I am trying to understand how I should use MinIMU-9 in a larger project. I have gone through and installed the libraries and AHRS code, done the calibration, and the board seems to work as expected.
Now, what I want to do is to be able to tell my robot “turn north” for example. So I will need a loop that monitors input (maybe from a remote control or through serial for example), which will then pass control over to a function that will read the IMU and steer until it gets the compass where I want it.
However, after looking at the AHRS code, it’s not clear for me how to do this. There are readings of the IMU at 50Hz, and the compass at 10Hz. But in the larger loop, I may not be reading the compass this frequently while waiting for instructions on what the robot should do, which would make a long integration time in the DCM algorithm. I don’t know if this will create huge errors, or is the “right way”.
Another approach would be to use some kind of threading, so the microcontroller (Arduino) is always reading the IMU at approximately 50Hz/10Hz and storing it in an internal state, and when my command is given the steering function can request the value. I’m no threading expert but this sounds like it would give what I think it called a race condition or something.
Anyway, in short, I was trying to do something that initially I thought was simple and now I’m not sure. If no one can give advice I’m going to attempt to figure it out and I’ll let you know how it goes. I guess I would maybe be better off with an IMU that will report its estimated R/P/Yaw?
A last resorts approach would be to either make a tiny Arduino using RBBB or something like that to handle the AHRS, and feed that into another Arduino, or possibly get a Propeller controller so I can run it on a separate thread/cog.
Sorry, that’s a lot of reading, but thank you for any help!
Arduino Uno (1.0 software), R1 or R2 board