Author Topic: Did I do this pull-up capacitor right?  (Read 1732 times)

0 Members and 1 Guest are viewing this topic.

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Did I do this pull-up capacitor right?
« on: January 13, 2018, 01:35:11 pm »
I've got an external push button installed on an enclosure, as well as two reed switches, that are all connected to an RPi. The button has about 10cm of about 24 gauge stranded wire and the reed switches are on about 3m of 22 gauge solid core unshielded twisted pair. When this button or these reeds are activated they pull low a GPIO pin to send a signal to the RPi.

I am being paranoid about my design producing extraneous emissions (and pass the FCC unintentional radiator lab measurements) so I wanted to put on a low-pass filter on these to prevent stray noise leaking from the RPi to the outside world. The board has some 100 kHz I2C devices and I could see there being a potential for at least the reed switches turning into antennas. [Edit: This did say 400 kHz but I found that 100 kHz is sufficient.]

So I designed all three connection ports like the attached picture. The values of the capacitor and resistor should filter out any noise above about 100Hz, as well as conveniently debounce the connection a bit. (Though the software has sufficient debounce.)

Is this correct? I ask because I've never heard of a pull-up capacitor and I didn't find what I was looking for with Google. But it seems right to me.
« Last Edit: January 14, 2018, 02:10:17 pm by SlowBro »
 

Offline riyadh144

  • Supporter
  • ****
  • Posts: 61
Re: Did I do this pull-up capacitor right?
« Reply #1 on: January 13, 2018, 04:55:28 pm »
I really don't think think you can pull a signal up using a capacitor since that 3.3V is seeing an open circuit, as capacitors block DC current, so that point is a virtual ground and you are better of putting that capacitor in parallel with your resistor to filter any noise.

But I don't believe you would have any noise in the first place and you are just over paranoid.
 
The following users thanked this post: SlowBro

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #2 on: January 13, 2018, 05:05:03 pm »
A two cent capacitor vs $500 an hour for lab time ^-^
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #3 on: January 13, 2018, 05:11:00 pm »
you are better of putting that capacitor in parallel with your resistor to filter any noise.

Like this?
 

Online blueskull

  • Supporter
  • ****
  • Posts: 10080
  • Country: cn
  • Power Electronics Guy
Re: Did I do this pull-up capacitor right?
« Reply #4 on: January 13, 2018, 07:23:47 pm »
Do you need the line value to be logic 1 on the exact moment of power up? If not, you can connect the capacitor across signal line and ground. Ground is usually much cleaner than VCC in terms of EMI noise. By decoupling signal line to VCC, you can well bring VCC noise to external.
If you do need the line to be high upon powering up, you can consider a reset delay circuit to allow the ground coupled capacitor to charge before the RPi exits reset and samples the data line.
SIGSEGV is inevitable if you try to talk more than you know. If I say gibberish, keep in mind that my license plate is SIGSEGV.
 
The following users thanked this post: SlowBro

Offline MarkF

  • Frequent Contributor
  • **
  • Posts: 774
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #5 on: January 13, 2018, 08:03:27 pm »
I would do something like this (with or without R1):
  where C1 would prevent button bounce and noise.

You should recognize this as the suggested configuration for rotary encoders. R1 and C1 are the low pass filter and R2 the pull-up for the switch.
 
The following users thanked this post: SlowBro

Offline ogden

  • Super Contributor
  • ***
  • Posts: 1128
  • Country: lv
Re: Did I do this pull-up capacitor right?
« Reply #6 on: January 13, 2018, 08:38:04 pm »
OMG  :palm:

Easy: resistor to VCC, capacitor to GND. Like this:

http://coder-tronics.com/switch-debouncing-tutorial-pt1/
 

Offline IanMacdonald

  • Frequent Contributor
  • **
  • Posts: 774
  • Country: gb
    • IWR Consultancy
Re: Did I do this pull-up capacitor right?
« Reply #7 on: January 13, 2018, 09:09:31 pm »
The last thing you want is a lo-Z capacitor shorted by the switch. OP's circuit is better.

