Getting the autopilot to co-operate

A project log for Swarm

A flying, distributed wireless mesh network. What could possibly go wrong?

cb22cb22 05/04/2014 at 18:290 Comments

I could just have gone and bought a complete APM system, but at a few hundred dollars, plus expensive shipping, I decided to go for a decidedly more budget route for the first autopilot system.

Take a Cheap Arduino clone and add a Chinese 10-DOF board, and you get a cheap (~$50 total) platform that can run the ArduPilot code. Well, sorta. While the BMP085 and HMC5883L on the sensor board were both well supported, the IMU - a MPU6050 was not. At first glance I thought it was, as the ArduPilot code has a driver for the MPU6000, with the difference being that it drives the 6000 in SPI mode whereas the 6050 is I2C only.

 I contemplated writing an I2C driver for the chip - but some searching revealed that this had already been taken care of. The MegaPirateNG project has extended the ArduPilot code to support a greater variety of boards, including quite a few of the cheap HobbyKing ones. Once the code was compiled and loaded on to the  board, it was time to hook up the sensors.

Or it would have been, if the Arduino clone ran off 3V3 or the sensors were 5V tolerant. Unfortunately neither of these are the case, and so getting it to work involved a bit of modification to the Arduino clone itself. In I2C, the bus is not driven high, instead pull-up resistors are used, and the bus is driven low.

This makes level shifting fairly easy, since you can just tie the pull-ups to the lowest voltage you need to support, and provided it is still higher than the threshold for a logic level 1, things will work. Usually the Arduinos use the AVR's built in pull-ups to do this, but for some reason the Arduino Mega has extra 10k pullup resistors. I cut the trace to these, and added in some external pull-ups to 3V3.

The rest was fairly straightforward. The channels from the radio receiver connect to the analogue input pins, and the PWM output pins are the output from the autopilot. It was a nice change not having to deal with and decipher a complicated pin mapping scheme, like on the Beaglebone Black or STM32s.

Flying environments tend to be a bit inconducive towards breadboards, unfortunately.