What is the fastest instruction cycle time of loop people get?

What is the fastest instruction cycle time of loop people get? I’m currently between 46-48ms from beginning to end. I was thinking it could or should be faster. Are there methods that make this happen?

Im on a MEGA 2560, so 16mhz clock.

Update:
WS2812 TYPE LED

That’s quite high. You want more like 10ms to achieve 100fps for nice fade effects.

It really depends on the code you have written and the number and type of LEDs you are driving.

Also try and use the math functions from the FastLED library wherever possible.

You also don’t give any information on the number and type of LEDs you’re using, or what kinds of things you’re doing on each loop around.

You also didn’t tell us which board you’re using. For simple animation on a small number (under 100-200) of LEDs, almost any board works. But for complex animations on larger numbers, 32 bit ARM boards running 48-180 MHz make a dramatic difference compared to 8 bit AVR boards at 16 MHz.

He did say mega 2560 :slight_smile:

Ouch, missed that…its a testament to the marketing power of the Arduino brand that these things are still selling!

oh, opps, see Mega now.

Agreed. Im hoping to understand why its so slow.
Its really a simple program I believe, but im a novice so I may just be shooting myself in the foot with how I wrote it.
not finding anything that reduces the time.

Bad link there, but anyway, you’re doing Serial.print in your line function, this is being executed every frame, that will cause a massive slowdown. You should only Serial print when debugging, and even then preferably to do it only every second or so.

Sorry for not getting that right. Slowly working things out.

ok ill try to remove the println and get results to print every second.
Also Ive had my mega for at least 2 years now. So the limits of it are creeping up but it has a decent set of attributes to get my feet wet.

You also have delays in there. Between the prints and the delay, you’re definitely slowing things down. On an Arduino Nano, with a small number of LED’s, I can get a loop speed of over 300 fps.

oh wow… 5-6ms now
ok serial.print slows it down hugely.
Do you guys monitor cycle time externally? or just for a debug purpose?

That answered my question. So I appreciate the advice all. Thanks!

Serial.print speed depends heavily on the baud rate. Maybe turning it up to the highest setting would help?