12v Output for an Arduino

I understand that the Arduino's operating voltage is only 5v. I do have an external power supply that runs off of 12v, but I notice that the voltage regulator on the board drops it down to 5v. Is there any pin on the board that will pin out to 12v? or will I need to implement an external DAC?

My end product is to have the user be able to adjust voltage on a pin using a serial interface from 0 - 12v to his/her specification

Vin outputs 12V, perhaps minus one diode drop.

If you want a variable voltage output you will either need a DAC or to low-pass filter a PWM signal. This will be 0-5V, so you will need to increase that. The simplest way would be with an op-amp with 2x gain running from 12V - that would give you 0-10V output (give or take a little at the top and bottom end - look for Rail-to-Rail input AND output op-amps).

Oh it would have to be as close to 0 - 12v as possible for testing purposes. We are testing some modular devices and its absolute low is 0v and highest value is 12v and we need to make sure the device we are testing can accept these ranges as well as variants in between, so I came up with the idea to use the arduino as a tiny 'black box' for testing this device in different ways.

So for 0-12v, an external DAC is required?
What if I were to use the vin (since apparently it can produce a 12v signal) and stick that 12v signal on a potentiometer. That value can then be analogously adjusted by the user with the twist of a knob, but I would like to have that voltage value read in back to the Arduino board and spat out in the serial output window, so that means that >= 12v value has to be fed back into the Arduino. If I did this, the results could be damaging correct? The best option is to probably stick a resistor on it to drop it to >= 5v for measurement?

The Vin pin is connected to the barrel jack via a diode. Whatever you put in to the barrel jack, less 0.7V, is what you get out of the Vin pin. Whether you take it from there, or from the barrel jack, or from the power supply you are plugging in, it’s all pretty much the same.

You can create a variable voltage that is manually controlled with a pot of sufficient value, yes. For 12V I would recommend at least a 20K? pot, maybe more. Connect it between your power supply +12V and GND, and the wiper will give between 0 and 12 volts. If you want it Arduino controlled, then you can still use a DAC or PWM, plus an op-amp - just use a gain that is slightly more than 2x so that it gives between 0 and 12V. You might want to consider a higher voltage power supply to give greater headroom. 15V is common for op-amps.

Then, for measuring it, you want to connect it to a voltage divider to reduce it back down to below 5V maximum. A 10K? and a 6.8K? resistor in series connected between your Vout and ground, and the junction between the two resistors connected to an analog input, should read between 0 and 4.857V assuming your power supply is really 12V. I’d personally be tempted to use 10K? and 4.7K? so it reads between 0 and 3.613V so that it’s possible for the input voltage to rise to as much as 15V before any damage is done to the Arduino.

Yes, with a proper voltage divider network (just 2 resistors), you can read voltages well above the 5 Volt limit. Just a word of warning tho. Make sure the resistor going to ground never comes loose. When mine did - dead board.

jackwp:
Yes, with a proper voltage divider network (just 2 resistors), you can read voltages well above the 5 Volt limit. Just a word of warning tho. Make sure the resistor going to ground never comes loose. When mine did - dead board.

That's what solder is for :stuck_out_tongue:

That's what protection diodes are for.

polymorph:
That's what protection diodes are for.

And a small (~100?) resistor on the input to limit the current.

Thanks guys, that really makes me feel better.
I was breadboarding, in a hurry, and was confident I had it right. I ASSUMED it was ok. Thanks for all your symphety . LOL

Thank you all for the amazing responses! Seriously, this was extremely helpful! you guys are the best!

I did have one random question though, I do have an unopened motor shield from Arduino, would it be possible to implement that shield as a DAC? does it have the capability to do so...? Totally random!

If not, the above responses work too!

No. a motor shield does not convert the digital (pwm) to analog, it basicly just amplifies the voltage/current, and provides forward/reverse ability. The motor shield is a digital module, not analog.

You can make a DAC with a resistor, and capacitor hooked to one of the pwm pins. It can be improved with some amplifiers.

Well I suppose that's fine too because the device we're going to be reading these voltages in to will have to be analog anyway instead of digital. If I had the motor shield, I could adjust the analog voltage levels on it? then if that's the case I wouldn't need a DAC at all since I wouldn't need a digital signal to be converted to analog correct?

the device we're going to be reading these voltages in to will have to be analog anyway instead of digital.

What device are you wanting to be reading these voltages in to ?
Maybe if we know that, we can tell if it needs clean analog voltage, or not.
It you have a url for it, would be great.

The device it is going to must require analog voltage. It's for a product I am helping develop at my job place, we do integrated technologies. I cannot say what the device is, but what it can accept is 0 - 12 volts analog and the point of the arduino is to test this device on varying levels of voltage to see if indeed the target device is processing the voltage input.

Ok, then tell us this. Does it draw current or just looking at a voltage. What is its input impedance ?
How accurate of a voltage do you need (1 tenth volt?)?
Would your device blow up if it got 13 volts?

the voltage is from 0 - 12 volts with an input impedance of 49KOhm / 0.1 uF, so this pin just looks at voltage levels, there is another pin that looks at current (0-20mA) but that's for a later time.

And it needs to be fairly accurate, 1/10th of a volt is good. Before with my little jerry-rigged DAC on a PWM pin, I was getting steps of .02 for example:
2.02volts, 2.04volts, 2.06volts, etc.

And it absolutely cannot go any higher than 12 volts, maximum operating voltage is 18.

Great.
You had a DAC on a PWM pin that seemed to work to some degree for you. What did it do well, and what did it not do?
Do you have an oscilloscope that you can view the voltage, to see how much ripple it has?

Apparently you need an amplifier to increase the 0 - 5V, up to 0 - 12V. Is that where we are at now?

If your power supply is below 18 volts, you should be ok, but for good measure a zener may be used to prevent over voltage.

Well that PWM and resistor/cap combo for a DAC worked somewhat well but two things:

  1. it could only go from 0 - 5v
  2. the impedance of the target device was too high for a 10k ohm resistor and 100uF cap

with #2 as soon as I plugged it into the target device, the suggested voltage that I was reading dropped considerably and with this device for testing, if the user types in 3.20v in the arduino serial interface, 3.20v should go out to the device (or as close to it as possible)

I think you would be much better off with an MCP4821 SPI controlled DAC. Gives 0 - 4.095V in 1mV steps. Pipe that through a rail-to-rail I/O op-amp with 3x gain to get 0 - 12.288V in 3mV steps.