Look up how Marconi did his radio experiments.  :o
 

Online blueskull

  • Supporter
  • ****
  • Posts: 10080
  • Country: cn
  • Power Electronics Guy
Re: Did I do this pull-up capacitor right?
« Reply #8 on: January 13, 2018, 09:14:51 pm »
The last thing you want is a lo-Z capacitor shorted by the switch. OP's circuit is better.

Look up how Marconi did his radio experiments.  :o

EMI testing usually involves some sort of EMI test mode in firmware that puts device into normal operation without human intervention, and usually human is not physically operating the device during the test.
Human operator sets the device up for testing, and then leaves and conducts the test in a separate room.
That is to say, even if the button is an EMP bomb that can knock off electronics devices in the entire block, it can still pass EMI test.
SIGSEGV is inevitable if you try to talk more than you know. If I say gibberish, keep in mind that my license plate is SIGSEGV.
 

Offline Twoflower

  • Frequent Contributor
  • **
  • Posts: 385
  • Country: de
Re: Did I do this pull-up capacitor right?
« Reply #9 on: January 13, 2018, 09:20:24 pm »
The problem having a cap parallel to a switch is that the current while switching might be rather high and can cause excessive wear or even fuse the contacts together. At least a current limiting resistor would be useful.
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #10 on: January 14, 2018, 05:00:00 am »
OMG  :palm:

Apologies, I mistook this for the beginner's forum. In a beginner's forum some dumb or obvious questions may get asked.

Easy: resistor to VCC, capacitor to GND. Like this:

http://coder-tronics.com/switch-debouncing-tutorial-pt1/

Not looking to debounce. Unless those instructions also filter emissions coming from the board to the wires.
« Last Edit: January 14, 2018, 05:05:58 am by SlowBro »
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #11 on: January 14, 2018, 05:05:20 am »
Do you need the line value to be logic 1 on the exact moment of power up? If not, you can connect the capacitor across signal line and ground. Ground is usually much cleaner than VCC in terms of EMI noise. By decoupling signal line to VCC, you can well bring VCC noise to external.
If you do need the line to be high upon powering up, you can consider a reset delay circuit to allow the ground coupled capacitor to charge before the RPi exits reset and samples the data line.

Trying to wrap my head around what you're saying. No I don't need it to be logic 1 on power-up, just need to ensure no excess noise from the board leaks onto the line and out into space. If the cap connects signal to ground won't that register as low, and signal to the RPi that the switch is turned on?

I was reading here that the way this is typically handled is with either common-mode filters or ferrite chokes. I could put some chokes on but I don't know what value I need. Suggestions welcome.
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #12 on: January 14, 2018, 05:10:54 am »
I would do something like this (with or without R1):
  where C1 would prevent button bounce and noise.

You should recognize this as the suggested configuration for rotary encoders. R1 and C1 are the low pass filter and R2 the pull-up for the switch.

So that configuration reduces emissions coming from the board out to the wires? Debounce is not a goal here; software looks for the switch to be active for at least 1 second.

Also, the RPi has pull-ups, so would the pull-up there be required?
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 4807
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #13 on: January 14, 2018, 05:39:24 am »
Do you have any reason to believe that there are emissions on the wire?  Do you have a way to measure the effect? 

If the wire is long, I would worry more about external influences coming in through the wire.

When you short a capacitor with a switch, you run into the capacitor equation:

i = C dv/dt  -- the current (i) is related to the size of the capacitor (C - in farads) and the rate of change of the capacitor voltage (volts per second).

But dv/dt can be quite high when you throw a crowbar (essentially 0 Ohms) across a capacitor.  In theory (only), dv/dt approaches infinity.  Therefore, the current i approaches infinity.  The only thing limiting the current is the internal resistance of the capacitor, the resistance of the switch contacts and the resistance of the wire.  These are surprisingly small.

