PDA

View Full Version : reading pulsewidth


proto pro
03-28-03, 01:41 AM
I have been trying to read the pulse width output from an HITEC RC receiver but I must not be understanding the PWM-IN usage in the IsoMax manual. Can some one give an example of how to use PWM as an input?
Thanks in advance,
Dave

Dave
03-28-03, 10:01 AM
Hi Dave,
In addition to the manual, there is the IO Glossary available on the IsoPod Download page here -> http://www.newmicros.com/store/product_details/download.html . Page 6 of the glossary details an example use of PWM input using the following code :

DECIMAL
: GET-RC-SERVO ( -- n )
TC1 ACTIVE-HIGH
TC1 SET-PWM-IN
BEGIN TC1 CHK-PWM-IN ?DUP UNTIL ( wait for nonzero value )
4 10 */ ( scale by 4/10 )
;

GET-RC-SERVO . ( measure pulse width and print result )

This should be able to read and scale a input servo pulse and return the result in microseconds.

proto pro
03-30-03, 12:00 PM
Thanks Dave,
I don't know how I missed that link!
The code works good.
I have one more question. After looking htrough the documentation It looks as though the only pins for use with pulse in measurement on the V2 is TC0, TC1, TD0, TD1, TD2, & TD3, for a total of six. Is this in fact the case? Is there a way to have more?

Dave

RMDumse
03-30-03, 02:29 PM
Any of the timers can be used. One should not be used because it is the system timer TD3. Two are difficult to use because they have no specific input pins, so are essentially not useful this way TC2,3.

Yes TC1,0 and TD0,1,2 are easily available. But so are TA0,1,2,3 and TB0,1,2,3. These eight timer lines share pins with Quad 0 and Quad 1. So if you aren't using the quadrature, they're free for use for PWM or any other timer/counter related tasks.

So on the middle column of J6, from top of board (near J1 Pin1, opposite board edge from LEDs) the signals go
+5V, GND, TA0, TA1, TA2, TA3, +5V, GND, TB0, TB1, TB2, TB3. There are the pins timer names. They also have quadrature names. Internally to the processor chip the quadrature and timer circuits share these pins.