Raspberry Pi 3 Crosstalk Button Issue - Page 1
Forum section: electronics / beginners

author: atech
author_rank: Newbie
timestamp: July 24, 2017, 09:41:54 am
content: Hello everyone! I have a issue that is confusing me beyond words, but I thought perhaps someone here may know what is happening.I am building a system which uses a remote attached to the RPi with a ribbon cable from about 3ft away.The remote has buttons on it which connect the Raspberry Pi's GPIOs to GND. The system works beautifully when I use an Adafruit breakout board, plugging the ribbon cable into that. However, when I tried to connect the ribbon straight to the RPi, pressing 1 button often triggers 2 others. The breakout board has no resistors on any electronics on it, it is just a circuit board with labeled pins.The mystery deepens, because my circuit stops triggering multiple inputs if I hold the back of the board (i.e. Short the switch contacts with my finger). I tested it extensively, and it works every single time. So the question is, is it the resistance or capacitance of my hand that is doing the trick. Thoughts?

author: cowana
author_rank: Frequent Contributor
timestamp: July 24, 2017, 09:56:55 am
content: Does the remote have its own pullup resistors, or are you relying on the ones internal to the Pi?

author: wraper
author_rank: Unknown
timestamp: July 24, 2017, 10:01:50 am
content: Raspberry pi apparently have built it pull-ups. But they must be enabled, I would guess they are not in this case. However they are too weak to attach buttons end expect this to reliably work, yet with a 3ft cable. Therefore pull up resistors should be attached between 3.3V and each input pin. I would suggest around 4.7k resistance.

author: atech
author_rank: Newbie
timestamp: July 24, 2017, 02:48:00 pm
content: Okay. I don't understand what is happening with my hand, but I'll try the Pullup resistors. Should I disable them in the code if I do this?. Also, will each pin need a separate circuit or is there some way to chain all the pullups together?

author: timb
author_rank: Super Contributor
timestamp: July 24, 2017, 02:57:38 pm
content: Quote from: atech on July 24, 2017, 02:48:00 pmYour hand is likely adding a bit of capacitance to the GPIOs and possibly resistance to GND or a voltage rail if you're actively touching any of the pins or traces.

author: wraper
author_rank: Unknown
timestamp: July 24, 2017, 10:22:57 pm
content: Unconnected pins should be left with enabled pull-ups of configured as outputs. If pin is left unconnected and without any pull-up, it may cause voltage on it jumping around and/or being somewhere in between 0 and 1 state. This may cause increased current consumption, in some very rare cases even a failure of the chip because it. If you have external pull up on the pin, leaving internal pull-up enabled won't hurt at all. You can use either separate resistor for each pin or get a resistor network (if you have a lot of pins to be pulled up).

author: atech
author_rank: Newbie
timestamp: July 25, 2017, 12:06:19 am
content: I have attached a screenshot to show what I plan to make for the pullup circuits. I've got 1k protection resistors (it seems like that is usually good form) and 5k1 current resistors. The green wires would go to separate GPIO pins and the red and black connect to 3v3 and gnd respectively. Does this seem sound?

author: timb
author_rank: Super Contributor
timestamp: July 25, 2017, 12:44:37 am
content: Yeah, that looks fine. Took me a minute to trace out the breadboard connections. In the future you might want to post a normal schematic like this:Edit: Keep in mind your circuit doesn't haven't any sort of debouncing, so you're likely to get multiple hits every time you press a button. You'll need to do the debouncing in software. Alternatively you can do it in hardware:(Note: The resistors, diode and capacitor make up the debouncing circuit. The flip-flop and LED are just there to simulate a GPIO input and status register.)

author: atech
author_rank: Newbie
timestamp: July 25, 2017, 01:10:17 am
content: Wow! Thank you for theVERYcomprehensive answer!As for debounceing, lucky for me the RPi has debouncing built in to it's GPIO library. Thank you so much for all of your help!

author: floobydust
author_rank: Super Contributor
timestamp: July 25, 2017, 01:12:39 am
content: Wait a sec, RPi I/O is 3.3V not 5V.So pull-up resistors to 3.3V. I use 10k's

