New IMU Library for Arduino- RTIMULib

Obtaining orientation angles can be a challenge! RTIMULib may make things easier.
Obtaining orientation angles can be a challenge. RTIMULib may make things easier.

My blog traffic shows that a lot of the visitors are looking for information on IMUs (Inertial Measurement Units) like the MPU-6050.  Understanding how to use IMUs and access the data they provide can be daunting.  However, I just came across a new Arduino library for getting IMU data that looks like it will make things simpler.  Written by a company named Richards-Tech, the library is called RTIMULib, and can be found at https://github.com/richards-tech/RTIMULib-Arduino.

What’s incredibly awesome, and more or less unique about this library is that it comes with well-documented sample programs.

Read more

MPU-6050 Redux: DMP Data Fusion vs. Complementary Filter

MPU-6050 on GY521 breakout board.
MPU-6050 on GY521 breakout board.

I’ve been using the GY-521 IMU breakout board containing Invensense’s MPU-6050 IMU to compute orientation in my self-balancing scooter (the “Halfway”). I’d like to improve the scooter’s performance on hills and uneven surfaces.  I thought I’d revisit the fusion algorithm which combines gyroscope and accelerometer data to compute the scooter’s tilt angle.  The initial code for the Halfway used a complementary filter algorithm, explained in an earlier blog post.  Accelerometer data is noisy on short time scales, and gyroscope data drifts on longer timescales, so the complementary filter combines both for greater accuracy.  However, the MPU-6050 contains a digital motion processor (DMP) which can perform the data fusion on the IMU chip iteslf.

Read more

The “Halfway” – A Self-Balancing Scooter

Ready to take the "Halfway" for a test drive. Bike helmet essential for safety.
Ready to test drive the “Halfway”. Bike helmet essential for safety.

This latest project is the longest and most complicated so far.  Over the last several months I’ve been working to put together a Segway-like self-balancing scooter, aka the “Halfway”.  Many people have written up and posted similar projects online.  Google “DIY self balancing scooter” to see some examples.  Other people’s work provided a lot of inspiration and help during the design and execution of the Halfway scooter.  If you’d like to see how it turned out, skip to the end of this blog post for a video of the Halfway in action.

This particular project was appealing to me because it utilized elements from my earlier blog posts, such as obtaining angle data from an IMU and integrating a Wii nunchuck with an Arduino.  I also got to learn some new skills, including welding metal, CAD with Google Sketchup and programming with PID control loops.

Read more

MPU-6050: DMP Data from i2cdevlib

In March, I posted on experimenting with the MPU-6050 IMU chip (mounted in a GY-521 breakout board).  It seems that many people are using the MPU-6050, and I wanted to follow up with some more information, because there are better ways to access and process the combined sensor data than were demonstrated in that post.  The previous experiment compared the raw data from the 3-axis accelerometer and 3-axis gyroscope sensors to the results when the raw data are combined via a complementary filter.

For the comparison, I had adapted a program from the Arduino Playground Wiki on MPU-6050 to pull the raw accelerometer and gyroscope data from the MPU-6050,  The program calculated pitch, roll and yaw (rotation about the X, Y and Z axes, respectively, also knows as Euler Angles).  These calculations were limited by certain properties of both the accelerometer and gyroscope.  Gyroscope data has a tendency to drift with time, and accelerometer data is noisy and makes it difficult to calculate rotations over ranges greater than 180 degrees.

Read more

Gyroscopes and Accelerometers on a Chip

 

The interior of a 3-D MEMS Gyroscope Sensor is intricate and tiny (the width of this structure is only about 800 micrometers).
The interior of a 3-D MEMS Gyroscope Sensor is intricate and tiny (this structure is only about 0.08 cm wide).

My last two blog entries discussed demonstrations of gyroscopes and angular momentum conservation at our school’s science fair. One of the demonstrations I put together takes a look at how really small gyroscopic sensors, such as those in many smart phones, video game remotes or quad-copters provide information about their changing orientations. This information can be used as feedback for self-balancing (e.g. a two-wheeled scooter), navigation or as input to other applications like video games.

I didn’t want to sacrifice my smart phone for this experiment. Fortunately, chips containing gyroscopic sensors are relatively cheap. In reading up on gyroscopic chips, I found that orientation data from gyroscope sensors is prone to drift significantly over time, so gyroscopic sensors are frequently combined with additional sensors, such as accelerometers or magnetometers to correct for this effect. This combination of sensors is frequently referred to as an IMU, or “Inertial Measurement Unit”, and it is used in  airplanes, spacecraft, GPS navigators (for use when GPS signals are unavailable) and other devices.  The number of of sensor inputs in an IMU are referred to as “DOF” (Degrees of Freedom), so a chip with a 3-axis gyroscope and a 3-axis accelerometer would be a 6-DOF IMU.

Read more

Buidling the Anyway NXT Scooter

The "Anyway" in profile
The “Anyway” in profile
The "Anyway" self-balancing scooter -balancing itself.
The “Anyway” self-balancing scooter – balancing itself.

As I mentioned in my last post, my sons’ school had a science fair last week where I ran a demonstration involving angular momentum and gyroscopes.  In researching the use of gyroscopes in engineering today, I found that extremely large gyroscopes, weighing up to hundreds of tons, are used to stabilize ships, and extremely small gyroscopes that operate by vibration are used in electronic circuitry, such as that in smart phones and video game controllers.  One application that many people are familiar with is the use of gyroscopic sensors to stabilize self-balancing two-wheel scooters, like the Segway.

Googling “self-balancing robots” reveals a remarkably large number of homemade robot

Read more

Fun with Angular Momentum

Demonstrating the conservation of angular momentum with a bicycle wheel and rotating stool.
A young experimenter demonstrating conservation of angular momentum with a bicycle wheel and rotating stool.

Last weekend my children’s school had a science fair which they called “STEAM Day”, for Science, Technology, Engineering, Arts and Math. It turned out to be a engaging and dynamic event, with lots of great demonstrations and activities for the children, ranging from kindergarten to 8th grade.

I volunteered to run an activity demonstrating angular momentum conservation, which was titled “You Spin me Round”. Our primary demonstration used a large gyroscope made from a bicycle wheel with two handles, like this one here. I (and my oldest son, who was my assistant) would spin up the bicycle wheel, and carefully hand it to a child who was sitting on a stool that was free to rotate. We then told the child to tilt the bicycle wheel to the right or the left. They were usually surprised to find that the spinning wheel “resisted” this change, and that they would start to rotate in the direction in which they turned the wheel! One tip I would recommend for anybody else trying this experiment – it was tremendously helpful to have work gloves for use in spinning up the bicycle wheel. After several hours, the palm of my hand was bruised and sore!

The children were too young to understand a detailed explanation of angular momentum conservation using torque and angular momentum vectors, 

Read more