Step 26Gyros orientation
NOTE: (March 2011) I have added a lot more on this with photos and video on page 41 as very easy to get this all mixed up in which case your machine just will not balance at all!
Do the soldering properly and carefully, no bodges here otherwise your machine will behave chaotically.
I have also added an IMU testing sketch to check this is set up correctly (see page 41 onwards).
Accelerometer used because will give accurate data on which way is upright (direction of gravity). However it is very sensitive to vibration and we have a lot of that over anything other than smooth flooring.
Gyro gives instant real time data on rate of rotation (i.e. rate of tipping over of our machine), is insensitive to vibration BUT drifts slowly with time.
If you wire up the IMU as I have in the photos then the diagrams on the right will hold true.
The IMU is interesting as the gyros each have 2 output pins with a varying voltage on each. One is relatively insensitive but works up to a rotational speed of 500 degrees per second. The second is more sensitive and works over a range up to 110 degrees per second. The arduino software is therefore written to read the insensive one when tipping fast, but switch to the other higher resolution one when tilting more slowly.
The "complimentary filter" uses best bits of each: the gyro is used to measure very short term changes in tilt and the accelerometer readings are averaged over time to give a stable value of which way is "up." This is then used to correct the drift of the gyro.
If you read around this on the net it is called PID tuning. There is also a very complicated way of doing the maths called a Kalman filter. However an engineer told me that ths is only optimal when you know the control inputs as well (as in an aircraft). In this case the "skateboard" is dumbly just trying to stay upright, it does not know if I am leaning more on one end or the other or how flexible my joints are etc. Therefore he told me the complimentary filter is actually the more appropriate technique to use.
I am not an engineer so I am sure there are some out there who will expand on this or correct me if I am wrong.
Anyway, bottom line is that the complimentary filter works fine. Also, no matter how much modelling people do they all seem to in the end have to fine tune their devices by hand (there are links to many other segway type projects on my website).
| « Previous Step | Download PDFView All Steps | Next Step » |


























































































I actually use 1 gyro and one accel to balance, and the second gyro as a way to detect and then compensate for sudden rapid changes in direction (like one wheel hitting a stone for example).
It is the Sparkfun 5DOF IMU (5 degrees of freedom)
There is also a 6DOF version (3 gyros and 3 accels) but for my needs the 5 DOF one is fine.
Making video of the new pneumatic tyre board at the moment.
Best wishes
John