Step 10: Firmware

Picture of Firmware
The core files are derived from Zigduino's core files, which are mostly just minor additions to the original Arduino core files for use with the ATmega128RFA1. I made some modifications regarding the activation of the 2nd UART on the ATmega128RFA1.

During the planning stages of this project, I purchased two Zigduinos as a test platform for code involving the radio transceivers of the ATmega128RFA1. I decided I needed a high performance radio code, with maximal data rate, minimal latency, and minimal overhead. I chose to dig into uracoli, which is a free and open source library that supports many radio transceivers including the ATmega128RFA1, and developed the ZigduinoRadio library for Arduino. Then from there, I increased the performance even further and developed the PicopterRadio library specifically for this project.

PicopterRadio is designed to quickly replace traditional RC signal inputs. Instead of having a microcontroller read pulse widths using pins, PicopterRadio delivers data that represents what would have been measured directly in a digital fashion. This makes it faster and more accurate.

The ATmega128RFA1 also has a built-in random number generator (not psuedo random, this is true random good enough for cryptography) which I used to allow a random frequency to be generated and used by both the quadcopter and transmitter. The user connects these two pieces together and press a button, a frequency will be randomly selected and both units will switch to the new random frequency.

There are 16 available frequencies possible on the ATmega128RFA1 but I found some of them to be unreliable, at least in my house (with Wifi and cordless phones everywhere). So I've limited the number down to the few that I know works.

PicopterWiiClassicCtrler is a library I wrote to read the Wii Classic Controller using twi.c and twi.h (originally from the "Wire" Arduino library). It features detecting disconnections and automatic calibration.

My other quadcopter used AeroQuad flight software, which is free and open source, written with Arduino. I tried to port that code to the ATmega128RFA1. When I finished and decided to test it using the configurator, I had some wonky results. Tried fixing it, didn't have much luck. I then tried to port over MultiWii's code, which is also free and open source and Arduino, except it's more C style, instead of AeroQuad's C++ OOP style. The port is surprisingly successful. The GUI utility for MultiWii is written in so it's just Java. while AeroQuads GUI utility is a huge LabView application. MultiWii is superiour in terms of how the software is written, but I heard AeroQuad's code might be better in terms of how stable the quadcopter flies But in the end, I'm using MultiWii because my port is working.

I customized MultiWii's code, mainly to add in my libraries, and to change some functions to using buttons instead of joystick action combinations. The orientation of the sensors does not match what the code expected, so I had to make a small edit that changed the orientation. The PWM output's range was not designed for MOSFET controlled DC motors so I had to make a small math adjustment for the PWM duty cycle.

"Version 2" added a MPU-6000, which is relatively new on the market, I had to add in some custom code for this sensor myself, where as the ITG-3200 and BMA180 was already supported in the original MultiWii code. The MPU-60x0 chip is very similar to the ITG-3200, so most of the initialization parameters stayed the same.

I also cut out a lot of irrelevant code so it's easier for me to read. MultiWii supports a lot of difference sensors and input methods, I deleted the stuff that is not what I am using.

Because MultiWii is written in a much more efficient way than AeroQuad, I was able to make the quadcopter wirelessly configurable by redirecting serial port data to the radio instead. So the user can plug in the transmitter to the computer instead of plugging in the quadcopter itself.

The bootloader is adapted from the original Arduino bootloader. The "ISP mode" is implemented by modifying the "ArduinoISP" sketch.
Remove these adsRemove these ads by Signing Up

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!