Go Down

Topic: Checking for 12 Volts (Read 733 times) previous topic - next topic

kajmaya

I need to look for 12v when a switch is pressed. In the schematic the H-12v is my sense line. I'm looking for a high on pin 2 of the Ardurino Mini. Could I get some feedback on this design and is this a good approach for solving the problem?





Thanks in advance.

johnwasser

I think that transistor is going to invert the signal.  The pull-up resistor will keep Pin 2 high unless the transistor conducts.  A high signal on the transistor base will cause the transistor to conduct and drag Pin 2 to Ground.  HIGH on input == LOW on output.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

dc42

You don't need R16, it does nothing useful. You can also omit R17 if you enable the internal pullup resistor in the microcontroller. I would increase R18 to 10K or more.

A simpler approach is to feed the +12V via a 100K resistor direct to the microcontroller input. The pin protection diode will protect the mcu, and the 100K resistor limits the input current to a safe value.
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.

winner10920

Are use a 7v zener to drop it to less than 5 but > 3, or a simple resistor voltage divider

oric_dan

Why not just use a 12V:5V voltage divider, 15K feeding into 10K.

kajmaya


Why not just use a 12V:5V voltage divider, 15K feeding into 10K.


Ok so this will work?



thanks

oric_dan

The nice thing about that sucker is, the input pin isn't floating when the sensor is
not connected.

kajmaya


The nice thing about that sucker is, the input pin isn't floating when the sensor is
not connected.


Oh I didn't know that. So I can eliminate the pull down?

dc42


Ok so this will work?


Yes, but for better protection against transients on the 12V signal I would use higher value resistors, e.g.  100K and 68K.
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.

oric_dan

Quote
So I can eliminate the pull down?


No, the pulldown is what keeps the input from floating, and also produces 5V to the pin.
As dc42 says, higher value Rs can be used, just keep the same ratio.

Read the part on figure 2,

http://en.wikipedia.org/wiki/Voltage_divider

kajmaya


Quote
So I can eliminate the pull down?


No, the pulldown is what keeps the input from floating, and also produces 5V to the pin.
As dc42 says, higher value Rs can be used, just keep the same ratio.

Read the part on figure 2,

http://en.wikipedia.org/wiki/Voltage_divider



Yea, I just read my posted then slapped my self in the head. I need both resistors. Dumb on my part. I will go with the higher values.

Thanks

oric_dan

However, also see the following thread, in regards the R values getting too large,

http://arduino.cc/forum/index.php/topic,135169.0.html

Osgeld

#12
Dec 02, 2012, 09:04 am Last Edit: Dec 02, 2012, 09:13 am by Osgeld Reason: 1

The pin protection diode will protect the mcu, and the 100K resistor limits the input current to a safe value.


ya know, I just dont trust those things

I just did a one off design to read optical switches @ 24 volts on a plc in parallel to arduino to pipe over USB to windows, and as much as I fought myself to trust the protection diodes, I ended up with 0.5 watt zeners and some fat resistors to limit everything down to about 1ma (ea * 8 channels) if all hell broke loose.

Simply based on the fact that no one can really nail down the numbers on them, and little glass diodes has to be more robust than a microscopic chip feature buried in epoxy
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

dhenry

Quote
is this a good approach for solving the problem?


It matters a lot if you want to detect the presence of a voltage, or you want to detect the presence of 12v.

In the 1st case, the simplest would be to stuck a resistor (10k for example) between the H_12v line and your mcu pin.

This approach has its drawbacks: it doesn't sense a particular voltage and it is sensitive to interference. You can then use a pull-down resistor to alleviate that. a 47k pull down is fairly good but I typically use a 22k pull down. With that, it produces a 1->0 when the input voltage is less than 1v * (22k+10k)/22k and 0-> when the input voltage is greater than 4v * (22k + 10k) / 22k. So by adjusting the value of the 10k / 22k resistors, you can get it to trip at 12v.

oric_dan

Quote
Quote from: dc42 on December 01, 2012, 11:57:09 AM
The pin protection diode will protect the mcu, and the 100K resistor limits the input current to a safe value.

ya know, I just dont trust those things


I'm with you on this.

If the input is a known voltage, then a voltage divider as described works fine. If the
voltage can be about anything > 5V, within reason, a resistor [10K, 22K, etc] feeding
onto a zener diode is probably better. For something dangerous, like 120VAC, I'd go with
a properly designed optoisolator ckt.

Go Up