EuroPi icon indicating copy to clipboard operation
EuroPi copied to clipboard

[Bug Report] Ghost Button presses

Open gamecat69 opened this issue 2 years ago • 1 comments

Bug Report

Describe the bug
This could potentially be a problem with the hardware or perhaps the firmware button debounce method. On some occasions a b(n).handler_falling interrupt can be triggered without a physical press of a button. However, it is quite difficult to reproduce and seems to happen mostly randomly. The bug was identified after logging was added to the CVecorder script.

To Reproduce
In some cases this can be produced by starting the module with nothing connected, then connecting CV to ain followed by a clock into din. However, this problem does not happen all the time and appears to happen rather randomly.

Expected behavior
A b(n).handler_falling interrupt should not be triggered unless a button is pressed and then released.

Images
A slightly upset kitten

Additional context
This bug has been identified so far only when using the CVecorder script - as a button press can trigger the deletion of recorded CV, so it is therefore obvious when it happens. However, I believe this issue could manifest in all scripts.

gamecat69 avatar Apr 29 '22 16:04 gamecat69

Confirmed to appear in probapoly and consequencer too. Placing an upper time limit on a long button press detection dramatically reduces the chance of a phantom button press like the snippet below (3000 is used as an upper limit in this example).

if ticks_diff(ticks_ms(), b1.last_pressed()) > 500 and ticks_diff(ticks_ms(), b1.last_pressed()) < 3000:

gamecat69 avatar Aug 03 '22 22:08 gamecat69

I noticed these as well working on my own script. I know there are pullup resistors on the europi board, but also enabling the internal pullups of the pi pico seams to resolve these issues for me. I think my header pins on the pico are not the best and it only happens on some eurorack PSUs. To test this you can enable the pullups in your script like this:

    b1 = Button(4)
    b1.pin=Pin(4, Pin.IN,Pin.PULL_UP)
    b2 = Button(5)
    b2.pin=Pin(5, Pin.IN,Pin.PULL_UP)

or directly change this line in europi.py self.pin = Pin(pin, Pin.IN) to self.pin = Pin(pin, Pin.IN,Pin.PULL_UP)

There are some other things I want to optimize in the DigitalReader class, that might resolve or at least reduce this issue as well. I will propose a PR for these when I got time.

redoxcode avatar Nov 14 '22 17:11 redoxcode

This is great! How do you feel about raising a PR for a change to the europi.py firmware?Kind Regards,Nik(Sent from a mobile device)On 14 Nov 2022, at 17:19, redoxcode @.***> wrote: I noticed these as well working on my own script. I know there are pullup resistors on the europi board, but also enabling the internal pullups of the pi pico seams to resolve these issues for me. I think my header pins on the pico are not the best and it only happens on some eurorack PSUs. To test this you can enable the pullups in your script like this: b1 = Button(4) b1.pin=Pin(4, Pin.IN,Pin.PULL_UP) b2 = Button(5) b2.pin=Pin(5, Pin.IN,Pin.PULL_UP)

or directly change this line in europi.py self.pin = Pin(pin, Pin.IN) to self.pin = Pin(pin, Pin.IN,Pin.PULL_UP) There are some other things I want to optimize in the DigitalReader class, that might resolve or at least reduce this issue as well. I will propose a PR for these when I got time.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

gamecat69 avatar Nov 14 '22 18:11 gamecat69

I would like to have some people confirm this before I put it in a PR, since it could be a thing of my hardware only. But yeah, as I wrote earlier I plan a PR to the europi.py firmware, that could include this change.

redoxcode avatar Nov 14 '22 18:11 redoxcode

I can confirm the suggested code change seems to avoid the phantom button presses

gamecat69 avatar Dec 22 '22 19:12 gamecat69

Unfortunately, this change prevents the ability to long-press both buttons to return to the menu.

gamecat69 avatar Dec 23 '22 09:12 gamecat69

Is this still present? There was some minor fix to the logic in https://github.com/Allen-Synthesis/EuroPi/pull/212

redoxcode avatar Jan 23 '23 11:01 redoxcode

Unfortunately, this change prevents the ability to long-press both buttons to return to the menu. I guess you lost the irq handler for the both action by redefining the buttons. That handler gets set in bootloader.py. You should try to change europi.py to include the PULL_UP.

redoxcode avatar Jan 23 '23 11:01 redoxcode

This hasn't had any further reports since the issue was discovered, and there have been a few releases since, so I'm going to mark it as closed and re-open if it's experienced again in future

roryjamesallen avatar Mar 22 '23 13:03 roryjamesallen