Go Down

Topic: getting 10V from arduino PWM (Read 1 time) previous topic - next topic


Hi, long-time reader, first time poster.

I'm interfacing some old 0-10V analog gauges to my arduino, and would like to be able to use the full gauge scale, not just 0-5V.

What's the best way to get the 0-5V produced from the PWM outputs scaled to 0-10V? It seems like an op-amp would work, but I'm not sure about the implementation details, or if that's the best way.

Any ideas?



yes you need an op-amp, as described here. You'll need to power the op-amp from 10V or more; 12V would probably be convenient!



Apr 23, 2007, 10:20 pm Last Edit: Apr 23, 2007, 10:23 pm by appelback Reason: 1
One way of amplifying is to use just a transistor (depends on the application). I have used a HEXFET power MOSFET transistor, more preciely the IRFZ24. Work really fine together with PWM ports. For example driving large amount of LEDs at 12v from the Arduino and so on, handles large currents also (up to about 15 to 17 A @ 10 V).


Thanks for the suggestions, I think I'm going to try a 741 opamp, but if I ever need to drive larger currents, I'll keep the MOSFET in mind.


After messing around with the 741, it seems to be a poor choice due to the complexity in getting it to work with a single-supply design.

Is there a better component to choose for this application? The MOSFET sounds interesting, but I don't have a very good grasp on how to implement it either.


Not sure how much current you need, but a typical rs232 transceiver (e.g. MAX232) generates +10V and -10V from a single +5 supply.  If you tap it at the right place (on the correct charge pump capacitor leg, or one of the output pins if you tie an input low) you can get ~ +10V.

Not sure if you'd want to use +/-10V to drive an op-amp,  or if you can possibly PWM the MAX232 input pin in some way to get  +/- 10V PWM on the output pin.

No idea how stable or clean, but it may be worth a look.



A common default choice for a single power supply op amp is an LM324. But you don't want to use an op amp. Your PWM output is just switching on and off very rapidly, it isn't really an analog signal. There is a schematic in the playground for driving multiple LEDs from an Arduino pin, http://www.arduino.cc/playground/uploads/Learning/multiple_leds2.jpg, it is similar to what you want to do. Just replace all of those LEDs with a single gauge connected to your +10v supply instead of the Arduino +5v. You must also connect the ground of your 10v supply to the ground of your Arduino.

The transistor operates as a switch which is off at low voltage and on at high voltage, you could use a FET here too, but the circuit shows a bipolar. If you use a FET you could lose the resistor, but funny things might happen between powerup and you enabling the pin as an output unless you put a resistor to ground... so stick with the bipolar.

Now, assuming you don't have a 10V power supply already in your circuit, the easiest way to get one of those is to power your Arduino from a 10-12V power supply. The regulator in the Arduino will still take it down to 5V for the digital logic and it will be available at the "raw" power out pin for driving your gauges. You might find that the 9V unit you have now is already making over 10V... they get a little funny at low loads.

To keep from pegging your needles you will have to either limit the voltage in software by never going too high, or you could stick a resistor between the gauge and the transistor. The size of the transistor will depend on the current required to make your gauge go to full scale... I'll make up a number... 8ma... and calculate with that...

Let V+ = 12volts
let Ig = 8ma  (current to peg gauge)
find R...

V+ = 10V + Ig*R + 0.2

... (10V is the voltage across the gauge when pegged, you called it a 10V gauge, 0.2 is the voltage across the bipolar transistor when full on.)

12v = 10v * 0.008a*R + 0.2
1.8v = 0.008a*R
R = 1.8v/0.008a
R = 225 ohms.
use a 220 ohm resistor, they aren't that accurate anyway.

If you still go over scale, then you guessed wrong at Ig, use a larger resistor until it works out.

Go Up