Logic level converter, 0-12v to 0-3.3v. - Page 1
Forum section: electronics / general

author: luiHS
author_rank: Frequent Contributor
timestamp: October 21, 2024, 09:25:34 pm
content: I need to read two-state signals of 0 and 12v with the ports of a RT1064 microcontroller, to convert them to 0 - 3.3v signals compatible with the GPIO of the microcontroller.I thought of something as simple as a diode and a pullup resistor, but I have my doubts. Now I think that I will not really get the low logic level of 0v in the GPIO, but the voltage drop of the 0.7v diode. And I think that the microcontroller will not interpret it as a low logic level or that value may be right on the border of what is the low logic level and the reading of those signals may be unstable with erroneous readings.I saw other schemes using BJT and MOSFET transistors, or for 5v signals using logic gates like the 74HCT245.

author: langwadt
author_rank: Super Contributor
timestamp: October 21, 2024, 09:37:07 pm
content: two resistors, divide 12V down to 3.3V

author: Zero999
author_rank: Super Contributor
timestamp: October 21, 2024, 09:42:42 pm
content: It will also default to 12V, if the input floats, i.e. is left unconnected.Why not use a potential divider?R1 = 33kR2 = 10kHow fast does it need to be? If more speed is required then put a 100pF capacitor across R1 and a 33pF capacitor across R2, forming a capacitive divider with the same attenuation factor as the resistors.

author: bson
author_rank: Unknown
timestamp: October 21, 2024, 10:01:01 pm
content: What's the threshold on the 0-12V signal?

author: luiHS
author_rank: Frequent Contributor
timestamp: October 21, 2024, 10:16:47 pm
content: Quote from: bson on October 21, 2024, 10:01:01 pmThe 0-12v input is via switches, the line is at 12v via a pullup resistor and each switch connects to GND when closed.According to the datasheet, the logic levels of the RT1064 GPIO are from 0 to 0.3v for the low logic level and from 0.7 to VCC for the high. What I don't understand is what happens between 0.3 and 0.7v

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 22, 2024, 02:08:39 am
content: Quote from: luiHS on October 21, 2024, 10:16:47 pmUsually that is margin and hysteresis. Measure a few devices and check.Then take your desired 12V sense level (eg 6V ?) and divide that down to the GPIO. 6V -> 500mV divider will sit with 1V with 12V in.Or, you could use a Digital Transistor with resistor ratio chosen to give a higher threshold, eg a PDTC144V (47K : 10k) specs typical 3.1V off and 3.8V onor you could choose a Digital transistor + a 50uA zener if you want a more precise, even higher threshold.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 22, 2024, 02:19:03 am
content: The simpler would be a resistive divider as suggested above. It's safe. Benefit is that it gives you a pull-down for free when the "12V" signal is floating.Now since you mentioned how you get this 12V signal, we know that speed is not an issue. But, a resistive divider as is would be, as the signal comes from a pull-up to 12V (is the pull-up value known and purely resistive?)If it's a known resistor value, then all you'd need is a pull-down resistor, which will act as a resistive divider combined with the pull-up resistor. Done. You could add a diode to Vdd (3.3V) to clamp it, just in case something goes wrong.