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

second loop() with lower frequency for maintenance tasks?

Postby Hamburger » Fri Jun 24, 2011 2:28 pm

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?
User avatar
Posts: 2557
Joined: Tue Mar 01, 2011 2:14 pm
Location: air

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

Postby Alexinparis » Fri Jun 24, 2011 7:26 pm


For the moment, I prefer to use this code approach:
Code: Select all
 if ( micros() > xyzTime + 500000 ) {
      xyzTime = micros();

( with micros() or millis() )
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Return to Software development

Who is online

Users browsing this forum: No registered users and 8 guests