I had noticed that the accelerometer had a strange offset in addition to the gyro drift I had encountered. Therefore, I conducted some more rigorous tests to look at the signal to assess the gyro drift and the accelerometer readings simultaneously. The testing method was as follows:
With the code set to record the accelerometer angle, gyro angle & overall pitch angle...
1) Undisturbed testing...
- Robot placed on stand
- Reset the arduino
- Start timer on my phone as soon as the serial monitor started outputting data
- When timer reached 30s, pull USB cable from arduino to terminate serial communication
- Record data in .txt file
- Clear the Serial Monitor
- Repeat until 5 sets of data have been collected
2) Disturbed testing...
- Same as above but between 10s and 20s of each repeat shake the robot
See the below data for the accelerometer angle...
Undisturbed data:
Disturbed data:
Observations:
- Immediately I could see that the data did not align with the experiment time (the data from both experiments apparently only went up to about 20s despite me knowing I recorded data for 30s). My conclusion was that the MPL (main program loop) must be exceeding its time limit; the code was taking longer to run than anticipated.
- The accelerometer has a constant offset of around 10 degrees; this is unchanged by excitation and will be dealt with by centering the signal about 0 by subtracting the mean from this data.
Further experimentation to verify the above:
I made the MPL time period a variable and increased it from 4ms to 7ms and the result was as follows:
I subtracted the mean from the above data and took more readings:
As a result of the above changes, the robot needed some more PID tuning (MPL period resulted in new gain values needed), but looked very promising in terms of stability.
Because I am coming to the end of my project timescale, I decided to move on to the mechanical design of the crane system despite the remaining balancing perfromance issues. The robot works well enough for proof of concept.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.