I guess I would put the capacitor between the pin and ground with a series resistor of around 100 Ohms to the switch.  I wouldn't necessarily use the internal pull-up because it won't flow enough current to make a reliable connection through a switch (burning through oxidation, for example).  The capacitor actually helps in this case because it provides a brief spike of higher current that the pull-up resistor can't provide.

I would probably think in terms of a 1k to 10k pull-up resistor at the pin.  Check the datasheet for the nominal internal pull-up resistance.  It is often on the order of 100k or more.  High enough to pull up the internal logic but not high enough to provide switch current.
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #14 on: January 14, 2018, 06:51:42 am »
Do you have any reason to believe that there are emissions on the wire?  Do you have a way to measure the effect?

No, just trying to be careful. There is a 400kHz I2C clock on the same board that a couple 3m wires are on. Don't want excess emissions.


If the wire is long, I would worry more about external influences coming in through the wire.

(..)

Check the datasheet for the nominal internal pull-up resistance.  It is often on the order of 100k or more.

Yes, it is about 50k.

So will the attached schematic help reduce EMI coming from the board? Similar to MarkF's design.
« Last Edit: January 14, 2018, 07:04:01 am by SlowBro »
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 2470
  • Country: fr
Re: Did I do this pull-up capacitor right?
« Reply #15 on: January 14, 2018, 07:05:28 am »
I hope you do realize that sticking a cap to a non-schmitt trigger equipped input is a good recipe for having the input start to oscillate due to the very slow transition. May not affect your EMI test but could well break the functionality of the device.
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #16 on: January 14, 2018, 07:26:42 am »
I hope you do realize that sticking a cap to a non-schmitt trigger equipped input is a good recipe for having the input start to oscillate due to the very slow transition. May not affect your EMI test but could well break the functionality of the device.

Even MarkF's design, or the one I just posted in the previous comment?

Oh and the software does the debouncing. It expects at least 1 second for each connection.
« Last Edit: January 14, 2018, 07:44:07 am by SlowBro »
 

Offline MarkF

  • Frequent Contributor
  • **
  • Posts: 774
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #17 on: January 14, 2018, 10:09:19 am »
When you short a capacitor with a switch, you run into the capacitor equation:

i = C dv/dt  -- the current (i) is related to the size of the capacitor (C - in farads) and the rate of change of the capacitor voltage (volts per second).

But dv/dt can be quite high when you throw a crowbar (essentially 0 Ohms) across a capacitor.  In theory (only), dv/dt approaches infinity.  Therefore, the current i approaches infinity.  The only thing limiting the current is the internal resistance of the capacitor, the resistance of the switch contacts and the resistance of the wire.  These are surprisingly small.

Are we really going to start worrying about shorting a 10nF capacitor?  Even a 100nF capacitor for that matter. :scared:

I'm thinking of a 10nF capacitor and 4.7K resistors. 
Since you're doing switch debounce in software, I would only use a pull-up resistor chosen to switch approx. 1mA.
 
The following users thanked this post: SlowBro

Offline cdev

  • Super Contributor
  • ***
  • Posts: 3435
  • Country: 00
  • I love science, stars, nature and electronics.
Re: Did I do this pull-up capacitor right?
« Reply #18 on: January 14, 2018, 10:23:06 am »
Try using a clip on choke, suppose you have a pair of wires, Wrap the wires - together, side by side, around the open choke as many times as will fit, then close it. If you are using a ribbon cable you use a different kind of clip on choke, a flat one. The most common material they are constructed with is #43. You could also use a toroid, again to eliminate common mode signals, all the wires have to go through the choke and follow the same path.
I was reading here that the way this is typically handled is with either common-mode filters or ferrite chokes. I could put some chokes on but I don't know what value I need. Suggestions welcome.

You likely already have some lying around as they commonly come with electronic equipment.
"What the large print giveth, the small print taketh away."
 
The following users thanked this post: SlowBro

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #19 on: January 14, 2018, 11:58:18 am »
How about this? For the long reed switch wires I added L_Core_Ferrite, which is this component. Its impedance is 998 ohm at 100 MHz.
« Last Edit: January 14, 2018, 12:02:38 pm by SlowBro »
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #20 on: January 14, 2018, 12:17:35 pm »
This may be better. Uses the internal 50k ohm pull-ups on the Pi with the 1uF cap for a 0.05 RC time constant for a nice long debounce. Uses the aforementioned ferrite bead for noise choking. (Noise leaving the board.) And the 1k ohm limits the current from the cap.
« Last Edit: January 14, 2018, 12:19:14 pm by SlowBro »
 

Offline wraper

  • Supporter
  • ****
  • Posts: 8248
  • Country: lv
Re: Did I do this pull-up capacitor right?
« Reply #21 on: January 14, 2018, 12:28:01 pm »
First of all, switch should never be connected directly in parallel with capacitor as it may reduce switch life and produce inductive kickback. Therefore capacitor should be on the other side of 1K resistor. Adding ferrite as shown is a borderline with ridiculous. Relying on internal pull-up is not reliable solution. Also I cannot find any info about raspberry pi having Schmitt trigger on it's GPIO, if that is the case, just adding capacitor does more harm then good. Just in case, debauncing can be done in software without any external circuit.
If you just want ir for radiated EMI and not debounce, then sure that EMI won't come from GPIO which is configured as input. I would rather care what is happening with the ground.
« Last Edit: January 14, 2018, 12:37:14 pm by wraper »
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #22 on: January 14, 2018, 12:43:23 pm »
By the way I found that 100kHz is fast enough for my needs so I stepped down the speed.


First of all, switch should never be connected directly in parallel with capacitor

It's not. The connector for the switch is on the right, the label on the left goes to the RPi.


Adding ferrite as shown is a borderline with ridiculous.

Could you explain why? Newbie here.


Relying on internal pull-up is not reliable solution.

Again, please explain why.


Also I cannot find any info about raspberry pi having Schmitt trigger on it's GPIO

It does not.


if that is the case, just adding capacitor does more harm then good.

Again, please explain why.


Just in case, debauncing can be done in software without any external circuit.

It is.


If you just want ir for radiated EMI and not debounce

EMI is the main emphasis.


then sure that EMI won't come from GPIO which is configured as input.

Couldn't it come from coupling from elsewhere on the board?


I would rather care what is happening with the ground.

Such as what? Help please.

Thanks!!  :)
« Last Edit: January 14, 2018, 12:47:38 pm by SlowBro »
 

Offline wraper

  • Supporter
  • ****
  • Posts: 8248
  • Country: lv
Re: Did I do this pull-up capacitor right?
« Reply #23 on: January 14, 2018, 12:55:50 pm »
Quote
Adding ferrite as shown is a borderline with ridiculous.

Could you explain why? Newbie here.
I thought it was connected directly to raspberry pi. You said it's opposite, then it makes more sense. However I don't think there will be any effect from it anyway.
Quote
Relying on internal pull-up is not reliable solution.

Again, please explain why.
Too low current, regardless of noise susceptibility, it's too low to guarantee reliable switch operation. Both for contact wetting current and operating normally if switch becomes a little bit conductive in off position which is not rare for tact switches.
Quote
Also I cannot find any info about raspberry pi having Schmitt trigger on it's GPIO

It does not.
then you shouldn't do it like this.  Read this. http://www.ti.com/lit/an/scba004d/scba004d.pdf

Quote
I would rather care what is happening with the ground.

Again, please explain why.

Thanks!!  :)

Because sloppy ground is what can potentially became the worst EMI offender.
 

Offline SlowBro

  • Regular Contributor
  • *
  • Posts: 126
  • Country: us
Re: Did I do this pull-up capacitor right?
« Reply #24 on: January 14, 2018, 01:11:04 pm »
So you said that GPIO inputs won't radiate and I asked about possible coupling from elsewhere. Is that a concern or am I over-thinking it?


Because sloppy ground is what can potentially became the worst EMI offender.

I oopsed and asked why then corrected myself to say, could you give more details about that.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf