I'm using Encoder library on Adafruit Feather M0 (Atmel SAM) with PlatformIO on Visual Studio Code. My test program runs a DC motor with a quadrature encoder in the same direction. In normal power mode, the counting is accurate. When I put the microcontroller into sleep at each iteration of the loop, the count changes its sign, which is an error. Here is the code:
I'm using Encoder library on Adafruit Feather M0 (Atmel SAM) with PlatformIO on Visual Studio Code. My test program runs a DC motor with a quadrature encoder in the same direction. In normal power mode, the counting is accurate. When I put the microcontroller into sleep at each iteration of the loop, the count changes its sign, which is an error. Here is the code:
Incorrect output with
Watchdog.sleep(5000);
:Correct output with
delay(5000);
: