5V Logic from 12V

Discussion in 'General Electronics Discussion' started by Xenobius, May 15, 2012.

1. Xenobius

125
0
May 15, 2012
Hi all,

If you had 12V and you wanted a logic signal to a uC or an Arduino for example which solution would you prefer design wise (not cost wise).

1. Would you use a transistor, feed the 12v to base and switch 5v to arduino?
2. Would you use a 20k - 10k resistor (voltage divider) to take 4V to arduino?

Regards
X

2. (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,490
2,832
Jan 21, 2010
I'd probably go the voltage divider route, but I would also consider the 12V source and if it were noisy I might add some additional components to ensure that the signal to the arduino did not contain spikes (say a zener diode or diodes to the supply rails).

3. Xenobius

125
0
May 15, 2012
Oh this is interesting. Would you be so kind as to show me how to connect them? I can assume that the 12V will be from a car battery which will make it very stable BUT when the electric_match goes off, I don't know if it will spike or something (I still have to test).

So assuming I will have some noise, how to you connect the diode/s with this voltage divider?

Thanks once again

4. (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,490
2,832
Jan 21, 2010
12V from a car is *very* noisy.

I'll draw a circuit for you shortly

5. (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,490
2,832
Jan 21, 2010

Shows a common ground and your resistive divider, chosen to give approx 5V.

The capacitor will help absorb variations and the zener (a 5.1V device) will remove any higher voltages that get through.

This shows a modification to a simple voltage divider, but it turns out that the lower resistor is not really required. Adding a resistor (say 10k) between the output of this and the arduino input will provide even more protection.

I'd pick something like 20k for the upper resistor, 15k for the lower, 0.1uF, and a 5.1V zener diode.

You have to remember that the battery voltage on a car system can vary from about 10.5 to 15 volts. This circuit will be a little marginal at the lower end, but not if you remove the lower resistor.

File size:
4.4 KB
Views:
3,474
6. Xenobius

125
0
May 15, 2012
Thats great I think this is settled then. I will buy some zeners and will do it this way.
Thanks a lot!!

7. KrisBlueNZSadly passed away in 2015

8,393
1,271
Nov 28, 2011
Steve's advice is good as usual, but I have a few points to add.
1. The noise filtering capacitor, and the capacitance of the zener diode (which can be in the nanofarad range) will both cause a delay on both the rising and falling edge of the input as seen by the micro. Steve's suggested values will give a delay of about a millisecond. If you don't need immediate detection of the input condition, then there's no problem.
2. All wiring connected to a vehicle's electrical system will carry large common-mode and differential-mode noise when the engine is running. In this case this applies to the input signal, up to the first resistor. Such wiring should be kept physically away from the microcontroller and any other sensitive components and circuitry. I suggest putting the resistor immediately next to the connector that the signal comes in on, so the length of the "net" from connector pin to resistor is as short as possible. Also a circuit like this should be grounded to the chassis at a single point; don't bring in another ground on the same connector, just the one input wire. Also the power input should be treated in the same way as the input (assuming it's powered from the vehicle's battery), including resistor-inductor-capacitor filtering, and probably a star ground (see Wikipedia etc).
3. Steve says the bottom resistor isn't needed, but this depends on the characteristics of the circuit driving the input. If the input signal swings firmly between +12V and 0V then you don't need the resistor, but if the signal is "switched +12V" (for example, +12V fed through a relay contact), you do need it, because without it, there would be nothing to pull the input to 0V when the contact opens. I'd recommend using it in all cases, or instead, using a pulldown resistor straight across the input. In this case you can remove the bottom resistor in the voltage divider, and you'll get the wide input voltage range.

8. Xenobius

125
0
May 15, 2012
Oh but I didn't tell you that the battery will be standalone (not connected to a car) Im sorry for missing this detail. I think that I will need the bottom resistor then.

Awesome forum too!!

9. (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,490
2,832
Jan 21, 2010
Probably a good idea

125
0
May 15, 2012
Hehe will do

11. Xenobius

125
0
May 15, 2012
Oh dear... what do I do to make the logic available immediately? As in, how do I lower the capacitance?

Thanks

12. (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,490
2,832
Jan 21, 2010
Well, you haven't told us what this signal is supposed to do. Reacting in less than 1ms means that you may also react to transient voltages.

To reduce the capacitance, you, well, you reduce the capacitance. You might use 0.022uF

13. Xenobius

125
0
May 15, 2012
Hi Steve,

You're right. Ok so basically as you might have noticed I am asking questions in 2 separate threads as I thought they were separate but now they are kinda going to join so I'm sorry about this.

My aim is to use an Arduino to switch 74HC595's (8 Bit Shift Registers Output) basically because I need to switch over 800 of these electric matches.

Since this is a safety critical application I will also need to read back what I have written using 74HC195's (8 Bit Shift Registers Input) so that if something just doesn't match the system will shutdown. So to answer your question, the signal that I intend to read from the 12V, will be fed into the 74HC195 and into the Arduino for processing.

I hope this makes it easier for you to help me

Thanks All
X

14. (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,490
2,832
Jan 21, 2010
But 74HC operated from 5V.

Where does 12V come into it (aside from perhaps being used for the ignitors)? Or will you be reading back from the ignitor itself?

You really need to show us a circuit diagram of the various pieces so we can figure out how it all links together.

15. Xenobius

125
0
May 15, 2012
You've said it perfectly. The 12 will be used to turn on an LED and to blow the ignitor. I will then need to read from the ignotor itself to see if it blew or not!

So thats why I need to get a logic from 12v into 5v to feed it into the 74hc.

The following is a description of what I intend to do (even if you said the circuit is wrong) but just an idea... I will need to fix this schematic.

If I send 12VTest, One of the LEDs will turn on using R3 as a limiting resistor and straight through the ignitor marked J9

When I pass 12VLive, the other led will turn on indicating that the system is live but will only trigger when Q1 mosfet is triggered using the logic O1 from 74hc595 limiting the current to 1A using R2

Once the ignitor blows there will be an open circuit. I will then use R5, R4, D2 and C5 to READ a 0 logic into the 74Hc195 to confirm that the ignitor blew.

Thanks once again
X

Attached Files:

• Schematic.jpg
File size:
14.9 KB
Views:
500
Last edited: May 15, 2012