Using Radio Control Transmitters for Motor Control


Sometimes its useful to be able to control a motor’s speed or position with a radio controlled signal.  RC (car, airplane, boat) radio transmitter and receivers are readily available and relatively inexpensive. For example, I just picked up a 2.4GHz spread spectrum transmitter and receiver for about $60.  To use these devices with standard DC motors you just need to do a little numerical/hardware conversion.

A standard RC signal from a receiver is a pulse repeated over a regular interval.  The pulse has a period of around 20ms, and a positive pulse width of 1-2ms that represents the user control position (a joystick, trigger, wheel, or switch, depending on your transmitter).  1.5ms is the neutral position that the joystick returns to when not touched.  1ms and 2ms represent the extremes where the joystick is moved to either end point.  By measuring the pulse width you can tell where the joystick is.

Number conversions:
We need to…
1.  read a pulse value from an RC receiver
2.  convert that to a motor drive signal

If we assume that we can measure the RC pulse width in 1us intervals, as can be done with the Synaptron Micro using the signal input pin, then we have a value of 1000-2000 to work with (1-2ms in 1us increments).   We need to convert that to a motor speed and direction.

Let’s further assume we’re using a  Microchip dsPIC33 operating at 36MHz with hardware pulse-width modulation (PWM) signal generators and a 20KHz period.  With this setup the PWM signal has a resolution of 3685.  This is also the default setting of the Synaptron Micro.  Setting the PWM register in the microcontroller to 3685 is equal to 100% positive duty-cycle.  A PWM value of 3685/2 =   1843 = 50% duty-cycle (or half power and approximately 1/2 speed), and a PWM value of 3685/4 = 921 = 25% duty-cycle (or quarter power and approximately 1/4 speed).

For a single motor direction application you need to convert 1000-2000 (RC pulse width)  to a value from 0-3685 (positive duty-cycle value).  PWM value  = (RC signal – 1000) * 3.685 does the job.  A pulse of 1000us duration = (1000-1000)*3.685 =  0 PWM value (stopped).  On the other extreme a pulse width of 2000us => (2000-1000)*3.685 = 3685 (full speed).

For bi-directional motor applications you just modify the equation to (RC signal – 1500)*7.37.  Therefore, and RC pulse of 1000us results in (1000-1500)*7.37 = -3685 where the absolute value is equal to the duty-cycle and the sign is equal to the direction the motor needs to turn.

The resolution of this system is dependent upon the resolution of the RC signal measurement.  Measuring 1us intervals allows about 9-bit resolution in bi-directional operation (500 motor speed steps) and 10-bit resolution in unidirectional applications (1000 motor speed steps).

A little bit about the H-bridge:
Modern H-bridges used to drive DC motors are made from MOSFETs, and if you use integrated circuits they can be driven by logic level signals.  You can drive both sides of an H-bridge using a single pulse-width modulation drive signal, but that method is generally less efficient from a power dissipation standpoint.

In most applications each switch of the H-bridge is driven with a different pin of the microcontroller.  The PWM signals are applied to the low side switches of the H-bridge and the high side switches are just turned on or off (low side = switches connected between the motor and ground, high-side are the switches connected between the power supply and the motor).   PWMing the high side switches can be done, but this usually results in higher power dissipation due to the longer rise and fall times of the PWM signals.  Based on the h-bridge diagram above we know we need two PWM generating pins for the low-side switches in the H-bridge and two on-off controls for the high-side switches.

Position Control:
You can also use the RC signal to generate a position control signals.  This is quite a bit more complicated.  Essentially you convert the RC signal to a desired position and then run the difference between the desired position (RC signal) and actual position through a PID algorithm.  The output of the PID algorithm is the PWM signal.  You can read more about that in the Synaptron Micro user datasheet.

Speak Your Mind