0
\$\begingroup\$

I have 12V, Use these 12V to power a device (that has a 12V output signal) and to power a 7805. After the 7805 there is a pic microcontroller where I would have to connect the output from my device. I was thinking of having 2 resistors in a 3/1 ratio in order to have about 4V at the pin of the pic. Can this be done, given that the ground is common, or will it give some sort of problem with the lm7805?

\$\endgroup\$
2
  • \$\begingroup\$ It should be OK but it's always sensible to use fairly high value resistors and a schottky diode from the input pin to 5 volts to catch any over-voltage. \$\endgroup\$
    – Andy aka
    Feb 19, 2018 at 17:08
  • \$\begingroup\$ Using three equal resistors would be better. That way if one is faulty or gets shorted, you do not blow up the PIC. \$\endgroup\$
    – Trevor_G
    Feb 19, 2018 at 18:17

2 Answers 2

2
\$\begingroup\$

All you need is one resistor about 100k in sereis with the signal. the PIC has internal diodes that will protect it from the current that flows in the resistor. the input will appear high for voltages above about 2 to 3 volts, if you want to increase that threshold to around 6V then adding a 47K resisto from the GPIO to ground would do that.

LM7805 can swallow a few milliamperes of back-feed so if the pic isn't using the excess signal current the 7805 will deal with it for you, if you're worried put a 5.1V zener parallel with the PIC.

However I don't think 7805 is really suited to automotive applications, the voltages can be well above 40V

\$\endgroup\$
3
  • \$\begingroup\$ That is not great advice. If the 5V regulator is turned off the 12V will try to power the pic though the IO pin at 12V. This is a general issue when relying on the protection diode. Granted the 100k will help control that effect, however, 100k on a signal line leaves you extremely sensitive to EMI, which if this is an automotive application, will be problematic anyway, so you have conflicting requirements. The zener, though I would use a 4.7V, is a good add in all cases though due to those transients you mentioned. \$\endgroup\$
    – Trevor_G
    Feb 19, 2018 at 19:14
  • \$\begingroup\$ Thanks, not sure I understand: if I put a 100k resistor, it will only limit the current, right? But the signal will still be 12V, right? Wont that fry my pic? \$\endgroup\$ Feb 19, 2018 at 22:35
  • \$\begingroup\$ the 7805 will limit the supply it to 5V unless the connection to the PIC is broken. the PIC has internal diodes that will limit the voltage tosomething safe. \$\endgroup\$ Feb 20, 2018 at 5:02
1
\$\begingroup\$

I was thinking of having 2 resistors in a 3/1 ratio in order to have about 4V at the pin of the pic. Can this be done, given that the ground is common,

Yes, you can do that. However it may not be safe if the device's 12V output has transients on it (due to EMI or an inductive load) and if the PIC is not powered then enough current might be injected into the IO pin to start it up.

To isolate the PIC from the signal source I use a bipolar transistor, which is much more robust than the MCU's CMOS input. The circuit looks like this:-

schematic

simulate this circuit – Schematic created using CircuitLab

Of course this circuit inverts the signal, but that is easy to accommodate in software (just remember that logic 0 = 12V on).

R3 and R2 are chosen to produce ~0.6V on the Base of Q1 at around half the expected input voltage (6V in this case). D1 is only required if there is a possibility of large negative voltage spikes, which might be caused by a motor or relay across the input.

To further reduce the number of components you can use a 'digital' transistor (with built-in Base resistors) and the MCU's internal pullup in place of R1. However this may make the circuit more susceptible to EMI, and if the transistor breaks down it could feed high voltage into the MCU.

In one project I used a digital transistor with additional resistance in series with the Base, both to raise the input threshold and provide extra protection. The SOT-23 transistor and 1206 size resistor didn't take up much board space.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.