At 09:02 AM 3/5/97 +0000, you wrote: >OK Ben, > I have done a lot of work in PWM for controling R/C servos In my >requirement there is a 15-20 mSec refresh of a 1-2 mSec pulse. > I'm interested in driving R/C servos as well. I've managed to use the 16C84 to generate a 1-2ms pulse width by using an excellent suggestion from Steve Hardy on this list. He suggested using the TMR0 and the prescaler together as a 16-bit counter running with a resolution of 500ns (8Mhz CPU clock). This works very well, but there is some work involved in reading the prescaler value since it isn't directly accessible. It basically involves switching TMR0 clock from the CLKOUT to the T0CKI/PA4 pin and manually clocking the PA4 pin to read out the count. > My code generates the Pulse output based on the clock speed and I use >the fact that I have a 5 mSec window to do other things. > Do you use TMR0 or depend on a fixed instruction timing loop to generate the pulse? > I calculated the fastest ans slowest time through the rest of my code >and ensured that it was less than 5 Msecs. this then alowed me to >calculate a constant time to get the 20Msec Duty cycle. > Just to make sure I understand you, do you mean the fastest and slowest time through the code that doesn't generate the servo pulse? > If you are interested in the code i can send it to you. BTW I control 2 >O/Ps for two servos but the timings will allow up to 7 Servos > IE 7*2 Msecs = 14 Msecs giving me a fixed time of 1 Msec and a variable >time of 5 Msec to do my other stuff. > I'd be interested to see your code as well. BTW, do you have any suggestions on reading servo pulse widths asynchronously? I'd like to be able to read two PWMs coming from a R/C receiver and drive one servo simultaneously. Thanks, --Anil