Go Down

Topic: Detecting 12 volts on input pin (Read 488 times) previous topic - next topic

DaveO

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.

James C4S


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.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

DaveO

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.

MarkT

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).
[ I won't respond to messages, use the forum please ]

James C4S


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
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

DaveO


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.

GaryP


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
The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

James C4S


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.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up