|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Did you know...
|
Serial Wombat Hardware Transition Measurement Channel ModeA few pins on the Serial Wombat have special hardware assisted features capable of measuring the timing between high to low and low to high transitions. These pins can accurately count and time transitions occuring as often as every 15 microseconds, and as infrequently as every two seconds. This channel mode was designed with two primary goals in mind: allowing the measurement of periodic events such as a position sensor on a rotating wheel or shaft, and allowing the measurement of standard R/C Servo pulse inputs from a receiver or other source. This channel mode is different from most other Serial Wombat channel modes in that it only works on a few specific pins: 16, 17, 33, 34, and 35. These pins have special hardware which allows interrupts to occur upon a pin state transition. When this happens, the Wombat will stop what it's doing, capture a new timestamp corresponding to the time of the transition, increment a counter for that pin, and return to its prior work. This allows the Wombat firmware to be sufficently responsive to inputs while still maintaining the round-robin style pin scheduling used by the Serial Wombat executive. When the host enables the Hardware Transition Measurement Channel Mode for one of the eligible pins, a high priority interrupt is enabled inside the Wombat for that pin. Any time this input pin changes state, a small amount of interrupt code will be executed at a higher priority than other tasks in the system. This presents a potential problem for the system. If pin transitions occur faster than the Wombat's CPU core can process the interrupt code, then the Wombat will spend 100% of its time trying to record these transitions. This results in a situation where the rest of the Wombat firmware, including the Serial Port receive software which could otherwise be used to turn off this mode is starved. In order to avoid this situation, the system design should not allow pin transitions on pins using Hardware Transition Measurement to occur more often than every 15 microseconds. This applies to the summation of all pins which are enabled in this mode. This is to say that if all 5 eligible pins are enabled, on average, only one pin should transition every 15 microseconds. Future versions of the Serial Wombat will include a user-enabled watchdog function which will reset the Wombat if the communications code is not serviced within some period of time (likely 1 to 2 seconds). This will disable all channel modes and allow the host to regain control in the event of a starvation event. Even if these conditions are met, it is possible that under some circumstances transition interrupts may consume enough of the Wombat's CPU time to cause other tasks to run slowly. It is recommended that a throughput analysis be performed under realistic usage conditions to determine if the Wombat has sufficient CPU power to perform all desired tasks. Documentation on how to use the Wombat's internal CPU usage monitoring will be available in the future. For each of the 5 pins the Wombat keeps transition timestamps of the two most recent high-to-low and low-to-high transitions. This allows the Wombat to provide period/frequency information, and durations for high and low sections of a wave form. This can be used to accurately measure the frequency and duty cycle of an incoming PWM signal. Each of these four times is stored as a 24-bit number. Each 'tick' of the time represents 1/16 of the clock used by the Serial Wombat. Therefore, the 32Mhz internal clock would yield a time of 500 nanoseconds. The absolute value of these timestamps has no meaning. However, by comparing timestamps of events which happen within 2 seconds of each other, relative timing can be determined. Additonally, a counter is kept for each pin which counts the total number of transitions for that pin. This is a 16 bit value which will wrap around from 65535 to 0. This counter can be used by the host to determine if new timing data is available, and can be used to determine the average number of transitions over a period of time. The Hardware Transition Measurement function can provide one of a number of different outputs as it's public data:
Message format:The first message is used to enable interrupts so that the special hardware on the selected pin can begin measuring transitions. This message also configures which aspect of the transition measurements is presented to the rest of the system as public data.
The second message is used to retreive transition data. It is possible that the user may wish to retreive more than one set of data for a set of captured transitions. For this reason, the host can choose to suspend additional captures after the message is returned to the host. This allows, for example, the host to request both high and low times for the same set of 4 transitions, allowing a calculation of duty cycle. This is not possible if additional transtions are captured between requests. If the host is only interested in one piece of data, such as pulse high-time, then additional captures can be left enabled so that additional data is captured after the message is returned.
Example:
Configure channel 16 to capture the high time of pulses. Then issue a command asking for the high time to be returned to the host, without pausing captures. Response will be for a high pulse of 0.7624 seconds, pulse number 4217 SEND to Wombat:
200 16 24 1 0x55 0x55 0x55 0x55 ; Set pin 16 to Hardware Pulse Management mode,
; Report high time as public data (1)
SEND to Wombat:
201 16 24 1 1 0x55 0x55 0x55 ; Get High Time from Pin 16, don't pause
RESPONSE from Wombat:
201 16 24 0x17 0x44 0x40 0x10 0x79 ; High time = 0x174440 = 1524800 = 2000000 * .7624
; Count = 0x1079 = 4217
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright Wombat Interface Products, 2005-2008. All Rights Reserved.