Pullup input with a resistor voltage ladder

Thread Starter

EV_fun

Joined Feb 9, 2020
5
1581268260538.png

Hi, thank you in advance for the help.

I am having a using a GPIO IO input pin with a pullup sampling through a voltage ladder that steps down 12-18v signals down to 3.3v. I need to sample with the option that the internal pullups are enabled for pulldown switches. I have attached the schematic.
A little bit of background. I am using a ESP32 with a MCP23017 i2c IO expander that runs of 3.3v as well. The MCP23017 will be receiving 12v signals from a motorcycle switches but due to the noisey power supply that motorcycles run off, the power can peak up to around 18v. I have a 18v zener diode, a voltage ladder and a 3.6v zener diode after that to protect the GPIO from any sudden power spikes or ESD. My problem is that my inputs in the future may not be 12v but instead short to ground.
Normally I would use the MCP23017 internal pullups and then have the inputs short to ground but the voltage ladder resistor is preventing the pullup as the resistor is much lower in the voltage ladder. I looked at adding additional pullup resistor at 25kohms but that would only give around a 1.0v signal to the IO when the button isn't pressed and a voltage of 0.78 when it is.
The MCP23017 requires a high signal of 0.8v above VDD but just having 0.2v headup between a HIGH and LOW input seems risky.
Is there a better solution than what I have to ideal protect the IO expander IOs from overvoltage while also allowing me to use a high signal or pulldown signal on the IO.
Thanks a lot for your help.
 

crutschow

Joined Mar 14, 2008
34,430
Offhand I don't see any easy way to do this, since some signals are active high and some may be active low.

One option is to add 12V pull-up resistors on the ladder input when you have active low (ground) signals
Those resistors could be switched in with DIP switches (example below) on the circuit board.

1581275832066.png
 

MisterBill2

Joined Jan 23, 2018
18,502
Is this application very critical about the timing, can you accept response delays of perhaps 10 to 20 milliseconds? A series resistor to limit current, along with clamping resistors and a shunt capacitor should provide adequate protection. So there is one way to protect your GPIO inputs and still be able to use them for active high or active low inputs while using fewer parts. A 10K input series resistor, 2 diodes in series clamping the input to values between Common and Vcc clamping the input between common and Vcc. Use lossy disc capacitors across the bottom diode to show spikes until the diodes can fully conduct.
 

dendad

Joined Feb 20, 2016
4,476
Don't use pullups at all. Run the buttons commoned to 3.3V, not 0V. So the inputs go high on button press.
Or, if the buttons are hard wired, use them to drive an opto isolator that switches the inputs to 3.3V.
 

Thread Starter

EV_fun

Joined Feb 9, 2020
5
Thanks guys for the help. Unfortunenetly, some of the inputs are active high and some are active low so I don't have much of a choice. Timing isn't critical, is this what you had in mind MisterBill2?

1581311114099.png
 

dendad

Joined Feb 20, 2016
4,476
Unfortunenetly, some of the inputs are active high and some are active low so I don't have much of a choice.
Do you mean the actual inputs of the processor board, or the way the switched/sensors are wired?
An opto can be used to convert the active low switches to active high inputs.

Inputs.jpg
 

MisterBill2

Joined Jan 23, 2018
18,502
Thanks guys for the help. Unfortunenetly, some of the inputs are active high and some are active low so I don't have much of a choice. Timing isn't critical, is this what you had in mind MisterBill2?

View attachment 198729
That is fairly close. It would need one more diode, pointing up, from the junction of the diode shown, with the cathode connected to the positive supply. And both of the diodes can be regular diodes, not special ones, The diodes make a clamp circuit preventing the voltage output from exceeding the supply voltage range. At that point it is exactly what I have used for many years. It has the advantage of not affecting signals by pulling them up or down.
 

Thread Starter

EV_fun

Joined Feb 9, 2020
5
Thanks guys. I really appreciate the help. I think for this design I'll go with MisterBill2's design. Thanks so much for the help and input.
 

Thread Starter

EV_fun

Joined Feb 9, 2020
5
That is fairly close. It would need one more diode, pointing up, from the junction of the diode shown, with the cathode connected to the positive supply. And both of the diodes can be regular diodes, not special ones, The diodes make a clamp circuit preventing the voltage output from exceeding the supply voltage range. At that point it is exactly what I have used for many years. It has the advantage of not affecting signals by pulling them up or down.
One quick question. What is the voltage limit of the diodes the limit for using this as a active active input? Also, if I added a small resistor after that capacitor I should be able to use the GPIO as a 3.3v output to, right? Thanks a lot for your help
 

MisterBill2

Joined Jan 23, 2018
18,502
One quick question. What is the voltage limit of the diodes the limit for using this as a active active input? Also, if I added a small resistor after that capacitor I should be able to use the GPIO as a 3.3v output to, right? Thanks a lot for your help
I used 100 volt diodes because we had several thousand of them. The circuit limits the voltage to between ground -0.7 volts and +Vcc +0.7 volts. If you use shottkey diodes , change the 0.7 to o.25 volts. With the current limiting resistor no harm gets done. And this scheme does not care if the input is pulled up or pulled down. That is what makes it handy.
 

dendad

Joined Feb 20, 2016
4,476
Can you show the input devices? Are they just switches to +V and 0V?
Without some external circuitry, I cannot see how you can use the one input for PNP and NPN inputs.
 
Top