User Tools

Site Tools


projects:gy-80

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:gy-80 [2013/01/12 16:24] – [Phase IV] mkuciaprojects:gy-80 [2013/03/04 22:13] (current) – [Source code] mkucia
Line 1: Line 1:
 +====== 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
 +
 +<html>
 +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) -->  <svg    xmlns:dc="http://purl.org/dc/elements/1.1/"    xmlns:cc="http://creativecommons.org/ns#"    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:svg="http://www.w3.org/2000/svg"    xmlns="http://www.w3.org/2000/svg"    version="1.1"    width="308.83362"    height="123.34399"    id="svg2">   <defs      id="defs4" />   <metadata      id="metadata7">     <rdf:RDF>       <cc:Work          rdf:about="">         <dc:format>image/svg+xml</dc:format>         <dc:type            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />         <dc:title></dc:title>       </cc:Work>     </rdf:RDF>   </metadata>   <     transform="translate(-236.55353,-229.71667)"      id="layer1">     <rect        width="68.185295"        height="37.880722"        x="247.55353"        y="243.82584"        id="rect3046"        style="fill:#0000ff;fill-opacity:0.56345179;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     <rect        width="68.185295"        height="97.984833"        x="356.45294"        y="244.07584"        id="rect3052"        style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     <path        d="m 451.86259,259.65721 -1.44809,-0.83626 0,0.59655 -7.40156,0 1.44117,-1.52261 c 0.12265,-0.0983 0.28312,-0.16727 0.44819,-0.17109 0.6678,0 1.06437,-1.8e-4 1.21034,-4.1e-4 0.0989,0.28191 0.36474,0.48539 0.68071,0.48539 0.39972,0 0.72411,-0.32436 0.72411,-0.72423 0,-0.40004 -0.32436,-0.72429 -0.72411,-0.72429 -0.31597,0 -0.58176,0.20336 -0.68071,0.48504 l -1.19616,-2e-4 c -0.32418,0 -0.66389,0.17787 -0.8801,0.38638 0.006,-0.006 0.0121,-0.0128 -4e-4,1.1e-4 -0.005,0.005 -1.52903,1.61528 -1.52903,1.61528 -0.12239,0.0982 -0.28278,0.16669 -0.44774,0.17063 l -0.8373,0 c -0.11098,-0.55313 -0.59944,-0.96988 -1.18536,-0.96988 -0.66803,0 -1.20953,0.54151 -1.20953,1.20933 0,0.66803 0.5415,1.20956 1.20953,1.20956 0.58604,0 1.07449,-0.41709 1.18548,-0.97069 l 0.82263,0 c 0.002,0 0.004,1.2e-4 0.006,0 l 1.8195,0 c 0.16464,0.004 0.32483,0.0728 0.4471,0.1711 0,0 1.52411,1.61001 1.52883,1.61522 0.0122,0.0129 0.006,0.006 1.1e-4,1.1e-4 0.21622,0.20849 0.55606,0.38624 0.88031,0.38624 l 1.15275,-2e-4 0,0.48553 1.44846,0 0,-1.44832 -1.44846,0 0,0.4849 c 0,0 -0.30361,-5e-4 -1.16687,-5e-4 -0.16511,-0.004 -0.32575,-0.0727 -0.44835,-0.17098 l -1.44148,-1.5229 5.59152,0 0,0.5975 L 451.86259,259.65721 Z"        id="path1334" />     <text        x="268.34409"        y="265.57367"        id="text3866"        xml:space="preserve"        style="font-size:7.72295475px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><tspan          x="268.34409"          y="265.57367"          id="tspan3868"          style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;font-family:Verdana;-inkscape-font-specification:Verdana">GY-80</tspan></text>     <path        d="m 347.32361,269.49691 8.12932,-9.83986 -8.12932,-9.83986 0,5.67716 -22.45546,0 0,-5.67716 -8.12932,9.83986 8.12932,9.83986 0,-5.67716 L 347.32361,263.81975 Z"        id="path3887"        style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     <text        x="366.96191"        y="290.33051"        id="text3898"        xml:space="preserve"        style="font-size:7.72295475px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><tspan          x="366.96191"          y="290.33051"          id="tspan3900"          style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;font-family:Verdana;-inkscape-font-specification:Verdana">Stellaris</tspan><tspan          x="366.96191"          y="299.98419"          id="tspan3902"          style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;font-family:Verdana;-inkscape-font-specification:Verdana">Launchpad</tspan></text>     <text        x="330.93628"        y="262.15964"        id="text3916"        xml:space="preserve"        style="font-size:20px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><tspan          x="330.93628"          y="262.15964"          id="tspan3918"          style="font-size:6.875px">SPI</tspan></text>     <path        d="m 456.57254,269.4969 8.12931,-9.83986 -8.12931,-9.83986 0,5.67716 -22.45547,0 0,-5.67716 -8.12931,9.83986 8.12931,9.83986 0,-5.67716 L 456.57254,263.81974 Z"        id="path3924"        style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     <rect        width="68.185295"        height="37.880722"        x="466.20184"        y="240.71667"        id="rect3926"        style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     <text        x="494.48718"        y="262.46454"        id="text3928"        xml:space="preserve"        style="font-size:7.72295475px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><tspan          x="494.48718"          y="262.46454"          id="tspan3930"          style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;font-family:Verdana;-inkscape-font-specification:Verdana">PC</tspan></text>   </g> </svg>
 +</html>
 +==== 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 ====
 +<html>
 +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg    xmlns:dc="http://purl.org/dc/elements/1.1/"    xmlns:cc="http://creativecommons.org/ns#"    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"    xmlns:svg="http://www.w3.org/2000/svg"    xmlns="http://www.w3.org/2000/svg"    version="1.2"    width="590.6015"    height="128.00433"    id="svg2">   <defs      id="defs4">     <marker        refX="0"        refY="0"        orient="auto"        id="marker4216"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.2,0,0,-0.2,-1.2,0)"          id="path3946"          style="fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:#4d4d4d;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="Arrow1Mend"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.4,0,0,-0.4,-4,0)"          id="path4202"          style="fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:#4d4d4d;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="Arrow1Lend"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.8,0,0,-0.8,-10,0)"          id="path3934"          style="fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:#4d4d4d;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="Arrow1Mstart"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(0.4,0,0,0.4,4,0)"          id="path3970"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="marker5378"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.2,0,0,-0.2,-1.2,0)"          id="path5380"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="marker5314"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.2,0,0,-0.2,-1.2,0)"          id="path5316"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="marker5268"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(0.2,0,0,0.2,1.2,0)"          id="path5270"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="Arrow1Send"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.2,0,0,-0.2,-1.2,0)"          id="path3979"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="marker4426"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.2,0,0,-0.2,-1.2,0)"          id="path4428"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="marker4306"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(-0.8,0,0,-0.8,-10,0)"          id="path4308"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="marker4240"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(0.2,0,0,0.2,1.2,0)"          id="path4242"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>     <marker        refX="0"        refY="0"        orient="auto"        id="Arrow1Sstart"        style="overflow:visible">       <path          d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"          transform="matrix(0.2,0,0,0.2,1.2,0)"          id="path3976"          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1" />     </marker>   </defs>   <metadata      id="metadata7">     <rdf:RDF>       <cc:Work          rdf:about="">         <dc:format>image/svg+xml</dc:format>         <dc:type            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />         <dc:title></dc:title>       </cc:Work>     </rdf:RDF>   </metadata>   <     transform="translate(-0.67397976,-354.68845)"      id="layer1">     <path        d="m 515.91803,418.69061 67.87945,0"        id="path3940"        style="fill:none;stroke:#4d4d4d;stroke-width:4.88637638;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:14.39999962;stroke-opacity:1;stroke-dasharray:none" />     <path        d="m 108.72001,383.78792 176.17548,0"        id="path3921"        style="fill:none;stroke:#4d4d4d;stroke-width:4.88637638;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:14.39999962;stroke-opacity:1;stroke-dasharray:none" />     <path        d="m 108.72001,453.5933 36.56472,0"        id="path3923"        style="fill:none;stroke:#4d4d4d;stroke-width:4.88637638;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:14.39999962;stroke-opacity:1;stroke-dasharray:none" />     <path        d="m 248.33076,453.5933 36.56471,0"        id="path3925"        style="fill:none;stroke:#4d4d4d;stroke-width:4.88637638;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:14.39999962;stroke-opacity:1;stroke-dasharray:none" />     <path        d="m 387.94154,383.78792 49.86092,34.90269 -49.86096,34.90269"        id="path3927"        style="fill:none;stroke:#4d4d4d;stroke-width:4.88637638;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:14.39999962;stroke-opacity:1;stroke-dasharray:none" />     <rect        width="103.04603"        height="48.198948"        x="5.6739798"        y="359.68845"        id="rect3846"        style="fill:#cccccc;fill-opacity:1;stroke:none" />     <text        x="30.220692"        y="369.74966"        id="text3848"        xml:space="preserve"        style="font-size:10.17995071px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana"><tspan          x="30.220692"          y="369.74966"          id="tspan3850"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">Accelerometer</tspan></text>     <rect        width="103.04603"        height="48.198948"        x="5.6739798"        y="429.49384"        id="rect3852"        style="fill:#cccccc;fill-opacity:1;stroke:none" />     <text        x="50.953392"        y="439.3761"        id="text3854"        xml:space="preserve"        style="font-size:10.17995071px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana"><tspan          x="50.953392"          y="439.3761"          id="tspan3856"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">Gyroscope</tspan></text>     <rect        width="103.04603"        height="48.198948"        x="284.89548"        y="359.68845"        id="rect3858"        style="fill:#cccccc;fill-opacity:1;stroke:none" />     <text        x="337.785"        y="369.43652"        id="text3860"        xml:space="preserve"        style="font-size:10.17995071px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana"><tspan          x="337.785"          y="369.43652"          id="tspan3862"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">Low Pass </tspan><tspan          x="337.785"          y="382.16147"          id="tspan3896"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">filter</tspan></text>     <rect        width="103.04603"        height="48.198948"        x="145.28473"        y="429.49384"        id="rect3864"        style="fill:#cccccc;fill-opacity:1;stroke:none" />     <text        x="188.74985"        y="439.55505"        id="text3866"        xml:space="preserve"        style="font-size:10.17995071px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana"><tspan          x="186.74985"          y="439.55505"          id="tspan3868"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">Integration</tspan></text>     <       transform="matrix(0.16581277,0,0,0.16581277,337.30328,349.24206)"        id="layer1-0">       <path          d="m -240.65258,203.78557 c 0,0 28.57143,-61.42858 62.14286,0 33.57143,61.42856 61.42857,-1.07143 61.42857,-1.07143"          id="path2876"          style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m -191.24442,216.2328 21.41119,-21.68926"          id="path2878"          style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m -240.0424,249.87743 c 0,0 28.57143,-61.42856 62.14286,0 33.57143,61.42857 61.42857,-1.07143 61.42857,-1.07143"          id="path2876-0"          style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <rect          width="185.74904"          height="185.1929"          x="-271.0358"          y="132.19884"          id="rect2911"          style="opacity:0;fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />       <rect          width="185.59811"          height="184.48582"          x="-269.84805"          y="135.61113"          id="rect3707"          style="fill:none;stroke:#000000;stroke-width:3;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     </g>     <text        x="156.22107"        y="463.87433"        id="text3898"        xml:space="preserve"        style="font-size:23.26845932px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><tspan          x="156.22107"          y="463.87433"          id="tspan3900">∫</tspan></text>     <rect        width="103.04603"        height="48.198948"        x="284.89548"        y="429.49384"        id="rect3902"        style="fill:#cccccc;fill-opacity:1;stroke:none" />     <text        x="334.4248"        y="439.55505"        id="text3904"        xml:space="preserve"        style="font-size:10.17995071px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana"><tspan          x="334.4248"          y="439.55505"          id="tspan3906"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">High Pass </tspan><tspan          x="334.4248"          y="452.28"          id="tspan3908"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">filter</tspan></text>     <       transform="matrix(0.16581277,0,0,0.16581277,337.30328,419.04744)"        id="g3910">       <path          d="m -240.65258,203.78557 c 0,0 28.57143,-61.42858 62.14286,0 33.57143,61.42856 61.42857,-1.07143 61.42857,-1.07143"          id="path3912"          style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m -191.24442,251.31525 21.41119,-21.68926"          id="path3914"          style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m -240.0424,249.87743 c 0,0 28.57143,-61.42856 62.14286,0 33.57143,61.42857 61.42857,-1.07143 61.42857,-1.07143"          id="path3916"          style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <rect          width="185.74904"          height="185.1929"          x="-271.0358"          y="132.19884"          id="rect3918"          style="opacity:0;fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />       <rect          width="185.59811"          height="184.48582"          x="-269.84805"          y="135.61113"          id="rect3920"          style="fill:none;stroke:#000000;stroke-width:3;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     </g>     <rect        width="103.04603"        height="48.198948"        x="412.87201"        y="394.59113"        id="rect3922"        style="fill:#cccccc;fill-opacity:1;stroke:none" />     <text        x="466.86002"        y="404.65234"        id="text3924"        xml:space="preserve"        style="font-size:10.17995071px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Verdana;-inkscape-font-specification:Verdana"><tspan          x="466.86002"          y="404.65234"          id="tspan3928"          style="font-size:10.17995071px;font-family:Verdana;-inkscape-font-specification:Verdana">Combine</tspan></text>     <flowRoot        id="flowRoot3942"        xml:space="preserve"        style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><flowRegion          id="flowRegion3944"><rect            width="94.285713"            height="40"            x="747.14288"            y="425.21933"            id="rect3946" /></flowRegion><flowPara          id="flowPara3948" /></flowRoot>    <text        x="420.707"        y="431.54776"        id="text3952"        xml:space="preserve"        style="font-size:23.26845932px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><tspan          x="420.707"          y="431.54776"          id="tspan3954">Σ</tspan></text>     <       transform="matrix(0.58171148,0,0,0.58171148,-109.87336,156.35335)"        id="g5258">       <path          d="m 226.09628,377.95972 0,26.87761 -17.40435,17.40435"          id="path3956"          style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-start:url(#Arrow1Sstart);marker-end:url(#Arrow1Send)" />       <path          d="m 226.09628,404.83733 19.94003,0"          id="path3958"          style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#marker4426)" />     </g>     <       transform="matrix(0.58171148,0,0,0.58171148,-109.87336,226.15873)"        id="g5262">       <path          d="m 226.09628,377.95972 0,26.87761 -17.40435,17.40435"          id="path5264"          style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m 226.09628,404.83733 19.94003,0"          id="path5266"          style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m 49.498464,544.37244 a 7.8571429,7.8571429 0 1 1 11.327453,-1.09071"          transform="matrix(0.25389083,0,0,0.54292706,222.81255,112.75886)"          id="path5450"          style="fill:none;stroke:#000000;stroke-width:4.0401454;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m 49.498464,544.37244 a 7.8571429,7.8571429 0 1 1 11.327453,-1.09071"          transform="matrix(-0.54292706,0,0,0.28892633,255.60056,238.91937)"          id="path5532"          style="fill:none;stroke:#000000;stroke-width:3.78727603;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />       <path          d="m 49.498464,544.37244 a 7.8571429,7.8571429 0 1 1 11.327453,-1.09071"          transform="matrix(-0.42533914,-0.33742615,-0.17956611,0.22635025,338.77061,308.08723)"          id="path5534"          style="fill:none;stroke:#000000;stroke-width:3.78727603;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />     </g>     <text        x="539.45557"        y="411.70383"        id="text3942"        xml:space="preserve"        style="font-size:23.26845932px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:sans-serif"><tspan          x="539.45557"          y="411.70383"          id="tspan3944"          style="font-size:14.5427866px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Verdana;-inkscape-font-specification:Verdana">Angle</tspan></text>   </g> </svg> 
 +</html>
 +
 +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]]