Saturday, 18 January 2014

Raspberry Pi Flight Controller Part 1 : Inputs and Outputs via GPIO

I'm now focused on my next mission: turning the Raspberry Pi into a quadcopter flight controller (this has already been done by many people, but I'd like to try it myself for the fun of it). If sucessfull, I'll be able to get rid of the good old KK board.

The first step is to handle the I/O, namely:
  • getting inputs from an IMU (gyroscope, accelerometer and more...)
  • sending output PWM signals to the ESCs/motors

In the past, I managed to do both using USB modules (a Phidget Spatial as an IMU and a Pololu Maestro as a PWM generator). Now I'd like to get rid of these too and do everything using the Raspberry Pi GPIO.

For the IMU part, I bought a Drotek IMU 10DOF V2. This I²C board has the following components:
  • MPU6050 gyroscope and accelerometer
  • HMC5883 magnetometer
  • MS5611-01BA barometer/temperature sensor
For only 20 euro-bucks, that's a bargain!

The code I wrote to support these components is using Jeff Rowberg's excellent I2C Device Library. This lib is originally for Arduino but someone ported the I2C communication code to the Raspberry Pi. In theory all the devices supported by the I2C Device Library should work on the Pi with minimum effort!

For the PWM part, the Raspberry Pi can generate PWM signal in hardware without any problem. I used the C code from the also excellent RPIO.PWM library.

I've wrapped all this code in my own hardware abstraction library called Piha. This allows me, for example, to swap PWM generation from GPIO to Pololu Maestro in pretty much one line of code. Piha has it's own user-interface to display recognized devices and play with them. It now supports quite a wide variety of devices/components/APIs, I shall present it in another post someday.

Here are some pictures of the set up. Only one ESC is connected to the GPIO for now.

And here it is live!

1 comment:

  1. This article is a logical clarification of how an investigation being led, already innovatively outlandish, will have the capacity to test Einstein's most prominent accomplishment, his General Theory of Relativity. Gyroscope component