12V analog input on 3V3 GPIOs

Thread Starter

Fyod

Joined Jun 2, 2019
39
Hi everyone,
The topic of reading 12V automotive signals on microcontroller inputs has a wide array of answers all over the internet. I believe opto-isolation is overkill here and have found the attached circuit (with dividers for 5V inputs, not 3V3) which seems to be a solution that would pass automotive standards (not that I need to, but peace of mind and all) and would like to confirm whether this is suitable for the following conditions and if there's anything else to consider:
1) High/low detection (seems obvious)
2) Square wave detection (RPM) <500Hz, around 10V
3) Sensor value detection (simple ADC)

Any thoughts are welcome.

divider.png
 
Last edited:

Ian0

Joined Aug 7, 2020
13,097
Not bad, but 15k/40k gives 5V output for 13.33V in, so you won’t be able to tell the difference between 13.3V and 13.8V (float charge) or 14.7V (boostbcharge) or any possible overvoltage situations.
I would suggest a higher division ratio, so you can read up to at least 16V.
 

Thread Starter

Fyod

Joined Jun 2, 2019
39
Definitely. I would like up to 18ish volts and the resulting voltage needs to be under 3.3V (the example is for 5V IOs).
 

ronsimpson

Joined Oct 7, 2019
4,647
Any thoughts are welcome.
Everyone puts input protections diodes like you show in post #1. Inside the IC there are diodes. Look at the data sheet they have a low current rating. (1 to 10mA depending on the part) I think the internal diodes will conduct before the external diodes. I don't care if you use the diodes, just keep the current below the input max current rating of the IC. Or use a Schottky diode which should turn on at a low voltage.
 

Ian0

Joined Aug 7, 2020
13,097
Everyone puts input protections diodes like you show in post #1. Inside the IC there are diodes. Look at the data sheet they have a low current rating. (1 to 10mA depending on the part) I think the internal diodes will conduct before the external diodes. I don't care if you use the diodes, just keep the current below the input max current rating of the IC. Or use a Schottky diode which should turn on at a low voltage.
The TS has 1A Schottkies, which will almost certainly conduct before the ordinary 10mA pn junction diodes on the chip.
Not all processors have A full set of clamp diodes.
one thing to watch out for (but not a problem in this case) is using low values for the divider. If so, enough current may flow through the protection diodes when overloaded into the 3.3V supply to increase the supply voltage.
 

Thread Starter

Fyod

Joined Jun 2, 2019
39
I'd probably be using some ESP32 variant, which have "snapback" ESD devices on the pins.

I suspect it would be best to use an external ADC with external VREF for the sensors where VREF+ is a permanent 12V line divided down to ~2.5V.
 

MisterBill2

Joined Jan 23, 2018
27,186
Clamp diodes with adequate current limiting resistors have been used success fully for decades. A small refinement has been to add a shunt capacitor across the lower diode to reduce the power of the "really fast" spikes that sometimes appear. And the cheap insurance has been to feed the clamped signal first to a cheap buffer gate so that any damage by an overpowering spike does not destroy that expensive processor IC.
 
Top