MMU 6050 6 axis / 6 DOF gyro and accelerometer interrupt & data summary

The most excellent Xincehjian maker Edward introduced me to the also excellent MMU 6050 that has a 3 axis gyro and a 3 axis accelerometer and in addition has a bucket load of on-board digital motion processing (DMP) to give a huge range of 6 axis (DOF) outputs as well as motion, free fall, tap and shake detection. Amazingly, in China, you can buy it on a break out board for about $4 and get it delivered for another $1, a day or so later.

A popular library for this chip, seems to be the I2cDev library from Jeff Rowberg which not only provides access to this chip, but a HOST of other sensors AND it also provides a generic I2C lib (hence the name I2Cdev) that can and has been ported to many different host processors!

But wait there’s more, the I2cDev library offers a choice of several underlying I2C libaries, and even when using the default Arduino Wire library to provide the I2C, the common blocking – hanging issues that seem to plague many people when using the Arduino Wire library for I2C, have been resolved! I can now run I2C code for many hours, even overnight, instead of previous seconds or rare minutes!

So, I am really stoked, because the MMU 6050 delivers a lot of features that I really want to use (see Assistive devices) and those Wire I2C issues have caused me a lot of grief over the last 2 years as I tried to use several different sensors and motor controllers and even recently when I tried several different libraries, that others have created to get past these issues!

click for the A3 page of information
Screenshot of MMU 6050 interrupts & data summary

 

But wait there’s still more, there is also the freeIMU library, which I have been using successfully. It sits on top of the I2cDev library and provides additional features.

The last “But wait there’s more” is that as part of trying to get my head around all, well so far some of the above (tap, shake and motion detection), I delved into the documentation and code and summarised my understanding of interrupt configuration, interrupt status, raw data access and access to the DMP data. The document is still a work in progress, so please add comments to this post or contact me with updates and corrections!

SwarmRobot InfraRed remote control

The video shows three SwarmRobots being controlled by one InfraRed signal – sorry for the poor video quality.

Looking at ways to have some sort of SwarmRobot display for MakerCarnival in Shanghai in early November, found this AtTiny 2313 code which can decode RC5 IR. It compiled, loaded and ran (verified looking at serial data output), but it did not detect IR from several different remote controls tried.

Using this Arduino code, (which uses some really nice multi-protocol IR receive and transmit libraries) it was discovered that all the remote controls used where NEC protocol, not RC5! Research indicates the NEC protocol is very common in Asia!

Rather than find NEC code for the AtTiny, or write code decode NEC, I used the above library to send RC5 and now a SwarmRobot can receive commands and as the shows, several SwarmRobots can be controlled at the same time! Kept using RC5 because it actually sends two sets of information an ID and a command, so this really fits controlling robot X to do command Y, or group z of robots to all do same command.

The code is on GitHub: SwarmRobot AtTiny2313 and the Arduino transmitter.

SwarmRobot infrared object avoidance video

Success:- Using one InfraRed transmitter LED and four receiver LEDs for 360 degree object avoidance. The program logic is very simple at present.

Unfortunately the setup is not yet reliable – works one day but not the next and there are still some initialisation issues.

Biggest issue seems to be that there are huge variations in the functionality of IR receiver LEDs and we have not found matching data sheets for the two types we are using!

HY-SRF05 Ultrasonic Sensor for autonomous robot

Continuing the autonomous robot sensor theme with some updated sample code for the HY-SRF05 Ultrasonic Sensor that significantly reduces the blocking (delays in program execution where NO code is run!).

Once again, the code is placed on the Wiki as part of the move to help create re-usable community content.

Honeywell HMC5883L compass sensor for autonomous robot

One big part of my ‘relaxation’ project – ‘building’ an autonomous maze solving car is the sensors.

Installation of the four ultrasonic sensor and experimental avoidance code has shown (again) just how bad I am at visualising in 2 & 3D space. My simple avoidance logic attempts always end up avoiding big objects, but then get stuck in a tight loop “go forward” – “avoid = go back” – “go forward”.

So I thought it was time to add the Honeywell HMC5883L compass sensor (part of Christmas present to self). The sample code ran up easily (once converted all the wire-I2C commands to Arduino v1.0), so I ported the code into my code. Weeks later after umpteen different project sidetracks I noticed that the output from the compass was not linear and very different if you rotated clockwise or anticlockwise!

After lots of web searching and help from others with this sensor, I have now started to get more sensible output. While this work is not fully complete, it is a big improvement over the standard sample code that is commonly found, so I thought I better start publishing before I loose momentum on this.

Details are on the wiki, and I also updated the SeeedStudio site sample code on their wiki. The main point to note is that it takes some effort to calibrate, but hopefully the sample code provided helps simplify the tasks.