Using GPIO interrupts
#1
I'm experimenting with GPIO interrupts on my RockPro64. I used the "Watching buttons" example from here: https://www.npmjs.com/package/epoll, but I changed the pin number to 156 (GPIO4_D4, pin 31 on the header).

The hardware is as follows: there's a mechanical switch between the supply (a buck converter with 3V output) and GPIO4_D4 and a 10k pull-down resistor between GPIO4_D4 and ground.

My issue is that when the button is released, the script just constantly spits out "released" (falling edge) events as fast as it can. When I close the switch, I get a couple of rising edge events, then a few falling edge events and then again a few rising edges. Then rising edge events pop up occasionally while the switch is still closed. I also found out that if I connect GPIO4_D4 directly to ground (with the switch open), the falling edge interrupts aren't emitted as frequently.

I'm aware of the fact that mechanical switches have contact bouncing, but is it normal that the events are repeated several times? Has anyone made a working hardware and software setup to detect interrupts with RockPro64? I would appreciate if you share your experiences Smile Thanks!
  Reply
#2
(06-30-2021, 06:39 AM)antonlyap Wrote: I'm experimenting with GPIO interrupts on my RockPro64. I used the "Watching buttons" example from here: https://www.npmjs.com/package/epoll, but I changed the pin number to 156 (GPIO4_D4, pin 31 on the header).

The hardware is as follows: there's a mechanical switch between the supply (a buck converter with 3V output) and GPIO4_D4 and a 10k pull-down resistor between GPIO4_D4 and ground.

My issue is that when the button is released, the script just constantly spits out "released" (falling edge) events as fast as it can. When I close the switch, I get a couple of rising edge events, then a few falling edge events and then again a few rising edges. Then rising edge events pop up occasionally while the switch is still closed. I also found out that if I connect GPIO4_D4 directly to ground (with the switch open), the falling edge interrupts aren't emitted as frequently.

I'm aware of the fact that mechanical switches have contact bouncing, but is it normal that the events are repeated several times? Has anyone made a working hardware and software setup to detect interrupts with RockPro64? I would appreciate if you share your experiences Smile Thanks!

export is depreciated and was actually removed in the newer kernels.
gpiolib is the route you are supposed to take now.

You may want to consider enabling the internal pulldown resistor to see if that helps.
  Reply
#3
I installed gpiolib packages (libgpiod2, libgpiod-dev, gpiod - all v1.6.2). Then I used `sudo gpiomon 4 28` and `sudo gpiomon -B pull-down 4 28` and they both give exactly the same output as sysfs. Also when I disconnect my whole button setup and touch the input with my finger, the command spits out RISING and FALLING interrupts no matter whether I enable pull-down or pull-up or disable them.
  Reply
#4
I've done some more testing and now the behavior is a bit different:

- The pin doesn't generate constant FALLING interrupts when pulled to ground
- However, when I touch the pin while the switch is open, it still picks up EMI and generates interrupts even though I have the 10k pull-down resistor connected, and I also tried it with the built-in pull-down - same results
- When I toggle the switch, the pin bounces (as expected) but generates several RISING/FALLING interrupts in a row (as before)

So my questions now are:
- Why does the pin pick up signals from my body despite the fact that I have pull-down resistors? How can I prevent this from happening? I'm probably asking at the wrong forum, but has anyone had a situation similar to mine?
- Is it normal that I register several interrupts with the same edge in a row? Common sense suggests that I can only get a FALLING interrupt after a RISING interrupt, but instead I get multiple RISING interrupts one after the other. I might be wrong, please correct me if so
Thanks!
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  GPIO on the RockPro64 - all pins high? colinmarc 2 1,522 11-18-2022, 10:20 AM
Last Post: colinmarc
  GPIO Expander HAT for ROCKPro64 and Quartz64 CounterPillow 7 5,187 07-18-2022, 10:05 PM
Last Post: zer0sig
  GPIO performance 100x slower compared to Raspberry Pi 3 axelf 9 9,513 08-19-2020, 04:41 PM
Last Post: Gienek
  GPIO in sleep mode Mentaluproar 2 3,293 04-08-2019, 03:50 PM
Last Post: Mentaluproar

Forum Jump:


Users browsing this thread: 1 Guest(s)