"set servo..." and "wait..."

Issue #111 resolved
connochaetes created an issue

Hi. This might be a bug; please excuse me, if it’s something I did wrong. I’m using an ESP32 board and a FS90R servo with continuous rotation.

  • If I click the blocks “set servo…” and “stop servo…” seperately, it 's working just fine.
  • If I combine the blocks “set servo…”, “wait 1000 millisecs”, and “stop servo…” in a script, the servo won 't stop.

Any suggestions? Thanks in advance.

Comments (9)

  1. connochaetes reporter

    Obviously, if I’m using the block “wait 1000 millisecs” the board is just waiting - and only waiting. So, the servo isn’t turning while the board is waiting. Is there a kind of “timer” block that could be running while the servo is turning?

  2. Bernat Romagosa

    Nope, the board isn’t waiting, it’s just the script that contains the `wait 1000 millisecs` block that’s waiting. If the servo isn’t running, it means we’re doing something wrong.

    I’m deep into something else right now, but I’ll try to test this out later and come back to you.

  3. Bernat Romagosa

    There’s indeed a strange bug in the servo library. I found a workaround but it’s not pretty, and I don’t quite understand why the workaround fixes the issue. Let me investigate some more…

  4. Bernat Romagosa

    @John Maloney , any idea why this happens?

    This doesn’t work. It does wait, but the servo doesn’t start spinning. However:

    Clicking on the [set servo] block and then on the script that starts with the [wait ( ) millisecs]block does work as expected.

    What’s more, just adding this modification to the [ set servo ] block makes everything work normally:

    It looks like the waitMs primitive is interfering with the servo one, but I don’t get why. I don’t get why duplicating that instruction fixes it all, either.

  5. John Maloney repo owner

    Hmm. I’ve mostly used servos with non-ESP boards (micro:bit and cpx). I am guessing this may have something to do with the low-level ESP servo support in the vm. I’ll investigate.

  6. John Maloney repo owner

    I found it. It was a bug in the ESP servo code. For now, the work-around is to call “set servo _ to speed _” twice in a row. That’s because if the servo is not already running, the first call to “set speed” doesn’t do anything. The same is true for the “set serveo _ to angle _” block.

    This fix will be in the next release.

  7. Log in to comment