Results 1 to 4 of 4

Thread: Squarks Blog - DIY Arduino Due controller

  1. #1
    Join Date
    Nov 2013

    Squarks Blog - DIY Arduino Due controller

    Just thought Iíd make a post detailing a flight control board Iíve built around the Arduino Due.

    The reason I went with the Arduino Due is the 32-bit processor, far superior to the Arduino Mega. I believe the Due has a similar chip to the Pixhawk? Itís pretty powerful. I am able to run the control loop at 150hz.

    So here are the components I am using on my TBS Disco quad. Not all of these pieces are required, on my smaller 330 quad I have left out the GPS and telemetry radio and some other pieces which makes it much cheaper:
    Main Components:
    Arduino Due ($50 from sparkfun)
    9DOF IMU ($35 from HK)
    BMP085 pressure sensor ($10 from HK)
    GPS ($50 from sparkfun)
    Connectors/pins ($20 from random)
    Resistors and capacitors ($5 radioshack)
    Logic level converter ($2 from sparkfun)
    12v voltage regulator ($2 radioshack)
    LEDs and buzzer ($3 radioshack)
    Custom Due Shield ($40 for 3 boards from OSHpark)
    FTDI 3.3v ($15 from sparkfun)
    Current sensor ($20 from HK I think)

    Other specific to my quad setup (optional):
    Minimosd ($20 from HK)
    Arduino Pro Mini for Spektrum ďRSSIĒ decoding ($10 from HK)
    900mhz telemetry radio ($100)
    Micro sd card breakout board, for onboard data logging ($10 from sparkfun)

    Total: ~$225 (main controller) + $140 (telemetry, rssi, and OSD)

    Here is a picture of it mostly installed with the top plate off

    Click image for larger version. 

Name:	IMG_1493.jpg 
Views:	325 
Size:	270.5 KB 
ID:	38288

    Here's just the Arduino Due + Shield with everything unconnected:

    Click image for larger version. 

Name:	IMG_1494.JPG 
Views:	288 
Size:	142.5 KB 
ID:	38290

    Hereís a diagram outlining the wiring of all the components, sorry for ms paintÖ

    Click image for larger version. 

Name:	Arduino_connections.jpg 
Views:	1125 
Size:	242.6 KB 
ID:	38291

    So there are tons of connections to the Arduino Due so I built a custom shield. It also handles all the voltage dividers to step down 5v signals to 3.3v, and the step up from 3.3v to 5v. There's also a 12v voltage regulator because I use a 4s battery and the voltage regulators on the Arduino are pretty small and heat up bad.
    Click image for larger version. 

Name:	large_i.png 
Views:	308 
Size:	203.1 KB 
ID:	38292

    Software Description:
    So there are 4 chips I have programmed:
    1. Arduino Nano RSSI decoder - The spectrum receiver outputs data over serial at 115200 baud and gives frame loss and fades which isnít really RSSI but you can sort of mimic an RSSI signal based on the data coming in, from this I output an analog signal 5v=100% and 0v = 0%. Actually its a PWM signal so I low pass filter it to get the true analog 5 to 0v signal, then step that down to 3.3v logic.
    2. For the IMU ATmega328 chip it is just a data pass through, data in on I2C, data out over Serial, allows for some oversampling and filtering.
    3. For the minimOSD I just deleted the mavlink code, put in my own binary protocol, and added some extra small display features, mostly for debugging things.
    4. Arduino Due, main flight control software.

    Main Flight control software features:
    - Receiver signals are on interrupts to read the PPM signals
    - IMU sensor data is calibrated and then sent to an Extended Kalman filter to calculate the current quaternions, position, velocity, gyro scale and bias errors.
    - PID control laws
    - Stick shaping using a linear-polynomial blend (linear near 0, quadratic near max throw)
    - GPS data at 1Hz
    - Pressure altitude at 15Hz
    - Flap switch down triggers RTH (not complete, still working on this), receiver fail safe triggers flap down so RTH on loss comm
    - Gear switch is a kill switch. Puts all motors to 0 on an interrupt routine. Anti-flyaway and anti-infinite loop (yes i got stuck in an infinite loop during early testing and my quad crashed and I had to take off my shoe to throw at the props to get them to stop)
    - Outputs data over serial, custom binary protocol, to the TM radio and OSD. Planning to change this to Mavlink in the near future.
    - SD card writer, I have it writing a google earth file of gps position. Also have some other features to log sensor data and control law params for tuning.

    Future plans:
    - Set up a GCS and allow for configuration changing by TM radio (once I get mavlink up and running)
    - Adaptive dynamic inversion control law
    - Add computer vision/object tracking algorithms possibly using a raspberry p.

    Well thatís pretty much where I am at. Itís a constant work in progress. But Iíve got about 30+ hours logged with this controller on my F330 quad which is what I used for most of the testing. Iíve flown it only a couple times on my TBS disco to tune the PID gains. Need to test GPS, telemetry, data logging and the RSSI feature (just finished that today). Also need to work on programming up the return to home and waypoint nav algorithm. My list of things to add seems to always be growing, at a faster pace than I get things completed....

    Anyways, if anyone else is interested in making their own flight controller with an Due I am more than willing to share my code. If there is interest I can host it online somewhere like github. I also have the eagle files for the shield if anyone wants those.

  2. #2
    Join Date
    Dec 2013
    Columbus, Ohio
    I would love to see the code.
    Sounds very interesting.

  3. #3
    Join Date
    Nov 2013
    Here is all of the code:

    Just a note: it's all still development so use at your own risk.

  4. #4
    Join Date
    Jun 2014
    Hi Squark!

    You've done a pretty amazing job there! Thanks for sharing the code with us.

    I'm working on a similar project. Still thinking on the proper architecture to use and I'd like to benefit from your experience through few questions:
    -you said your control loop is 150 Hz which is pquite close to the rate ardupilot reached on an Arduino Mega, why don't you go higher, the Due should have enough horsepower ?
    -as far as I understand your code, you used a RazorImu-like and just extract the raw data without further processing. May I have the reference of the Imu board ? Is 150 Hz the max rate you managed to output from your IMU ? It seems pretty slow since the only job of the 328P is a I2C to Serial gateway. I was expecting to reach 500 Hz (at least for the gyros/acceleros) with a similar config.
    -to put all in a nutshell, my main concern is the stability of the multicopter, is 150 Hz a sufficient rate for a good stability. Do you have any videos of your drone?

    Thanks and congrats again for your work!

Similar Threads

  1. Replies: 88
    Last Post: 25th July 2015, 09:18 AM
  2. Arduino Mega ADK
    By LabRat in forum DIY
    Replies: 0
    Last Post: 5th December 2013, 12:31 PM
  3. headtracker - dominator for arduino
    By gulabgiri in forum Fat Shark R/C Vision Systems
    Replies: 1
    Last Post: 25th April 2013, 08:13 AM
  4. Alientracker V2 for Arduino !
    By Dexterbot in forum DIY
    Replies: 0
    Last Post: 17th January 2013, 06:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts