Drive an RC Servo from Analog Voltage
This is a circuit I designed to generate a PWM signal for an RC servo given an analog voltage or high frequency PWM. It has no microcontroller and can be built with one quad op-amp and passive components.
The op-amp I used in my implementation is a NJU7034D-ND, available from digikey, but any rail-to-rail quad op-amp will do.
Since the input stage has a low pass filter built in this circuit will accept a high frequency (>~5kHz) PWM as an input in addition to analog voltages.
- 1 Quad Op-amp (I used NJU7034D-ND)
- 1 10K resistor
- 1 50K resistor (or 2 100K resistors in parallel)
- 7 100K resistors
- 1 0.47 uF capacitor
- 1 0.047 uF capacitor
- 1 10K potentiometer (can be subbed with 100K pot, makes calibration trickier)
- 1 100K potentiometer
HOW IT WORKS:
Linear Ramp Generator:
This is the beating heart of the system, literally. This is an integrator and a hysteretic comparator hooked into a feedback loop that produces an oscillator with a linear ramp as output.
Low Pass Filter and Buffer:
This is simply a stiff RC low pass and an op-amp follower. The RC low pass removes high frequency noise from the input. The follower drives current to the calibration stage, which requires current that the RC low pass can’t deliver.
Every servo is a little different. These two potentiometers map the full swing of the input voltage to a small range of voltages feeding into the comparator stage. These have to be set properly for the servo to swing through its full range of motion. For calibration instructions, see the CALIBRATION INSTRUCTIONS section.
This generates the PWM that is sent to the servo by holding its output high when the input from the calibration stage is higher than the linear ramp from the oscillator and vice versa. The width of the pulse is directly related to the voltage coming in from the calibration stage.
- Connect power and ground. Connect the servo you want to use to the output. Connect the input of the circuit and set it to Vcc/2. The servo should swing to a position, probably one of its physical stops.
- Adjust the pot labeled ‘Amp Adjust’ all the way to one side so that its output is directly connected to the output of the ‘Bias Adjust’ pot.
- Rotating the ‘Bias Adjust’ pot should rotate the servo. Position the servo in the center of its range of motion. The closer to the center the better.
- Set the input of the circuit to 0V. Now adjust the ‘Amp Adjust’ pot until the servo is hitting one of its hard stops.
- Your circuit is calibrated. The full range of input voltages from 0V-Vcc should now map linearly to the position of the servo from one hard stop to the other.
- If your PWM frequency to the servo is too low or too high, decrease or increase (respectively) the value of the capacitor labeled ‘freq adjust’.
- You can use 2 100K resistors in parallel as the 50K resistor, reducing the number of different resistor values you need from 3 to 2.
- You can use a 100K pot instead of a 10K pot, reducing the number of different pot values you need from 2 to 1. This does make calibration trickier, just play with the pots until the range of motion is right.