XRP robot runs "when button A pressed" when it powers on

Issue #530 new
Russell Owen created an issue

My XRP robot kit often or always runs “when button A pressed” when it is powered on. Is this a known issue with any other boards, and is there some board-specific way to add a bit of dead time before looking for users buttons?

This is with pilot release v1.2.80

Comments (6)

  1. John Maloney repo owner

    This is not an issue with other boards.

    The schematic shows a 100k pullup resistor with a 0.1 uF capacitor (for debouncing, I assume). It's possible that MicroBlocks starts up so fast that the capacitor hasn't had time to charge. Thus, the logic level on the button pin is low (i.e. the button appears to be pressed).

    If that's the correct explanation, we can probably to work around the issue by adding a small delay to the startup code for the XRP. I'm guess 100 msecs would be more than enough.

    https://docs.sparkfun.com/SparkFun_XRP_Controller/assets/hardware_files/XRP_Controller.pdf

  2. John Maloney repo owner

    As a test, you could create a project with this script:

    scriptImage349261.png

    Power cycle the board, then connect to it with a USB cable. Use the "get file from board" command in the file menu to recover the file. It should contain a number indicating the number of milliseconds before the A button state became "false".

    If the number is zero then my theory is wrong (or there's a bug in the test program). But I'm guessing it will be at least a few milliseconds.

  3. John Maloney repo owner

    Note that you can download the above PNG, then drop it onto MicroBlocks to load the script.

  4. Russell Owen reporter

    I ran that and got 50 ms pretty reliably (info originally sent via private communication). I see that a fix went into the 2024-06-29 release, but when I tested it I found the problem still existed. So I ran the following code with that release:

    Here is truncated data (I never saw button A bounce; once it went to 0 it stayed 0):

    #, start, run
    1, 5
    1, 6
    1, 8
    1, 9
    0, 11
    0, 13
    ...
    #, start, run
    1, 59
    0, 107
    0, 141
    ...
    #, start, run
    1, 58
    0, 135
    0, 171
    ...

    In case it helps, I also observe a delay of about 1/2 second (maybe more) between turning on the power and when the “when button A pressed” block starts. (I don’t know how to measure that accurately).

  5. John Maloney repo owner

    Looking into this. I think the startup delay may be the result of firing up the WiFi chip. But in that case, I'm surprised that we're seeing the button A auto firing on startup since half a second is a really long time for the 0.1 uF capacitor on the button circuit to charge up. The RC time constant is 10 msecs.

  6. Log in to comment