====== Sensor fusion ======
===== Overview =====
The aim of this project is to learn sensor fusion algorithms and implement them on ARM microcontroller.
==== GY-80 ====
GY-80 is a cheap sensor board. Available on Ebay and DealExtreme. \\
{{:projects:gy-80.jpg?350|http://dx.com/p/gy-80-bmp085-9-axis-magnetic-acceleration-gyroscope-module-for-arduino-145912}}
Board feature 4 sensors providing in total 10-dimensional information.
^ Sensor ^ Description ^ I2C Address (8bit) ^
| [[http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00265057.pdf|L3G4200D]] | ST three-axis digital output gyroscope | 0x69 |
| [[http://www.analog.com/static/imported-files/data_sheets/ADXL345.pdf|ADXL345]] | Analog.com 3axis Digital Accelerometer | 0x53 |
| [[http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/HMC5883L_3-Axis_Digital_Compass_IC.pdf|HMC5883L]] | Honeywell Three-Axis Digital Compass | 0x1E |
| [[http://www.bosch-sensortec.com/content/language1/downloads/BST-BMP085-DS000-05.pdf|BMP085]] | Bosh Digital Pressure Sensor | 0x77 |
===== Project assumptions =====
The purpose of this project is to provide sensor fusion solution using low-cost sensor board.
===== Phase I =====
* Build a I2C ↔ PClink
* Set up sensors
* Read data periodically
* Plot the data
==== Launchpad connections ====
* Serial transmission parameters: ''115200 8N1''
| 1.1 | GY-80 VCC_3.3V |
| 1.10 | GY-80 SDA |
| 1.9 | GY-80 SCL |
| GND | GY-80 GND |
==== Source code ====
* [[:projects:gy-80:Processing_GUI]]
==== Screenshots ====
{{:projects:gy-80_plotter.png?direct|}}
Notes:
* Scaling is being adjusted in real time, shake sensor board to set maximum values so graph can be scaled to fit the window.
* Keys ''1'' to ''-'' turn on/off plotting value
* Key ''c'' clears the window
===== Phase II =====
* Implement 1D Kalman filter
==== Screenshots ====
{{:projects:gy-80_kalman.png?direct|}}
Notes:
* Key ''k'' - toggles filtered graph
* Key ''m'' - toggles measured value
==== Source code ====
* ARM code unchanged
* [[:projects:gy-80:Processing_GUI#kalman]]
===== Phase III =====
* 2D Sensor fusion
Following graph show angle measurement using accelerometer (red) and gyroscope (blue). Gyro clearly shows error-induced drift.
{{:projects:gy-80_drift.png?direct|}}
==== Complementary filter ====
Complementary filter is a good alternative for small systems. http://web.mit.edu/scolton/www/filter.pdf
==== Comparison ====
{{:projects:gy-80_kalmanvscomplf.png?direct|}}
Filters:
* Red - Complementary
* Green - Kalman
While both methods provided unbiased value, the Kalman filter provided more stable readout.
Present-day MCUs provide sufficient power to use Kalman filter in real-time.
===== Phase IV =====
* Build balancing robot.
{{http://www.youtube.com/v/CwFBXYt4UKg?.swf?420×315}}
The robot consists of 5 parts: Tamiya gearbox, double H-bridge driver, Bluetooth wireless module, Stellaris launchpad board and GY-80 sensor board.
The power is provided externally.
GY-80 board provides accelerometer and gyro sensor measurement at 100 [Hz] (UPS variable). Sensor data is then processed by kalman filter and feed into PI controller.
Control signal is driving PWM output driving motors H bridges.
Notes:
* The stability is good but not perfect
* Kalman filter response was rally bad. I have boosted the response by multiplying angular acceleration value. Estimated angle value has overshot now but is fast enough.
* Robot motors are powered externally. Wires are influencing robot stability.
* Taller robot would be much better (bigger moment of inertia).
* Both robot wheels are independent. Connected wheels would work much better reducing yaw.
{{:projects:gy-80_balancer.zip|Source code}}
{{:projects:gy-80_balancer.png?nolink|}}
Robot operation. Red - accelerometer angle. Green - Gyro angular acceleration. Blue - estimated angle. Yellow - PI control signal.
===== References =====
* www.processing.org
* [[http://www.ti.com/tool/ek-lm4f120xl|TI Stellaris Launchpad]]
* [[http://www.cs.unc.edu/~tracker/ref/s2001/kalman/index.html|An Introduction to the Kalman Filter]] - SIGGRAPH paper by Greg Welch and Gary Bishop
* [[http://web.mit.edu/scolton/www/filter.pdf|The Balance Filter]] - MIT presentation by Shane Colton
* [[http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/|tkjelectronics blog]] - A practical approach to Kalman filter and how to implement it
* [[wp>kalman_filter|Kalman filter, wikipedia]]