Whats the best way to use 12vdc inputs for a 16f88 (example). I guess the question is what will require the least components...2n2222's and resistors or is there a leaner way. Thanks!
Just a single current limiting resistor in series - this limits the current, and clips to 5V on the internal protection diodes. Ensure the input pins you use have protection diodes (check the data sheet), as there are occasional pins that don't.
Nigel,
what is the maximum voltage you could put into a Pic pin? I have an application at the moment where I have 24v inputs, and I was toying between a zener, or opto-coupler. The reason being, that I can't guarantee the quality of the external inputs. What would you reccomend for reliability
Nigel,
what is the maximum voltage you could put into a Pic pin? I have an application at the moment where I have 24v inputs, and I was toying between a zener, or opto-coupler. The reason being, that I can't guarantee the quality of the external inputs. What would you reccomend for reliability
A single resistor is all you need, the protection diode ensures that it clips at a safe level, 0.7V above and below Vdd and Vcc. Check the MicroChip application notes, where one even feeds mains directly through a limiting resistor to an I/O pin.
With 4.7K it would pass 1mA or so through the protection diode using a 10V input, or about 4mA with a 24V input - as this current is bypassed to the 5V rail it's probably a bit too much current, bearing in mind a PIC's low current consumption. I would suggest values in the 100K to 500K region, and reduce the current to ten's of uA.
To expand a little more, the regulator driving the PIC won't be able to sink current. This means that if the current through the input pin exceeds the current being drawn from the 5V rail, the 5V rail will rise.
To avoid this problem, we keep the input current as low as possible.
If you're doing this to many input pins and are worried about the 5V supply getting too high, you could ad a 5.6V zener across the 5V supply to protect it.
hi,
If you have lotsa 4K7's you could connect 3 in series between the +12V source and 0V, take the 4V signal from across the lower 4K7, this would be a high enough voltage to been seen as a logical high by the PIC input pin.