Pullup or not? - Page 1
Forum section: electronics / projects

author: phil from seattle
author_rank: Super Contributor
timestamp: June 06, 2020, 03:20:08 am
content: So, I have a design which uses a Schmitt trigger on digital input to a microcontroller. It uses a low pass filter. The input can be a simple switch or some sort of optoisolator (I'm designing it for general use so I have to handle all sorts of cases). Typically it will be an encoder of some sort. I use a pullup resistor for the cases where a simple switch to ground is used. See the diagram below. This works fine. But, I tested it without the pullup (R1) with pullups enabled in the uC and it worked correctly, even with the simple switch to ground - i.e no input signal. Looking at the output of the Schmitt trigger when it's not connected to the uC showed the expected random state fluctuations.It makes sense that it is deterministic when there is a pullup after the Schmitt trigger but am I setting myself up for trouble by doing that?The uC pullups are in the 50K ohm range.This isn't so much about saving money but saving space as I'm pressed for room for the resistors in the current design.

author: ataradov
author_rank: Super Contributor
timestamp: June 06, 2020, 03:56:35 am
content: You would still have a high-impedance input floating. It generally not a good idea, it will potentially be more sensitive to noise in noisy environments.I would also move R2 before the diodes. This way it will also act as a current limiter for the diodes if they happen to open.

author: Miti
author_rank: Super Contributor
timestamp: June 06, 2020, 09:54:35 am
content: What uC? It may already have ST inputs. If not, yes, you need a pull up/ down.

author: graybeard
author_rank: Frequent Contributor
timestamp: June 06, 2020, 12:29:50 pm
content: For a CMOS input a pull-up (or pull-down) is only needed if the input floats. A floating input is one that is not driven. This can be either open or tri-stated. The pull-up or pull-down drives an open input into a known state.Your low pass filter will prevent oscillation and most, but not all noise. The leakage currents in your protection diodes and the ones on the chip input will decide if input goes high or low if you omit the resistor. If the input floats and you do'nt care what state it is in, you can omit the pull-up. If your design cannot tolerate noise on the input, use the resistor.As ataradov stated, it would be better to move your clamping diodes inside R2.

author: wraper
author_rank: Unknown
timestamp: June 06, 2020, 01:18:24 pm
content: Circuit looks like a waste of money and parts. If you use switch, for best result you should debounce it in firmware anyway. Also if you use a switch or optocoupler, there should be lower resistance pull-up to ensure reliability, and directly connected to the switch/optocoupler, not through another resistor in series. Also many MCUs already have inputs with Shmitt trigger and internal pull-up.

author: SiliconWizard
author_rank: Super Contributor
timestamp: June 06, 2020, 02:36:19 pm
content: As said - check with your MCU in particular, but nowadays, most of them have Schmitt trigger inputs anyway, so the additional gate is useless.As for debouncing, I'm not against what you did here, depends on the kind of input you use really. Since it seems to be designed for "digital inputs" as well, I'm not sure the RC filter would really be a benefit in this case. As for the clamping diodes, why not, but I would then add a series resistor *before* the diodes. Depending on your input signal, you may even want to add a TVS diode.Point is - the extra gate is likely useless here, and more generally speaking, designing some kind of "universal" input like you seem to be doing here is IMHO not a very good idea. It's IMO a better approach to adapt it to the kind of input you'll really have to deal with. If you're using a mechanical switch, the extra clamping diodes are probably useless. OTOH, if the input can be connected to some kind of external signal through a connector, then better protection than what you did here would probably have to be considered.As for pullups - leaving CMOS inputs floating is never a good idea. If nothing else, it will tend to draw unncessary current.But if you get rid of the extra gate and enable internal pullups of the MCU, then the point is moot. No extra pullup needed, although depending again on your specific case, you may want to add an external, smaller value pullup (like 10k or lower) to avoid potential spurious state change due to external perturbation.

author: donmr
author_rank: Regular Contributor
timestamp: June 06, 2020, 03:02:05 pm
content: Enabling a pullup inside the uC is the same thing as putting R1 outside. Pullups are so common and useful that many devices include them for you.

author: phil from seattle
author_rank: Super Contributor
timestamp: June 06, 2020, 03:50:22 pm
content: Thanks for the constructive comments. Thought I had mentioned it but the ST is there because I need 5V tolerant input, the package happens to be nice and small and some inputs will benefit from the ST. So, not a waste of parts and I can't use the uC's features.The micro is actually one of several possible micros, all of which have STs on their input but again, that's irrelevant to the point.Moving the diode inside is a good idea though I don't expect particularly high energy here, more like EMI. That should not effect the LP filter operation.But to the original point, I will bite the bullet and add the pullups.

author: SiliconWizard
author_rank: Super Contributor
timestamp: June 06, 2020, 04:26:37 pm
content: Quote from: phil from seattle on June 06, 2020, 03:50:22 pmOK, that wasn't mentioned. Makes sense then. BUT: there is definitely a problem with your design then, as it's itself NOT 5V tolerant; notably due to the upper clamping diode which clamps to 3.3V. If your input goes up to 5V, it won't be pretty.

author: Miti
author_rank: Super Contributor
timestamp: June 07, 2020, 12:45:07 pm
content: Quote from: phil from seattle on June 06, 2020, 03:50:22 pmNo, it’s not irrelevant. With a few kohm resistor series and a clamp diode at 3.3V, your uC input is already 5V tolerant. And ST.