Page 1 of 1

second loop() with lower frequency for maintenance tasks?

Posted: Fri Jun 24, 2011 2:28 pm
by Hamburger
for the main loop with sensors reading, evaluation and actuator output we want minimum cycle time (or maximum frequency).
Now we do have some chores that need to be executed peridocally but with lower frequency. For the moment this includes
  • battery voltage reading,
  • current reading,
  • telemetry output over serial to LCD,
  • LED flashing
At the moment these tasks are/could be offloaded in the annex_code() function. Could/should we somehow tie this to another timed loop or at least execute it only sparingly every 10th cycle of main loop?
Hamburger

Re: second loop() with lower frequency for maintenance tasks

Posted: Fri Jun 24, 2011 7:26 pm
by Alexinparis
Hi,

For the moment, I prefer to use this code approach:

Code: Select all

 if ( micros() > xyzTime + 500000 ) {
      ...
      xyzTime = micros();
}


( with micros() or millis() )