Pages: [1]   Go Down
Author Topic: Detecting 12 volts on input pin  (Read 401 times)
0 Members and 1 Guest are viewing this topic.
South Africa
Offline Offline
Sr. Member
****
Karma: 2
Posts: 416
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to detect if an external relay is powered. The Common on the relay is 12.8 V - I can't change that.

Can I connect the N/O pin ( 12.8 V when relay on ) to the Arduino input pin using a resistor ?

If so, is my guess of a 390 ohm resistor correct ?  ( 12.8V to 5V 20mA )

would there be any down side to long time usage ?  The relay ( and therefore power to the input ) will be on continuously for a few days at a time.
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can I connect the N/O pin ( 12.8 V when relay on ) to the Arduino input pin using a resistor ?
If so, is my guess of a 390 ohm resistor correct ?  ( 12.8V to 5V 20mA )
I'm not sure I understand what you think that would do.

If you have an extra NO or NC contact, you could setup a pull-down or pull-up circuit that would provide a digital output.

Otherwise, use a voltage divider from the N/O pin.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

South Africa
Offline Offline
Sr. Member
****
Karma: 2
Posts: 416
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi James

My (very limited) thinking was that, just as a resistor would reduce the power for a LED, so it could also reduce the power for an input pin.

Do you have a diagram or link for a voltage divider for this type of application ?  All I need to know is when the external relay is powered - that is, when there is 12.8V on the NO contact.
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12194
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, the 20mA limit is for when the pin is an output driving a load.

As an input you must not take it above the 5V rail or below the GND rail by more than a fraction of a volt.  It will probably burn out the protection diodes if anything like 20mA flows in this fashion.

You should definitely consider using a resistive divider to bring that 12V down to 4V or something safe like that.  Limiting the current to a fraction of a milliamp will also be a wise precaution - thus a resistive divider of 22k and 10k (takes 12.8V down to 4.0V which is below 5V but high enough to guarantee counting as logic HIGH).
Logged

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

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My (very limited) thinking was that, just as a resistor would reduce the power for a LED, so it could also reduce the power for an input pin.
Power, Voltage, and Current are all different but related things.  Resistors drop a voltage relative to their resistance.  The amount of current through two resistors is the same.  The voltage drop would be the resistance (of each resistor) times this series-current.  This concept is called "Ohm's Law."
http://en.wikipedia.org/wiki/Ohm's_law

Do you have a diagram or link for a voltage divider for this type of application ?  All I need to know is when the external relay is powered - that is, when there is 12.8V on the NO contact.
http://en.wikipedia.org/wiki/Voltage_divider

Use something relatively large, but not extremely large like 5K for Z1 and 10K for Z2.
http://www.raltron.com/cust/tools/voltage_divider.asp
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

South Africa
Offline Offline
Sr. Member
****
Karma: 2
Posts: 416
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use something relatively large, but not extremely large like 5K for Z1 and 10K for Z2.
http://www.raltron.com/cust/tools/voltage_divider.asp

Many Thanks for the info James.

Looking at the calculator, if I put R1 = 5000 and R2 = 10000 then the output voltage is 8.533 -- wouldn't this kill my Arduino ?

If I switch the 5k and 10k around, it shows 4.267 output volt.

Besides that, I was searching and found this :
http://arduino.cc/playground/uploads/Learning/Level_shifting_4_arduino.pdf

I do have 10K resistors ( notes say to use 10K if voltage higher than 12V ) and the 2N3904, so would this be just as effective / reliable a solution ?

I have tested it with both resistors 10K and it appears to be working.
Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 7
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking at the calculator, if I put R1 = 5000 and R2 = 10000 then the output voltage is 8.533 -- wouldn't this kill my Arduino ?

What you think? If you were just told NOT to go over 5V?

Dividing voltage is easy with resistors. If you have 12V to divide, try this:
Connect twelve(12) 1k resistors in series, and measure voltage between each connection and GND? You should see the correlation between voltage and the any resistor combination. That way you can calculate any voltage to input pin. Works with output too, but then you need to take current limitations into your calculation, output pins can't handle much, safely 20mA.

Cheers,
Kari
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If I switch the 5k and 10k around, it shows 4.267 output volt.
Yeah, R2 should be 5K, I wasn't thinking when I typed it.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Pages: [1]   Go Up
Jump to: