Did I do this pull-up capacitor right? - Page 1
Forum section: electronics / beginners

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 02:35:11 am
content: 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.

author: riyadh144
author_rank: Unknown
timestamp: January 13, 2018, 05:55:28 am
content: 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.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 06:05:03 am
content: A two cent capacitor vs $500 an hour for lab time

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 06:11:00 am
content: Quote from: riyadh144 on January 13, 2018, 05:55:28 amLike this?

author: MarkF
author_rank: Super Contributor
timestamp: January 13, 2018, 09:03:27 am
content: 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.

author: ogden
author_rank: Super Contributor
timestamp: January 13, 2018, 09:38:04 am
content: OMGEasy: resistor to VCC, capacitor to GND. Like this:http://coder-tronics.com/switch-debouncing-tutorial-pt1/

author: IanMacdonald
author_rank: Frequent Contributor
timestamp: January 13, 2018, 10:09:31 am
content: 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.

author: Twoflower
author_rank: Frequent Contributor
timestamp: January 13, 2018, 10:20:24 am
content: 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.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 06:00:00 pm
content: Quote from: ogden on January 13, 2018, 09:38:04 amApologies, I mistook this for the beginner's forum. In a beginner's forum some dumb or obvious questions may get asked.Quote from: ogden on January 13, 2018, 09:38:04 amNot looking to debounce. Unless those instructions also filter emissions coming from the board to the wires.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 06:05:20 pm
content: Quote from: blueskull on January 13, 2018, 08:23:47 amTrying 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 readingherethat 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.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 06:10:54 pm
content: Quote from: MarkF on January 13, 2018, 09:03:27 amSo 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?

author: rstofer
author_rank: Super Contributor
timestamp: January 13, 2018, 06:39:24 pm
content: 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.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 07:51:42 pm
content: Quote from: rstofer on January 13, 2018, 06:39:24 pmNo, 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.Quote from: rstofer on January 13, 2018, 06:39:24 pmYes,it is about 50k.So will the attached schematic help reduce EMI coming from the board? Similar to MarkF's design.

author: janoc
author_rank: Super Contributor
timestamp: January 13, 2018, 08:05:28 pm
content: 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.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 13, 2018, 08:26:42 pm
content: Quote from: janoc on January 13, 2018, 08:05:28 pmEven 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.

author: MarkF
author_rank: Super Contributor
timestamp: January 13, 2018, 11:09:19 pm
content: Quote from: rstofer on January 13, 2018, 06:39:24 pmAre we really going to start worrying about shorting a 10nF capacitor? Even a 100nF capacitor for that matter.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.

author: cdev
author_rank: Super Contributor
timestamp: January 13, 2018, 11:23:06 pm
content: 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.Quote from: SlowBro on January 13, 2018, 06:05:20 pmYou likely already have some lying around as they commonly come with electronic equipment.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 14, 2018, 12:58:18 am
content: How about this? For the long reed switch wires I added L_Core_Ferrite, which isthis component. Its impedance is 998 ohm at 100 MHz.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 14, 2018, 01:17:35 am
content: 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.

author: wraper
author_rank: Unknown
timestamp: January 14, 2018, 01:28:01 am
content: 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.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 14, 2018, 01:43:23 am
content: By the way I found that 100kHz is fast enough for my needs so I stepped down the speed.Quote from: wraper on January 14, 2018, 01:28:01 amIt's not. The connector for the switch is on the right, the label on the left goes to the RPi.Quote from: wraper on January 14, 2018, 01:28:01 amCould you explain why? Newbie here.Quote from: wraper on January 14, 2018, 01:28:01 amAgain, please explain why.Quote from: wraper on January 14, 2018, 01:28:01 amIt does not.Quote from: wraper on January 14, 2018, 01:28:01 amAgain, please explain why.Quote from: wraper on January 14, 2018, 01:28:01 amIt is.Quote from: wraper on January 14, 2018, 01:28:01 amEMI is the main emphasis.Quote from: wraper on January 14, 2018, 01:28:01 amCouldn't it come from coupling from elsewhere on the board?Quote from: wraper on January 14, 2018, 01:28:01 amSuch as what? Help please.Thanks!!

author: wraper
author_rank: Unknown
timestamp: January 14, 2018, 01:55:50 am
content: QuoteI 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.QuoteToo 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.Quotethen you shouldn't do it like this. Read this.http://www.ti.com/lit/an/scba004d/scba004d.pdfQuoteBecause sloppy ground is what can potentially became the worst EMI offender.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 14, 2018, 02:11:04 am
content: 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?Quote from: wraper on January 14, 2018, 01:28:01 amI oopsed and asked why then corrected myself to say, could you give more details about that.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 14, 2018, 02:46:16 am
content: Quote from: wraper on January 14, 2018, 01:55:50 amSorry, my head is hurting after reading that... seems like too much. All I want to do is read some reed switches on the end of a 3m wire and ensure little EMI escapes the board.Assuming you are correct about input GPIOs not radiating, wouldn't the attached do the job? Don't think I need any hardware debounce, and the fast reaction time means it won't stay floating for long.(Edited because I forgot the input protection resistor.)

author: wraper
author_rank: Unknown
timestamp: January 14, 2018, 03:00:27 am
content: With such long wires, you should really add some ESD protection for reliability. I've seen a lot of RPi with blown GPIO. I'm not going to draw any circuits now because I'm going to sleep, 5AM here LOL.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 14, 2018, 03:16:42 am
content: Quote from: wraper on January 14, 2018, 03:00:27 amDang get some sleep.For when you come back, or for anyone else: Would the 1k input protection resistor not be enough?

author: not1xor1
author_rank: Frequent Contributor
timestamp: January 14, 2018, 07:05:35 am
content: Quote from: SlowBro on January 14, 2018, 02:46:16 amBTW I still do not understand how a polarized (was that electrolytic?) capacitor would help reduce EMI better than a lower value ceramic capacitor

author: lem_ix
author_rank: Regular Contributor
timestamp: January 14, 2018, 09:11:37 am
content: Quote from: SlowBro on January 14, 2018, 03:16:42 amThe resistor would probably arc over so you should add some more protection. Options being TVS and schottky or both with some resistance sprinkled around, maybe even some capacitance. Ferrite beads may be used too. Depends how paranoid you're feeling

author: SlowBro
author_rank: Regular Contributor
timestamp: January 15, 2018, 04:17:49 am
content: Quote from: not1xor1 on January 14, 2018, 07:05:35 amWe newbies make dumb mistakes. That's why I'm asking here and making changes in KiCAD before I commit to PCB

author: SlowBro
author_rank: Regular Contributor
timestamp: January 15, 2018, 04:20:07 am
content: Quote from: lem_ix on January 14, 2018, 09:11:37 amFeeling rather paranoid. I'd love to see an example circuit, complete with values, if you can find one.I did find this, but it wants me to use a zener, which I understand is not terribly fast:https://www.digikey.com/en/articles/techzone/2012/apr/protecting-inputs-in-digital-electronics

author: Zero999
author_rank: Super Contributor
timestamp: January 15, 2018, 10:53:52 am
content: That's pretty bulletproof, possibly overkill.It think there's more of a risk of external noise messing it up, rather than the circuit radiating.I'd just use the BAT54S, with a couple of resistors and a capacitor.

author: SlowBro
author_rank: Regular Contributor
timestamp: January 15, 2018, 01:00:26 pm
content: Quote from: Hero999 on January 15, 2018, 10:53:52 amI'm starting out with through-hole, sothislooks like the equivalent diode. Need two of them of course. Here's theBAT54S datasheetfor comparison.So everyone agrees.. no on the ferrite beads then?

author: lem_ix
author_rank: Regular Contributor
timestamp: January 15, 2018, 08:03:58 pm
content: Hero999's circuit already has a low pass filter witch will provide some differential mode filtering. If you're worried you can always place 0 ohm resistors and replace with beads if you need. Noise is an ambiguous term ,common mode, differential, who knows