Hello there,
I'm trying to measure the frame rate of a led installation (3x5meter ws2812 strips) where an arduino MEGA receives UDP packets from my mac and activate the pixels using adafruit Neopixel Library.
I'm using this code in my main loop to count the frames :
void loop(){
... READ THE UDP PACKET...
... ACTIVATE THE PIXELS WITH strip.setPixelColor() ...
nbframes++;
if (nbframes>500){ //counting every 500 packets
now = millis();
Serial.println(now) ;
Serial.println( 500/ (float(now-lastUpdated)/1000) );
nbframes=0;
lastUpdated=millis();
}
strip.show();
}
the problem is when the arduino says 3 seconds has past, I can count 9 seconds in the real world ! so i cannot have precise frames per second.
If I comment the "strip.show" line, the problem disappear.
Something must happen in the adafruit library that prevents millis from counting well. I've read that arduino millis() is not affected by other function since it's using interrupts. So what can it be ?
Could I use another way to count my framerate while displaying the pixels ?
here is the output of the Arduino serial port, using a shell "cat" to have timestamps (sorry for the french time formats )
18001, Ven 10 jul 2015 17:24:26 CEST
164, Ven 10 jul 2015 17:24:37 CEST
21047, Ven 10 jul 2015 17:24:37 CEST
164, Ven 10 jul 2015 17:24:48 CEST
24093, Ven 10 jul 2015 17:24:48 CEST
164, Ven 10 jul 2015 17:24:59 CEST
27140, Ven 10 jul 2015 17:24:59 CEST
164, Ven 10 jul 2015 17:25:10 CEST
30185, Ven 10 jul 2015 17:25:10 CEST
164, Ven 10 jul 2015 17:25:21 CEST
33231, Ven 10 jul 2015 17:25:21 CEST
164, Ven 10 jul 2015 17:25:32 CEST
36275, Ven 10 jul 2015 17:25:32 CEST
164, Ven 10 jul 2015 17:25:43 CEST
39319, Ven 10 jul 2015 17:25:43 CEST
164, Ven 10 jul 2015 17:25:54 CEST
42364, Ven 10 jul 2015 17:25:54 CEST
164, Ven 10 jul 2015 17:26:05 CEST
45410, Ven 10 jul 2015 17:26:05 CEST
Thanks for your help
Ben.