Up to these days i always worked with rasppberry pi like platforms where i have threads so multitasking was not a problem. But in avr or arm i need suggestion.
My main loop is busy enough with a few algorithms. Every 5ms program goes to the algorithm loop to calculate an output based on the readings from the sensors. Then pid controller uses this output and makes another calculation. As a result i will have 4 different variables which will be indicating the high times of pwm. And this process takes 4ms in every 5 ms.
Should i use timer interrupts to drive 4 motors with this 4 calculated variables perfectly or should i use a polling loop where it waits untill all motors are completing their high time(if completed while waiting for othermotors high time it will be turned low in this loop) and all turned low before leaving this loop.
Can you suggest me a approach so everything will be working without disturbing each other