Offline
Newbie
Karma: 0
Posts: 18
|
 |
« on: December 01, 2012, 02:37:41 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Massachusetts, USA
Offline
Tesla Member
Karma: 96
Posts: 6354
|
 |
« Reply #1 on: December 01, 2012, 02:54:26 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4644
|
 |
« Reply #2 on: December 01, 2012, 02:57:09 pm » |
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.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Offline
Edison Member
Karma: 3
Posts: 1712
|
 |
« Reply #3 on: December 01, 2012, 03:00:50 pm » |
Are use a 7v zener to drop it to less than 5 but > 3, or a simple resistor voltage divider
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 79
Posts: 2102
|
 |
« Reply #4 on: December 01, 2012, 03:01:59 pm » |
Why not just use a 12V:5V voltage divider, 15K feeding into 10K.
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #5 on: December 01, 2012, 03:14:08 pm » |
Why not just use a 12V:5V voltage divider, 15K feeding into 10K.
Ok so this will work?  thanks
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 79
Posts: 2102
|
 |
« Reply #6 on: December 01, 2012, 03:20:04 pm » |
The nice thing about that sucker is, the input pin isn't floating when the sensor is not connected.
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #7 on: December 01, 2012, 03:25:09 pm » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Faraday Member
Karma: 130
Posts: 4644
|
 |
« Reply #8 on: December 01, 2012, 03:26:26 pm » |
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.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 79
Posts: 2102
|
 |
« Reply #9 on: December 01, 2012, 03:30:47 pm » |
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
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #10 on: December 01, 2012, 03:33:26 pm » |
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_dividerYea, 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
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 79
Posts: 2102
|
 |
« Reply #11 on: December 01, 2012, 11:25:50 pm » |
However, also see the following thread, in regards the R values getting too large, http://arduino.cc/forum/index.php/topic,135169.0.html
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 33
Posts: 3618
@ssh0le
|
 |
« Reply #12 on: December 02, 2012, 03:04:48 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 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
|
|
|
|
« Last Edit: December 02, 2012, 03:13:39 am by Osgeld »
|
Logged
|
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
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #13 on: December 02, 2012, 08:37:19 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 79
Posts: 2102
|
 |
« Reply #14 on: December 02, 2012, 01:49:49 pm » |
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.
|
|
|
|
|
Logged
|
Murphy's Corollary: the "real" problem is usually what they don't tell you about, which leads to endless second-guessing. m
|
|
|
|
|