# Bidirectional DC motor driver from single analog pin

I'd like to build about 12 units (too few to make custom PCBs, enough for time, cost and inexperience to be a concern) of a device mapping an analog (voltage, not PWM) input range of 0 to 5V to an output range of e.g. -12 to +12V, ~2W, with 0 output around 2.5V input. That probably has a name, but I have not found it.
Doesn't have to be exactly linear.

I can approximate such a device with a microcontroller (ATtiny85) and an H-bridge (L9110S), but with both input and output quantized at such a poor resolution (10 and 8 bit, typically), the result is too twitchy for what I'm driving (not motor, exactly, but a similar enough device using electromagnets).

Researching similar devices that are already being manufactured, I came across something almost perfect:digital audio amplifiers.
PAM8403-based boards are super cheap, assembled, efficient, have 2 H-bridges each, v.fast switching frequency, and drive stepper motors beautifully. And there are stronger amps available.
However, they achieve their functionality via AC coupling. So, a DC motor moves in response to voltage change, not absolute level. Without the input caps, they don't seem to work at all (at least, I couldn't make them)

What is the suggested solution? H-bridge-based motor driver + some magic on the 2 input pins? Modifying an amp's input? An analog circuit?

First, yes you do want to make PCBs. That will be easier and far more reliable than kludging up 12 units with flying leads or whatever.

Since your overall power requirements are low, you can afford to use class B amplifiers. Your maximum output is ±12V (so abs 24 V) and the load then draws 2 W, so the current at that point is only 83 mA. The worst case dissipation of the pass elements is when half the full voltage is applied to the load. Assuming a linear load, it will then draw ¼ the maximum power, or 500 mW. The total dissipated by the pass elements will also be 500 mW. This is split between two opposite legs of the two class B drivers, so 250 mW worst case per pass element. TO-220 cases in free air can easily handle that.

Here is what one of the two class B output drivers would look like:

The four transistors form a power stage with a voltage gain of about 2. You want some gain here so that the opamp doesn't have to drive its output too close to the power rails. But, you want to leave some of the overall gain to the opamp so that it is stable. R5 and R6 are the voltage divider for the overall negative feedback, and set the overall gain at 4. Since the output stage has a gain of 2, this means the opamp will also have a gain of 2, which is good.

You didn't say what accuracy and speed, but mentioned the load is like a motor and the circuit "doesn't have to be exactly linear". This output stage has a deadband at the crossover point. This allows for simplicity and guarantees both the high and low side drivers won't be on at the same time. It will also result in some crossover distortion. However, the opamp will compensate for that at low frequencies. This isn't for "HiFi" audio, but should be plenty good enough for driving a motor.

I didn't show the LM324 quad opamp power connections, but it should be powered directly from the ±12 V, with a proper bypass cap of course.

The functional block shown above is essentially a power amplifier that works down to DC. It is driven from a ±3 V control signal, and produces a ±12 V power output signal.

You use two copies of this block, each driven with a ±3 V control signal of opposite polarity. Use one of the remaining two opamps to convert your 0-5 V input signal to ±3 V, and the other to flip this around to the opposite polarity ±3 V to drive the other power block.

The load gets connected between the outputs of the two blocks. You can think of this sortof like a analog H bridge that can drive the load with nearly ±24 V.

• Awesomely detailed and clear description, thank you! BTW, by "no custom PCBs" I meant I'd be using perfboard. Probably. Maybe. OK, you figured me out, porcupine balls of leads, wires and solder are pretty much my MO.
– kaay
Feb 9, 2017 at 14:27

It sounds like what you need is a DC coupled power type OpAmp. As long as the generated 0-5V analog signal is not "steppy" (i.e. generated with plenty of resolution) this type of amplifier should give a clean output.

I could envision a part like the OnSemi LA6500 powered off +/-15V power supply being able to produce your linear -12V to +12V output. Appropriate resistors around the LA6500 would set your gain and offset to convert the input range to the desired output range. These parts can be attached to a heatsink if necessary and are capable of driving more current than you need but at the same time they are sold at nice prices.

By the way. In normal usage an H-Bridge is not suitable for direct linear drive of your load as requested. The H-Bridge is used as a full digital switching device. They can be used for motor speed control for example if a digital PWM signal at a high enough frequency is fed through the H-Bridge driver. In this case the coils of the motor integrate the high speed pulses from the H-Bridge driver and will produce a net equivalent drive of the coil proportional to the duty cycle of the PWM signal.

• Thanks, I'll see what I can do with the direct coupling. Input comes from analog sensors, so I'm good (though thanks for drawing my attention to it, reminded me my power brick was noisy). H-bridge; yes, that's why I was happy when I found the audio amps - they're designed for fast switching.
– kaay
Feb 9, 2017 at 14:15

You could try the next circuit, it gets a signal from 0 to 5Vdc and using two Op-Amps convert it to a signal from -12Vdc to +12Vdc, then the transistor stage powers your unit with more current. It's far away from being linear but it's a very simple circuit for your requirements.

• I don't see the point to R1. Also, if you include the output stage in the feedback loop, U1B will compensate for the deadband, at least at low enough frequencies. The output stage in the feedback loop would also significantly lower the effective output impedance. Beware of headroom, both due to what the opamp can do, and that lost by the B-E drops of the output transistors. Feb 9, 2017 at 13:39
• @OlinLathrop Thank you so much for the observations, I edited the schematic and it's much more convenient to work the way you said. Feb 9, 2017 at 14:18