author: timb
author_rank: Super Contributor
timestamp: July 25, 2017, 01:56:22 am
content: Quote from: floobydust on July 25, 2017, 01:12:39 amIn my example the 5V rail could just as well be 3v3, it's not critical.I agree 5.1k is a bit on the low side, however it'll work just fine. If current consumption is an issue (running on battery power for example), then you could up it to 10k or potentially even higher. (The beauty of the debounce circuit I posted earlier is the very low static current, since the pullup is nearly 100k.)Sent from my iPhone using Tapatalk

author: atech
author_rank: Newbie
timestamp: July 25, 2017, 08:32:54 am
content: Okay, I'll switch it to 10K. I was just going to use 1/4 watt resistors for this. That should be fine, right?

author: wraper
author_rank: Unknown
timestamp: July 25, 2017, 09:00:50 am
content: Quote from: floobydust on July 25, 2017, 01:12:39 amActually 10k is not a good advice for long term reliability. There are 2 issues, switch wetting current to break down oxides on the surface of the contacts, and secondly, often tact switches become slightly conductive after a few years if used in humid environment.Quote from: timb on July 25, 2017, 01:56:22 amIt is critical, you show this in the beginner section. Inexperienced people quiet likely will just do exactly as shown without much thinking and connect it to 5V.

author: atech
author_rank: Newbie
timestamp: July 25, 2017, 09:08:30 am
content: Quote from: wraper on July 25, 2017, 09:00:50 amWhat Ohm rating would you suggest?Quote from: timb on July 25, 2017, 01:56:22 amI appreciate the advice, but I don't think that's fair to say. I may be a beginner, but I am not going to blindly follow something. I make an effort to understand it, and in this case I already did. That's how you get out of the beginner thread.

author: wraper
author_rank: Unknown
timestamp: July 25, 2017, 09:20:28 am
content: Quote from: atech on July 25, 2017, 09:08:30 amThat was said in general, not about particularly you. Someone may understand, someone may follow blindly and burn the thing. After all, someone can google this tread, see the thing without much reading and just do it.

author: wraper
author_rank: Unknown
timestamp: July 25, 2017, 09:24:16 am
content: Quote from: atech on July 25, 2017, 09:08:30 amI already said that in earlier post, 4.7k. Probably even less depending on circumstances. Also it depends on voltage, for 5V to keep the same current through the switch larger resistance is needed. Decreasing resistor increases current consumption when button is pressed so in portable devices you likely would want to use higher resistance. In noisy environment, with long wires or humid environment - lower.

author: timb
author_rank: Super Contributor
timestamp: July 25, 2017, 11:19:21 am
content: Quote from: wraper on July 25, 2017, 09:00:50 amI meant it doesn't affect the value of the pull-up resistor, obviously putting 5V into a 3V3-only GPIO won't end well. That's a pretty basic thing most beginners are aware of. And if they're not aware of it, they will be when they try it! (Failures teach us more than easy success.)

author: timb
author_rank: Super Contributor
timestamp: July 25, 2017, 11:43:57 am
content: Quote from: atech on July 25, 2017, 09:08:30 amThe 5.1k you picked is fine. As would 10k be, honestly. You don't really need to worry about all the "contact whetting current" stuff at your level. If you were producing a commercial product used in extreme environments, then maybe worry about it, but for a hobby project there's no need.(In fact, modern snap dome switches like you use on a breadboard are for the most part "self-cleaning" due to the action. In reality you really only need to worry about minimum currents these days on certain types of relays.)

author: wraper
author_rank: Unknown
timestamp: July 25, 2017, 01:21:04 pm
content: Quote from: timb on July 25, 2017, 11:43:57 amI guess you haven't repaired electronics much. Tact switches die like plague on many devices. In many of those cases enough current through the switch would avoid device malfunction. Often you need to replace all of them otherwise others will start acting within a year. "self-cleaning", you should disassemble some used tact switches and look through the microscope to appreciate how "clean" contacts look like.

author: timb
author_rank: Super Contributor
timestamp: July 25, 2017, 04:33:17 pm
content: Quote from: wraper on July 25, 2017, 01:21:04 pmSelf-cleaning of oxides, not dirt and debris. That's why I put it in quotes.If a tact switch was broken because of dirt or oxidation it would be easily fixable by a shot of contact cleaner spray. However, it's been my experience that most of them break due to a mechanical failure. Some cheap off-brand tact switches are only rated for a few hundred actuations!I've repaired quite a bit of gear over the years, both old and new.

