some coding help

 hi guys- just a quick question.

 

i want in my program to run 2 separate loops -

a control loop - running at 120Hz with a runtime of ~6ms,

and a communications loop - running at 25Hz with a runtime of ~3ms.

 

to do this i set up 2 timers (using the Atmega2560) to run at these speeds...

now here comes the tricky part- i cant run the loops inside the ISR since the arduino framework doesnt

allow nested interrupts which is required to read the digital sensors and receive incoming serial data and PPM data...

the only solution i found was to raise flags in the ISR's and then run the loops inside the main Loop...

this causes some problems such as inconsistent run frequencies (problematic for the PID).

 

how can i design the infrastructure of my program so that i run these loop at a constant speeds?

( please elaborate with code, i'm no AVR expert...)

 

Thanks,

Edi

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…