2014-06-09 04:15 PM
Hi guys, i am trying to make some 3d orientation for a RC toy. So i have a MPU6050 from wich i read 6 axis ( 3 xyz gyro, and 3 xyz accelerometer).
Search the internet till exaustion, and found a little project using some IMU filtering, however the project is complied in somekind of ''online complier'' The original code can be found here: http://mbed.org/users/aberk/code/IMUfilter_RPYExample/file/dda873ab579f/main.cpp My problem is not implementing the actual 6 axis readings/filtering, but saw there some kind of custom ticker appeal ''Ticker.attach''. At first sight that looks to me like a interrupt caller.accelerometerTicker.attach(&sampleAccelerometer,
0.005
);gyroscopeTicker.attach(&sampleGyroscope,0.005
); filterTicker.attach(&filter, FILTER_RATE); From above and the original code i can see that there are 3 distict interrupts defined at specific intervals, im right? In my code i have setup the timer to 5miliseconds ( 1/0,005sec = 200hz), wich generates a interrupt event every 5 ms, Using one timer was ok. But if i need 3 distinct operations in every interrupt? Or lets say i need 3 interrupts events, one for sampling acc, one for sampling gyro and the last for filter computations. Are these achiveable with one timer or i must use 3 separate timers? In the case of using 3 timers, i must declare the priority in the order i want to execute my functions? For example i want 1st int to sample acc, that would mean priority 1 timer 2 sample gyro sensor at 5 ms , priority 2? timer3 filter calculations at Filter_Rate, priority 3? I am using IAR as IDE and discovery f4 board hooked with stm32f407VG