## PWM to Digital Signal

I am trying to make an R/C sumo bot for a competition. What would be the easiest way to run regular DC gearhead motors from a servo controller? I'm thinking of somehow converting the pwm signal into a digital signal that would run the motors forward or backward.

If you do go down the microcontroller driving an H bridge route, the output signal from the receiver is 5V DC, with a 1 to 2 ms pulse roughly every 18 to 20ms, about 50 or 60Hz.

The equivalent of 1.25ms counting should then be subtracted. (if, for example it counts to 200 in 2ms, you should subtract 125). Move this to register A.

Subtract the actual value of A from the highest possible value of A (when the receiver is putting out the full forward signal.), putting the result in register B. If the result is greater half the maximum value of A, plus 5, then put a high on bit 1 of register C. If the result is less than half the value of A, minus 5, put a high on bit 2 of register C. The +-5 allows for inaccuracies.

#########

If bit 1 of C is high, set A = A minus the half the maximum value of A, set B=B minus half the maximum value of A.

This sets A as the high time, and B as the low time.

Set one of the outputs to the H bridge high, then run a delay of 16ms divided by half the maximum value of A, repeat A times.

Set the output low, then run the delay B times.

set A,B and C to 0, then goto start.

########

If bit 2 of C is high, do the bit sectioned off with the ###, just swap A and B over, and put the high output on the other input of the H bridge.

hopefully that will explain roughly how to do it, though to be honest, it is 9pm on friday afternoon, and I've been doing Alevels all week, so i'm not thinking too straight at the moment.

If you need any help with the programming, just ask.

As for forwards and backwards, for a DC motor you want an H-bridge; no way around that.