Quantcast
Viewing all articles
Browse latest Browse all 4829

General • Interrupt constantly fires weirdly

I am using a Pico W with a rotary encoder that has a button on the knob. This is software debounced and configured as follows;

Code:

'e_button' : Pin(21, mode=Pin.IN, pull=Pin.PULL_UP),self.pins['e_button'].irq(trigger = Pin.IRQ_RISING, handler=self.encoderButton)
When I press the button the first few times usually everything is OK and it activates my relay for 3 seconds and shuts it off and only fires one interrupt. My relay is a 2 channel SPDT board and it is powered by the 5v power rail the pico is also on and uses that ground because it has to.

But eventually it will just start acting like the interrupt is constantly firing. I can watch the print message from it firing in the code over and over and over again. Eventually sometimes it will stop. If I pull the button wire, it stops immediately... SOMETIMES. But not always. SO WEIRD

The rotary encoder is wired directly to the pico using the 3v3 as power and the pico on board ground.
I replaced the encoder with another one to make sure that it wasn't bad hardware but it still happens.
There is another single channel relay which does not have this problem. It is similar to the two channel in many ways.

I would be tempted to think that this is flyback or capacitance but I added a way oversized cap and tried a flyback diode with no luck but also...
...it isn't entirely related to the relay changing state because it will just sit there spamming interrupts the entire time the relay is active.

I came from ardu and this is the first time I've encountered this with the pico and I'm not sure what to do or what to change about the config to make it work.

Statistics: Posted by underhilll — Sat Aug 03, 2024 12:28 pm



Viewing all articles
Browse latest Browse all 4829

Trending Articles