Author Topic: Pullup or not?  (Read 1231 times)

0 Members and 1 Guest are viewing this topic.

Offline phil from seattleTopic starter

  • Super Contributor
  • ***
  • Posts: 1063
  • Country: us
Pullup or not?
« on: June 06, 2020, 03:20:08 am »
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.

 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11905
  • Country: us
    • Personal site
Re: Pullup or not?
« Reply #1 on: June 06, 2020, 03:56:35 am »
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.
Alex
 

Offline Miti

  • Super Contributor
  • ***
  • Posts: 1405
  • Country: ca
Re: Pullup or not?
« Reply #2 on: June 06, 2020, 09:54:35 am »
What uC? It may already have ST inputs. If not, yes, you need a pull up/ down.
« Last Edit: June 06, 2020, 09:56:16 am by Miti »
Fear does not stop death, it stops life.
 

Offline graybeard

  • Frequent Contributor
  • **
  • Posts: 443
  • Country: us
  • Consulting III-V RF/mixed signal/device engineer
    • Chris Grossman
Re: Pullup or not?
« Reply #3 on: June 06, 2020, 12:29:50 pm »
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.
« Last Edit: June 06, 2020, 12:51:38 pm by graybeard »
 

Offline wraper

  • Supporter
  • ****
  • Posts: 17952
  • Country: lv
Re: Pullup or not?
« Reply #4 on: June 06, 2020, 01:18:24 pm »
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.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15800
  • Country: fr
Re: Pullup or not?
« Reply #5 on: June 06, 2020, 02:36:19 pm »
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.
« Last Edit: June 06, 2020, 02:39:16 pm by SiliconWizard »
 

Offline donmr

  • Regular Contributor
  • *
  • Posts: 155
  • Country: us
  • W7DMR
Re: Pullup or not?
« Reply #6 on: June 06, 2020, 03:02:05 pm »
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.
 

Offline phil from seattleTopic starter

  • Super Contributor
  • ***
  • Posts: 1063
  • Country: us
Re: Pullup or not?
« Reply #7 on: June 06, 2020, 03:50:22 pm »
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.

« Last Edit: June 06, 2020, 03:53:36 pm by phil from seattle »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15800
  • Country: fr
Re: Pullup or not?
« Reply #8 on: June 06, 2020, 04:26:37 pm »
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.

OK, 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.
 

Offline Miti

  • Super Contributor
  • ***
  • Posts: 1405
  • Country: ca
Re: Pullup or not?
« Reply #9 on: June 07, 2020, 12:45:07 pm »
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.

No, 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.
Fear does not stop death, it stops life.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf