Hi All,
Wondering if someone can help demystify the inaccurate timing aspect of my project.
The project is just a simple timer, with an encoder incrementing or decrementing the rate in which 0v - 5v (HIGH / LOW) signal is outputted, and the use of a WS2182B (neoPixel) LED for output pulses.
Using the elapsedMillis library, I've set up a typical timer . I'm also, reading an encoder function, to check when the encoder has changed position using this library. (https://github.com/mathertel/RotaryEncoder)
Now, the timer starts to drift after 30 seconds or so, and I initially thought it could be the encoder or neoPixel timing causing the issue. So I removed both of those variables and used the onboard LED (pin 13) to represent the pulse output of the timer. It still drifts....
I'm referencing the pulse using Ableton Live Metronome, and haven't come across any issues with the Inbuilt Metronome having inaccuracy issues.
Any ideas as to how to correct this? What could be causing the drift for such a trivial task?
What would you recommend for accurate timing, using an encoder and WS2812B LED for visual output?
Thanks in advance,
M
Wondering if someone can help demystify the inaccurate timing aspect of my project.
The project is just a simple timer, with an encoder incrementing or decrementing the rate in which 0v - 5v (HIGH / LOW) signal is outputted, and the use of a WS2182B (neoPixel) LED for output pulses.
Using the elapsedMillis library, I've set up a typical timer . I'm also, reading an encoder function, to check when the encoder has changed position using this library. (https://github.com/mathertel/RotaryEncoder)
Now, the timer starts to drift after 30 seconds or so, and I initially thought it could be the encoder or neoPixel timing causing the issue. So I removed both of those variables and used the onboard LED (pin 13) to represent the pulse output of the timer. It still drifts....
I'm referencing the pulse using Ableton Live Metronome, and haven't come across any issues with the Inbuilt Metronome having inaccuracy issues.
Any ideas as to how to correct this? What could be causing the drift for such a trivial task?
What would you recommend for accurate timing, using an encoder and WS2812B LED for visual output?
Thanks in advance,
M
Code:
elapsedMillis timer;
int clock;
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
if (timer > 500) {
clock = !clock;
digitalWrite(13, clock);
timer = 0;
}
}
Last edited: