On Wed, 31 Dec 1997, Alex Holden wrote: > But, Bob Blick suggested an idea which sounded interesting: sync the PWM > to the incoming pulse train. That way, you don't need to about the two > colliding, and wouldn't even need interrupts. Just: Wait for the > incoming pulse. Time how long the pulse is (most accurate way is to > reset TMR0 and read it again when the pulse ends). Decide if you are > going in forward, reverse, or stopped, and by what magnitude. Work out > how long the pulse width needs to be (a lookup table could be used here) > Set the direction output to the H-bridge. Set the PWM output high. > Reset TMR0. Wait for TMR0 to equal the PWM value. Set the PWM output > low. There may be a problem with this, it depend on the type of speed control to be duplicated. I have seen several mentions of the higher quality rc car speed controls (as in the size of a box of matches, able to handle 30-100 amps DC ~ 7-10v, switching rate of 2000hz+) used in the racing cars. The older units (IIRC) did somthing similar, very low switching rates, often based on the pulse rate from the radio. The problem, watsed power, arcing in the motor, not very fine control. Trying to remember the specs, I thing is was a several ms pulse with a cycle time of 15 - 20 ms, with most units centering at about 2ms, + 20ms (20ms delay + 2ms pulse). Basing the pulse rate for the motor control on the control signal would give ~50hz, slow and causes bad arcing when the motor is under load. I got out of rc racing several year ago, but even then the typical units were switching at 2000hz+ and pwm the power to regulate motor speed. I am just learning about PICs, but is there really a problem with a mere 2khz signal? How does the pwm out on the pics operate? Is it a set it and let it run type, or do you set the width and trigger it each time? ---------------------------------------------------------------------------- Christopher E. Brown (CB421) +(907) 357-5680 We are Pentium of Borg. Division is futile. You will be approximated. ----------------------------------------------------------------------------