Page 1 of 1

What is the best method to connect 12V inputs to a pic.

Posted: 21 Feb 2014 18:28
by nayantha88
What is the best method to connect 12V inputs to a pic.
I used a pc123 and a bc327 transistor. But sometimes it wont work and I don't know why.
Attached document is my circuit. It may be not working i found it from google

Now I'm trying to use 4n35. But I don't have a schematic
Cant use voltage divider because the Input voltage may change from 9 to 24Vdc

Can anyone Guide me?

Re: What is the best method to connect 12V inputs to a pic.

Posted: 22 Feb 2014 08:27
by lejeff
For a digital input with 4n35, datasheet is here : http://measure.feld.cvut.cz/groups/edu/osv/4n35.pdf
diode forward voltage is 1.4V at Imax forward current 60 mA (at 25°C)
at 24V the resistor value is (24-1.4)/60 10exp-3 = 380 ohm
at 9V with 380 ohm the diode forward current is about 20mA (within the limits)
so you put a 380 ohm resistor in serial at the input, a 10k resistor between collector and +5V or between emiter and 0V, depending of your need
that's all
schematic is here
http://www.befriendwe.com/wp-content/up ... iption.png
You can choose a lowest forward current to calculate the resistor at 24V but consider the forward current at 9V with the same resistor (too low it doesn't works)

Re: What is the best method to connect 12V inputs to a pic.

Posted: 23 Feb 2014 13:48
by nayantha88
How to use separate grounds??

Re: What is the best method to connect 12V inputs to a pic.

Posted: 11 Apr 2017 08:42
by cgengineer
Hi

you can use a series resistor with a clamping zener

Input impedance of PIC input is very high so you can use a high value series resistor and a little zener. This simplify debouncing because you can place a capacitor in parallel with zener to realise a first order low-pass filter

The suggested optocoupler solution is good but has a low input impedance that maybe not good for who's feeding that input: but i saw that you are in a trouble about grounds, so don't worry, simply calculate the resistor for the input diode, place the collector of the output transistor at uC Vdd, place the emitter at the input pin and pull down it to ground with a resistor of at least 10k (the value is based on the frequency needed for the input)

Best