3D Robotics
Jordi has opened my eyes to the Arduino platform, which is being described as a "Basic Stamp killer". Is it a good candidate for autopilots? Well, let's look closer. Arduino is an open source embedded processor platform, based on the ATMega168 CPU, which has more memory than the Stamp and is a lot cheaper. There's proper development software available and SparkFun has a full line of dev boards and other accessories. Its programming language looks like C but should be easy enough to learn for people who know Basic. It started as an Italian project (it's named after an Italian king) and still has a European flavor, so that may explain why we in the US don't know it well. But Jordi, in Mexico, had done some very interesting work in exploring its potential as an autopilot platform. His main project is the "Arducopter" (shown at right), which has resulted in some very nice code, such as this navigation routine. In his comments, Jordi (BTW, he's just 21) described some of the cool things he's doing with it, which I'll simply quote with links here: "This is my first test with Boarduino (a breadboardable version of Arduino) controlling servos and using an accelerometer from a Nintendo Wii. Right now I'm using Gyros and Kalman filters. I even wrote code to read PMM signals, the GPS is finished and working pretty well, the IMU is in beta, and I'm developing an altimeter using I2C technology and high quality pressure sensors." Here are some links he provided: I'm intrigued. I don't see anything here we can't do with Basic Stamps with a little fiddling, but I have to admit that certain projects look like they would be easier with the Arduino, mostly thanks to its greater memory and full range of variable types, including floating point. Anybody else looking seriously at Arduino?
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Developer
    Ok to control servos is very easy, you can use any digital PIN to generate a PWM, you moust put the pin high between 500 (full left) to 2500 (full right) microseconds, you must pulse every 20 miliseconds, here is an example:

    // pulse the servo again if rhe refresh time (20 ms) have passed:
    if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH); // Turn the motor on
    delayMicroseconds(nowPulse); // Length of the pulse sets the motor position
    digitalWrite(servoPin, LOW); // Turn the motor off
    lastPulse = millis(); // save the time of the last pulse

    I used this code to control servos in the arducopter, here is the full example and code for pulse servos:

    Actually i wrote a better version to pulse 13 servos at the same time and consume the same cpu power as pulse only one (i used a parallel pulse trick), but i lost the code.... =)

    If you want to read or generate a PPM (Pulse position modulation), this include all the servos position in one single signal... If you want to learn more about PPM enter here:

    OK i wrote a code to read PPM signals coming from a buddy cable or you can hack your RC receiver to read it (just works in futabas and walkeras):

    If you need help to intercept PPM signals from your receiver, read this:

    Anyway i don't going to use it in my final version...

    And here is a good exampe to generate PPM:

    BTW, is not useless, because you need a lot of power to process the IMU data and other stuff.

    Nice day, and good luck
  • I read at least one good paper on driving servos with the Arduino and they are driven by the digital out pins. It said the PWM pins on the Arduino were basically useless for driving servos because the frequency they ran at was too high.

    So is that what you guys are all doing, driving servos off the digital out pins in software?

    What about reading PWM from the Rx, is it done the same way with digital ins?
  • If you re going to use a separate board to control servos then I agree that it is irrelevant to the platform choice. Its is another part to add but if it keeps the overall cost and complexity down (because you don't need a faster controller) then its certainly a win.

    One of my goals is for this to be easy for others to tinker with so I would like the source to be easy to understand. Using the Wiring platform and language makes it a lot more accessible.

    I though that the PWM outputs on the Arduino and Wiring were driven in hardware? I.E. you set the PWM width and they keep doing that for you. I thought the real CPU hog was going to be reading the channels from the receiver since you basically have to build your own PWM decoder in software.

    I'm looking at Servo.cpp from the Wiring examples but not totally clear to me yet.

    So how is all that actually accomplished?
  • 3D Robotics
    Jordi makes a good point: it's really inefficient to be generating and sending PWM servo commands directly from the CPU. (In fact, I think it's probably impossible to input and output six channels with one of these and still get a reasonable frame rate, to say nothing of actually doing any other processing). That's why we use servo and motor driver chips or miniboards, which are all controlled with a single serial out. So from my perspective, the number of servo outputs is irrelevant in the selection of a processor platform,
  • Developer
    The size, always the size. Actually i was planing to use two boards (dual core), to separate the navigation part from the AutoPilot, if something goes wrong with the navigation the autopilot still flying. The navigation part i was thinking to use a wiring board (includes gps, parse gps data, waypoint navigation, altimeter), and make inside it a small OS to change settings on fly, the autopilot part will be just an arduino (and receive data "ready to use" throw SPI or TWI(i2c)), and in the the hand, arduino will process the IMU (gyros and accelerometers) and control the servos. Another excellent thing about wirings is that the ADC's are 12-bit and not 10-bits like arduino.
    I wrote the last month an email to wiring, to ask were can i buy the mini board, (SparkFun maybe), but never answer me.
    About the servo, we can save a lot of CPU power if we use this:
    Good price and excellent performance. I can control any servo just sending three bytes in serial.
    What is your opinion? =)
  • Looking at Wiring vs. the Arduino. Wiring has more RAM, Flash and IO pins which could be really useful. Also they are about to come out with a 'Wiring Mini' thats even smaller than the Arduino and costs roughly the same. That would be a suitable flight platform. see: http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1203441602

    Near as can tell its almost the same CPU and code from the Arduino should run on Wiring and vis versa. One big thing these platforms have going for them for a micro UAV is that they can read 8 analog inputs and drive 6 servos. The Propeller can only drive 4. Also the tool chain is mature, you can code in Wiring or C and have things compiled and run fast.

    Is there a good reason to use the Arduino over Wiring, aside from Cost?
    Wiring Forum - System Information
    Wiring is an electronic sketchbook and hardware electronics for developing ideas. It is a context for learning fundamentals of computer programm…
  • The Arduino was the route I was thinking about using. I am also contemplating a python interface via gumstix, and realtime linux. We'll see how it goes, but for basic nav, the arduino should run just fine.
  • Chris,

    I'll have to look into the newer Stamp hardware, especially since I've gotten familiar with coding for the platform. That said, the cost of the Arduino is pretty compelling.

    If more power and memory is needed, I was thinking the best thing might be to use an embedded Linux computer like the gumstix for the main program logic and just offloading the sensor input ppm servo output to a Stamp or Arduino.
  • Developer
    Your can make arduino serial run at 57600pbs or less, like 9600, 4800 etc, with UART. There is a library to use any pin for serial com (max 9600bps). Arduino also supports I2C (TWI) and SPI communication. I love I2c (Two Wire Communication) is the same used by Wii accelerometer, and you can attach 128 devices in the same bus (2 wires) running at 40mhz, and requesting data only when you need it :), there is a lot of i2c hardware, including gps and ADC's with 16bit of resolution.
  • 3D Robotics

    I think Basic Stamps have improved since then. We're using the BS2p, which is 3x faster than the BS2, and all of our serial at 4800 and 9600 is rock solid. If need be, we can move to the BS2px, which is 5x faster than the BS2.

    That said, the limited memory (especially the variable space) is still a problem and requires some clever coding, using multiple program slots, scratchpad RAM, and reading and writing to EEPROM memory. I'll be interested to work with Arduino to see how that compares in this respect.
This reply was deleted.