[PROBLEM] GPIO button false trigger on startup - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7) +--- Thread: [PROBLEM] GPIO button false trigger on startup (/showthread.php?tid=2700) Pages:
1
2
|
GPIO button false trigger on startup - waffle - 06-24-2020 I have one button connected to GPIO 3 that turns on the power amp and it sometimes executes the action on startup, about 1/5-10 times. Looking at the log, it happens around the time the GPIO handler is started. Maybe there's some other log I should check? RE: GPIO button false trigger on startup - Tim Curtis - 06-24-2020 You could try adding some print statements to /var/www/command/gpio-buttons.py script and then run it manually from the cmd line after moOde boots up. 1. Add the print statement after the line below. I assume you are using Button 1. Code: subprocess.call(sw_1_cmd) 2. Turn the GPIO button handler off in System config 3. Reboot 4. Run it from the command line Code: sudo /var/www/command/gpio-buttons.py If 'button 1 command executed' is printed even though you physically did not press the button then it would suggest a possible wiring issue thats causing the GPIO pin to be in the wrong state after boot. RE: GPIO button false trigger on startup - waffle - 06-24-2020 (06-24-2020, 04:46 PM)Tim Curtis Wrote: If 'button 1 command executed' is printed even though you physically did not press the button then it would suggest a possible wiring issue thats causing the GPIO pin to be in the wrong state after boot.Sometimes it does, sometimes it doesn't. Should I just set that pin to as pullup input in config.txt? That didn't help Also, I have a cap added between GPIO 3 and ground because the relay switching was causing interference. RE: GPIO button false trigger on startup - waffle - 06-24-2020 If I check the state of the pin with this script before running gpio-buttons.py, it always returns 1 Code: import RPi.GPIO as GPIO RE: GPIO button false trigger on startup - TheOldPresbyope - 06-24-2020 @waffle Some random thoughts.
Regards, Kent RE: GPIO button false trigger on startup - Tim Curtis - 06-24-2020 GPIO https://www.raspberrypi.org/documentation/usage/gpio/ RE: GPIO button false trigger on startup - waffle - 06-25-2020 (06-24-2020, 08:51 PM)TheOldPresbyope Wrote: @waffle1. The spurious behavior happens when I launch gpio-buttons.py. I was testing the pin state before launching it because Tim mentioned that the GPIO pin could be in the wrong state after boot. 4,5. The capacitor in an smd one placed directly between pins 5 and 6 on the underside of the board. The value is around 1nF if I remember correctly. 6. Here are the internals. Power button is green wire, gnd is black. 7. GPIO handler launches a python script that toggles the relay and an led on the front panel. I can't think of anything else that could launch this script. Also, this button was previously set to reboot the system, and I sometimes got reboots after I started the system, but couldn't understand wth was happening. I moved the button to GPIO 12 and gonna be testing for a while. It's a very nasty bug because you have to do lots of reboots to catch it.. RE: GPIO button false trigger on startup - gbh_uk - 06-25-2020 It's not clear, but from the photo it looks very much like the green wire (button) is connected to header Pin 3 - which is actually GPIO8, not GPIO3. GPIO3 is header pin # 15. Plus you mention you've connected a capacitor between 5 & 6. Pin 5 is GPIO9. So, potentially the bug could be that the button is connected to GPIO 8, the capacitor is connected to GPIO9, and the script is controlling GPIO3, which is not connected to anything at all. RE: GPIO button false trigger on startup - TheOldPresbyope - 06-25-2020 @waffle POST EDIT: I didn't see the response from @gbh_uk until after I posted. For sure take care of his observations first. For sure, intermittent bugs are the worst. One my first jobs as an electronically minded teenager was to sit and watch several TV sets in the back room of a local repair shop in hopes of catching them when they misbehaved. That way the real tech could concentrate on repairing sets he'd already diagnosed. He got an extra pair of eyes on the cheap and I got to play with real testing equipment that I would never have been able to access otherwise. Sorry, I overlooked the bit about this happening specifically when you start the Python script. The bit about occasional reboots in your prior work seems pretty conclusive about the script being the culprit, while a 1nf capacitor is too small to cause worry about a possible RC-time constant effect in this applicatoin. I forgot to ask. Just for completeness, what model RPi and, if an RPi4B, have you tried the same with an earlier model? The Model 4 is a different beast internally but I'm not sure this would matter in your application [Compare https://elinux.org/RPi_BCM2835_GPIOs and https://elinux.org/RPi_BCM2711_GPIOs] RPi.GPIO V0.7.0 supposedly dealt with two relevant issues: 1) Updated RPI_INFO to include RPi 4B and 2) Fixed pull up/down for Pi4 (issue 168). Since GPIO 3 is pulled high internally I'm not sure how it might be in the "wrong state" when you start the script but I'll have to think about this some more. Regards, Kent RE: GPIO button false trigger on startup - waffle - 06-25-2020 (06-25-2020, 12:50 AM)gbh_uk Wrote: So, potentially the bug could be that the button is connected to GPIO 8, the capacitor is connected to GPIO9, and the script is controlling GPIO3, which is not connected to anything at all.Here's the pinout that I believe is correct If I'd used the wrong pins neither the button nor the relay would work at all I've tried it with the button on gpio 12 (that doesn't have any capacitors or any interfaces like i2c) and I also tried powering the system with power bank to avoid any kind of interference, but the problem didn't go away. The next step is to try a clean install on another sd card I guess. (06-25-2020, 01:08 AM)TheOldPresbyope Wrote: I forgot to ask. Just for completeness, what model RPi and, if an RPi4B, have you tried the same with an earlier model?Sorry, forgot to mention that, but you can see it in the logs I posted: Code: 20200624 185221 worker: Raspbian (10.3) |