Author Topic: Noise protection for simple inputs/outputs?  (Read 477 times)

0 Members and 1 Guest are viewing this topic.

Offline sparkydogTopic starter

  • Regular Contributor
  • *
  • Posts: 234
  • Country: us
Noise protection for simple inputs/outputs?
« on: March 23, 2023, 06:06:14 pm »
I've read enough about filtering on I/O lines to know... that I don't know anything. :)

Let's say I have a simple MCU project consisting of an I2C 7-segment display (e.g. this), some buttons (i.e. NO momentary switches), and some "kit" MCU (e.g. an Arduino Nano clone). For simplicity's sake, let's also say I'm plopping the MCU board onto a breadboard and connecting the other bits with 6"-12" wires.

My initial design just has each of several input pins wired directly to a button, in turn wired directly to "ground". I'm handling debounce in software (basically, near-continuous polling, and only register a press when the pin has continuously polled closed-circuit for some number of milliseconds).

Some obvious possible applications include alarm clock or stopwatch. In many cases, spurious detection of button presses is... ungood. (For example, my hypothetical stopwatch won't function very well if the MCU erroneously thinks the 'stop' button was pressed.)

What else, if anything, do I need to ensure that a) I don't pick up spurious button presses, and b) the I2C bus works? (Filter caps? ESD protection? Shielding around the wires? The eventual project is part of an automation system that's going to have other stuff, particularly a bunch of large 12V EMRs as well as other PCBs, in the same enclosure. Also, the I2C and button wires are going to be close together, maybe even bundled.)
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: lt
Re: Noise protection for simple inputs/outputs?
« Reply #1 on: March 23, 2023, 11:08:44 pm »
For relatively small length and slow speeds - don't overthink it.

To keep it robust, both button inputs and I2C simply should have low enough value pull-ups. I2C could be 2.2K, for buttons you may choose even lower, like 470R if you want. Benefit: it makes it robust against EMI and also provides solid "wetting" current for buttons, which for some buttons is a good idea. I don't see much use for filters here, should be perfectly fine without it. If you expect lightning strikes nearby, you may add extra ESD protection, but honestly I think it will be ok without it.

If you want to detect button presses without a lag, debounce just the release phase.
 

Offline sparkydogTopic starter

  • Regular Contributor
  • *
  • Posts: 234
  • Country: us
Re: Noise protection for simple inputs/outputs?
« Reply #2 on: March 24, 2023, 03:48:24 pm »
Thanks, Manul.

You're still beyond my level of knowledge :). Where do I put these resistors? (In series with the MCU pins?) Although... do I really need them? If I understand correctly, the MCU has internal resistors, and indeed it seems to be standard practice at least in prototyping to just connect the carrier board pins directly to "other stuff".

What's really unclear though is whether 6"-12" still qualifies as "small length". Some of the stuff I've read makes it sound like 6cm is likely to pick up enough noise to be a problem.
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: lt
Re: Noise protection for simple inputs/outputs?
« Reply #3 on: March 24, 2023, 05:31:02 pm »
Where do I put these resistors? (In series with the MCU pins?) Although... do I really need them? If I understand correctly, the MCU has internal resistors, and indeed it seems to be standard practice at least in prototyping to just connect the carrier board pins directly to "other stuff".

I've mentioned pull-up resistors, so the name says it all. They pull a digital signal up. Which means they are connected between digital input and supply possitive. MCU often has internal pull-up and pull-down resistors which can be activated by software. They are enough for some purposes, but there are two things to keep in mind: they are quite high value, for example 50K (so they are weak pull-ups) and they are generally inaccurate in that value. If you need more specific value, you add external resistors. I've explained some of reasons, why I would choose external lower value pull-ups.

Keep in mind that I2C needs pull-ups lower then internal MCU pull-ups anyway. It depends on total bus capacitance and required speed. For small length, low capacitance bus you might get away with 10K, but generally you should use less.

Also keep in mind that your I2C display might have them integrated (not uncommon). You should check the resistance between supply positive and SCL, SDA lines. You may already have some resistors present, but you still may wish to add extra pull-ups yourself (to get lower value). In that case total pull-up value will be equivalent to these two resistors being in parallel.

What's really unclear though is whether 6"-12" still qualifies as "small length". Some of the stuff I've read makes it sound like 6cm is likely to pick up enough noise to be a problem.

This part is really taking us into deep woods, I suggest you to not overload your head with that. Of course, definition of "small length" changes depending on what kind of signals are carried. Mostly depends on signal frequency content and signal levels (amplitude), but also lots of other factors. Buttom line is: for buttons and I2C it is a small length*.

* If everything else done properly
« Last Edit: March 24, 2023, 05:48:46 pm by Manul »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf