Pages: [1]   Go Down
Author Topic: Feeding +12V into digital pins  (Read 1083 times)
0 Members and 1 Guest are viewing this topic.
Frankfurt am Main
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all!

I'm asking you for advice to bridge the electronic sides of my project. Two light barriers will be polled for objects passing the lights, when an object passes and triggers a barrier, the barrier provides +12V on one of it's connections. The Arduino is programmed to watch for +5V on two pins.

What I need to know is a simple and reliable way to feed those two +12V signals into the Arduino. Done directly, it would damage the Arduino.

One way could be using two standard 5V regulator circuits (one circuit for one light barrier) based on a 78m05 and three capacitors, which should regulate the 12V (object detected) down to 5V.

Another approach, using a LM317K and one resistor, is described here http://www.roboternetz.de/phpBB2/konstantstrom.php.

Would you agree on either of these, is there a more straightforward solution?

TIA, Pat
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 514
Posts: 31539
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
One way could be using two standard 5V regulator circuits (one circuit for one light barrier) based on a 78m05 and three capacitors, which should regulate the 12V (object detected) down to 5V.
This is a classic beginners mistake. Do not use voltage regulators for signal voltage level translation.

Simply use two resistors in a potential divider to get the 12V down to 5V.
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Regulators are used to power circuits not for voltage translation of signal lines, the regulator would most likely try and draw too much current from your signal source. What you can use is a simple two series wired resistor voltage divider, where the 12vdc signal wires to the top resistor the bottom resistor wires to ground of both the signal source and the arduino. The junction of the resistors would wire to a arduino digital input pin. a 10k ohm top resistor and a 5k ohm bottom resistor would result in a 4vdc signal avalible at the junction of the resistors suitable to wire to the arduino.

Lefty

 
Logged

Frankfurt am Main
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Mike, Lefty, thanks for your swift answers.
I'm glad to read that the solution is by far simpler than I thought. Lefty, are 4V (as opposed to 5V) enough to provide a stable digital high on the pins? Would you advise to apply a 10kΩ pull-down resistor as recommended

when using the potential divider?

Best, Pat
« Last Edit: March 11, 2012, 05:12:12 pm by patrick » Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No pull-down resistor required, the voltage divider is also acting as a pull-down as the lower resistor is wired to ground and is why the arduino ground must wire to the divider and signal source's ground. As far as what a legal HIGH voltage is the AVR data sheet says minimum voltage for a HIGH is .7 X Vcc, so with an arduino 5volt board the value is 3.5vdc to 5.5vdc.

Lefty

 
Logged

Frankfurt am Main
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This may be the first time, things get less complicated, the more I learn about them  smiley-wink
Thank you Lefty, for helping me out on this matter!
Logged

Australia
Offline Offline
Sr. Member
****
Karma: 10
Posts: 397
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a good diagram of the wiring at the start of this post:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1288614795

You would use a digital pin on the Arduino rather than an analogue one. You would probably need to change the value of the resistors.
Logged

Frankfurt am Main
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the diagram lemming, but using an analogue pin here never was a subject to my case.
Logged

0
Online Online
Shannon Member
****
Karma: 162
Posts: 10478
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, that's why he said "You would use a digital pin on the Arduino rather than an analogue one."

Electrons behave the same for analog and digital pins!
Logged

[ I won't respond to messages, use the forum please ]

Frankfurt am Main
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're right. I wasn't looking close enough on the Terminals of the Arduino.
Logged

0
Online Online
Shannon Member
****
Karma: 162
Posts: 10478
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No pull-down resistor required, the voltage divider is also acting as a pull-down as the lower resistor is wired to ground and is why the arduino ground must wire to the divider and signal source's ground. As far as what a legal HIGH voltage is the AVR data sheet says minimum voltage for a HIGH is .7 X Vcc, so with an arduino 5volt board the value is 3.5vdc to 5.5vdc.

Lefty

 

Actually for the supply voltages used in Arduinos the input thresholds are 0.3Vdd and 0.6Vdd (ie 1.5V and 3.0V for a 5V supply).  In particular 3.3V will reliably be recognised as high.  These values apply to normal I/O pins (not Xtal or Reset) and only if the supply is 2.4V or greater.
Logged

[ I won't respond to messages, use the forum please ]

Frankfurt am Main
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good to know! Can this be found on the Arduino playground? If not, it should be pinned here or elsewhere.
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good to know! Can this be found on the Arduino playground? If not, it should be pinned here or elsewhere.

These specifications (along with many many more) are from the AVR datasheet for a 328p chip, of which every Arduino user should download a copy to have avalible at all times.

http://www.atmel.com/Images/doc8025.pdf

Lefty
Logged

Pages: [1]   Go Up
Jump to: