second loop() with lower frequency for maintenance tasks?

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

second loop() with lower frequency for maintenance tasks?

Post 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

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

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

Post 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() )

Post Reply