author: wraper
author_rank: Unknown
timestamp: July 25, 2017, 09:02:30 pm
content: Quote from: timb on July 25, 2017, 04:33:17 pmI wasn't talking about dirt coming from outside either. Almost no tact switch uses gold plating so they oxidize like hell. And metal membrane usually is just made of steel.QuoteWonder how you will get it under metal dome unless make it flowing all over the PCB. And your device is already faulty anyway. Also who keeps the contact cleaner just in case, not to say with very dubious efficiency in such case.QuoteIn my experience they usually are completely fine mechanically but electrically faulty. Here is just a random roughly 10 years old tact switch. It had barely any presses in it's lifetime, and was in a dry room all of that time. Most of the 3-5 years old tact switches look much worse than this. Unfortunately right now I don't have any of them around to take a photo. Often you see something similar to metal film growing in between of the contacts. And it's actually conductive, in 10+ to hundreds of kiloohms range.

author: wraper
author_rank: Unknown
timestamp: July 25, 2017, 09:12:15 pm
content: "Self cleaning", I would rather call it self oxidizing in places where the metal dome ever touches contacts, likely because of dissimilar metals.

author: timb
author_rank: Super Contributor
timestamp: July 25, 2017, 11:06:53 pm
content: Quote from: wraper on July 25, 2017, 09:02:30 pmMost of us keep Deoxit or similar sprays on-hand for cleaning purposes. A shot of it directly at the top of the tact switch will flood it, then you actuate it a few times and let the spray evaporate. Voila, no more oxidation.Also, those images you show aren't that bad for a cheap switch, especially over a decade! Also, I doubt even a 1mA current through that switch would prevent that type of oxidation. You laid the reasons out yourself: It's due to the dissimilar metals, contact shape and being exposed to the air.The reason minimum currents are required to keep certain types of relay contacts clean has to do with the shape of the contacts, the materials used, if they're sealed, contact arrangement, etc.A snap dome switch tact switch is completely different from a relay.

author: atech
author_rank: Newbie
timestamp: July 26, 2017, 02:27:27 am
content: I am using these switches from amazon. Do I need to be concerned about component failure? According to the datasheet they are rated between 1-3 million actuations.https://www.amazon.com/gp/product/B017AUJY2C/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

author: wraper
author_rank: Unknown
timestamp: July 26, 2017, 09:03:11 am
content: Quote from: timb on July 25, 2017, 11:06:53 pmI would like to see how it will flood the air pouch under the metal dome without applying excessive amount of it. Not to say, contact contamination won't go anywhere but will stay exactly where it is as there is no wiping action in the tact switch.QuoteYou can check datasheet for omron D2F switches with gold plated contacts. Low current types like used in a lot of computer mouses suggest minimum 1mA @ 5V.

author: timb
author_rank: Super Contributor
timestamp: July 26, 2017, 10:42:57 am
content: Quote from: atech on July 26, 2017, 02:27:27 amLike I said, for a hobby project you're absolutely fine with those and 5k resistors. wrapper is forgetting this is the beginners section and that people who are just figuring out the basics don't need to worry about these sorts of things. If you're building tens of thousands of these as a consumer product, yes, worry about it, otherwise you're fine.

author: wraper
author_rank: Unknown
timestamp: July 26, 2017, 02:22:49 pm
content: Quote from: timb on July 26, 2017, 10:42:57 amI'm just suggested how to get it right from the beginning. Actually I just complained after OP decided to increase resistance for no good reason after floobydusts' post.

author: atech
author_rank: Newbie
timestamp: July 28, 2017, 07:11:42 am
content: This is strange...The fix worked, so I got really excited. I needed to go do something, so I left it running, but when I came back 2 hrs later the problem was back! What could have happened in 2 hrs of it sitting there?

author: timb
author_rank: Super Contributor
timestamp: July 29, 2017, 12:40:33 am
content: Quote from: atech on July 28, 2017, 07:11:42 amCan you take some pictures of the setup, showing us how things are connected? That would help us figure out better what's going on. Also, how are you reading the buttons, code wise.

author: wraper
author_rank: Unknown
timestamp: July 29, 2017, 10:42:31 pm
content: If everything is properly connected, should be a software issue.