Go Down

### Topic: 12V on digital input pins? (Read 17361 times)previous topic - next topic

#### chauens

##### Mar 09, 2013, 12:53 am
May be stupid to ask, I'm a beginner when it comes to micro controllers, could not find a definitive answer, all infos I found about this don't seem to be absolutely clear to me: can I feed digital inputs with +12V (regulated) as "high" signal on Arduino Mega 2560? I am intending to integrate additional functions by using an Arduino into my existing electronic circuits that run on 12V. I would need to sense +12V for high and GND for low on digital input. I have 32 lines to test.
Information says "operates on (recommended) 7-12 Volts" so at the beginning I guessed yes but then I also found that "input pins operate on 5V".
In putting my mind to it further, the voltage for the signals on the input pins probably needs to be originating from the on board 5V power supply. Is this correct?
I want to be absolutely sure before continuing.
I apologize in case my question is an insult to the experts.
Thanks.

#### majenko

#1
##### Mar 09, 2013, 01:11 am
Treat the input just like an analog input and scale the input voltage to 0-5v using a resistive divider.

There are thousands of threads on here about it.  Look around for "12V analog input", but then in your mind substitute "analog" with "digital".

#### nickn4

#2
##### Mar 09, 2013, 01:15 amLast Edit: Mar 09, 2013, 01:24 am by nickn4 Reason: 1
edit: ..wrong information

my bad, sorry

nick
humankind cannot obtain anything without
sacrificing something of equal value in return.

#### majenko

#3
##### Mar 09, 2013, 01:22 am

I think your awnser lies in the IOREF pin on your board.

the digital pins knows that 5v is equal to HIGH. although, you can change this value through the IOREF pin if im correct.
i never used it myself before, here's some info i found on arduino page of your board:

Quote
"IOREF. This pin on the Arduino board provides the voltage reference with which the microcontroller operates. A properly configured shield can read the IOREF pin voltage and select the appropriate power source or enable voltage translators on the outputs for working with the 5V or 3.3V"

whenever u connect 12V to IOREF, the reference to HIGH will be 12V.
i hope this helped, i sugest you look further into it before testing since im not 100% sure.

the reference voltage level should be changeable,
also for analog reference, that would be the AREF pin, maybe this page clears up a little about these two pins:
http://arduino.cc/en/Main/ArduinoBoardMega2560

nick

I wouldn't do that if I were you...

From the ATMega2560 data sheet:
Quote

Voltage on any Pin except RESET
with respect to Ground ................................-0.5V to VCC+0.5V

Putting 12V into IOREF will make the Magic Smokeā¢ escape - unless there is some magic being done on the board that separates the pin drivers from the chip, and it would have to be so small that you can't see it.

The IOREF pin is there purely for switching between 5V and 3.3V on the IO pins.

DO NOT CONNECT 12V DIRECT TO ANY PIN EVER!!!

#### nickn4

#4
##### Mar 09, 2013, 01:26 am
@majenko:
sorry, i eddited and removed it right away.

i gues i mistranslated it that information.
im glad i never were in the need to use that pin that way xP

thnx anyway

nick
humankind cannot obtain anything without
sacrificing something of equal value in return.

#### CrossRoads

#5
##### Mar 09, 2013, 01:33 am
The IOREF pin is there for letting shields know what voltage the IO pins are expecting.
It could also be used a voltage source (it is the output of a voltage regulator); on the Mega it is tied to 5V on the header pin with a 16mil wide trace.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### Docedison

#6
##### Mar 09, 2013, 01:47 am
There is always pin 8 of the power connector header, Vin, BUT CAREFUL PLEASE there is no reverse protection... and will accept an input of 6 to 12 Volts, 7.5 being Ideal.

Bob
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

#### nickgammon

#7
##### Mar 09, 2013, 02:33 am

Information says "operates on (recommended) 7-12 Volts" so at the beginning I guessed yes but then I also found that "input pins operate on 5V".

The 7-12 volts goes into a voltage regulator which turns it into 5V (and some heat). The other pins are not allowed to exceed 5V.

Look up voltage dividers, you will need a couple of resistors of a suitable ratio to reduce the incoming voltage to the range 0 to 5V. Also make sure it isn't negative.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

#### retrolefty

#8
##### Mar 09, 2013, 03:44 am
Well I will go against the gain here and say there is a way to safely wire a +12vdc digital signal to a arduino digital input pin. It requires that you wire it through a series resistor of a high enough resistance such that the positive clamping protection diode for the input pin will be current limited to at or below it's maximum rated continuous forward current rating, around 1 ma I think. The clamping voltage will hold the input voltage equal to chip Vcc + Vf of the clamping diode.

So a two resistor voltage divider or a single resistor current limiting resistor, your choice.

Lefty

#### robtillaart

#9
##### Mar 09, 2013, 01:10 pm

If you want to use 12V you might check the ruggeduino - http://ruggedcircuits.com/html/ruggeduino.html -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### afremont

#10
##### Mar 09, 2013, 05:24 pm
There are ways to safely connect 12V (or larger) signals to your device, but they involve adding a few electrical parts to condition the signal.  They will "clip" the signal at 5V to protect the input pin.   I didn't read every word, but this looks like a pretty good write-up on it all:
http://www.kevinmfodor.com/home/My-Blog/microcontrollerinputprotectiontechniques
Experience, it's what you get when you were expecting something else.

#### dc42

#11
##### Mar 10, 2013, 11:41 am
I'm with retrolefty on this one. Use a 47K or 100K series resistor between the 12V source and the digital input pin.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### chauens

#12
##### Mar 11, 2013, 12:05 am
Thank you all for the good tips.
The ruggeduino looks good but compares to the Arduino UNO so it does not have enough i/o pins for my application, even if I multiplex.
I will probably use the resistors with diode clamp or perhaps the optical isolator.
Thanks again.

Go Up