0% found this document useful (0 votes)
122 views

Simple Arduino Robotics Platform PDF

This document describes a simple robotics platform built using an Arduino board. The platform uses an Arduino to control motors from a Vex robotics kit to drive a robot base. It can also control additional components like an LED and fan. The author details the parts used, including the Arduino board, Vex robotics kit, battery, breadboard, and MAX232 serial converter. Programming details allow controlling the robot and components via a connected PC or eventually a wireless netbook for remote control with a video feed.

Uploaded by

Henrique Yu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Simple Arduino Robotics Platform PDF

This document describes a simple robotics platform built using an Arduino board. The platform uses an Arduino to control motors from a Vex robotics kit to drive a robot base. It can also control additional components like an LED and fan. The author details the parts used, including the Arduino board, Vex robotics kit, battery, breadboard, and MAX232 serial converter. Programming details allow controlling the robot and components via a connected PC or eventually a wireless netbook for remote control with a video feed.

Uploaded by

Henrique Yu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Home Sign Up!

Browse Community Submit


All Art Craft Food Games Green Home Kids Life Music Offbeat Outdoors Pets Photo Ride Science Tech

Simple Arduino Robotics Platform!


by CalcProgrammer1 on October 12, 2009

Table of Contents

Simple Arduino Robotics Platform! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Simple Arduino Robotics Platform! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: What it can do... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3: Arduino and PC Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 4: Add a Netbook to explore unknown worlds from a distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 5: Get a Video Feed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

http://www.instructables.com/id/Simple-Arduino-Robotics-Platform/
Author:CalcProgrammer1
I'm attending Missouri University of Science and Technology for Computer Engineering. I like working with electronics, and I'll post instructions on projects. I
also like the Nintendo Wii and the Xbox 360, but not the stupid PS3.

Intro: Simple Arduino Robotics Platform!


I just got an Arduino after playing around with some AVR microcontrollers during Robotics team meetings. I liked the idea of a really cheap programmable chip that could
run just about anything from a simple computer interface so I got an Arduino because it already has a nice board and USB interface. For my first Arduino project, I dug
up a Vex Robotics kit I had laying around from some competitions I did in high school. I had always wanted to make a computer driven robotics platform but the Vex
microcontroller requires a programming cable that I didn't have. I decided to use my new Arduino (and maybe later a bare AVR chip if I get it working) to drive the
platform. Eventually I want to get a netbook and then I can drive the robot using WiFi and view its webcam remotely.

I managed to get a decent serial protocol and a simple example that drives the robot using an Xbox 360 controller connected to a Linux PC.

Image Notes Image Notes


1. Arduino 1. Vex microcontroller, needs expensive custom programming cord and
2. Breadboard software...but the Arduino does more and is cheaper!
3. Vex Robotics base 2. R/F Radio Control interface for Vex kit, if I figure out the protocol I could use the
Arduino to read this input as well.

Step 1: What it can do...


The Arduino is a very versatile platform. My basic goal was just to get the Arduino to interface two Vex motors to the PC, but I had a lot of leftover input/output pins and
decided to add some extra stuff. Right now I have an RGB LED for serial port status (green if packets are good, red if they are bad) and a PC fan driven by a transistor.
I can also add switches and sensors but I didn't put any of those on it yet.

The best thing about it is that you can add whatever you want to an Arduino robot. It only takes a little bit of interface code to control extra stuff and get input to the
computer.

Image Notes Image Notes


1. With a computer, you can drive the robot using any input device you want. 1. RGB Status LED shows if serial communication has errors
The Xbox 360 controller is easy to interface with Linux and is a good robot 2. The motors connect here. The white wire is the 5V pwm signal, black is
driving device. ground, and orange is +12V from the battery.

http://www.instructables.com/id/Simple-Arduino-Robotics-Platform/
2. RS232-TTL converter based on MAX232 chip. My old laptop only has one 3. Transistor and resistor connect a rear-mounted PC fan to the Arduino as an
USB port so I had to interface the Arduino through serial so I could use the Xbox example of other devices that you can control using a PC and an Arduino.
controller. 4. A bunch of resistors in series protect the RGB LED. I didn't have any single
3. You can use almost anything to power your robot. I was charging the battery I resistors large enough so I just hooked all the extra small ones I had together.
normally use so I just plugged it in to a 9V adapter. 5. 12 volt rail from power (battery)
6. regulated 5 volt rail from Arduino

Step 2: Parts
For my robot, I used a few different parts. Most of the parts were from old stuff I had laying around my basement.

1) Arduino Duemilanove w/ ATMega328

This is the newest Arduino, and since I just got it a few days ago I have the newest one. However, the code is small enough that it should easily fit on any Arduino. It
could probably even fit on an ATTiny (if I build a robot controller apart from the Arduino, the ATTiny 2313 looks like a good choice, it's smaller and cheaper but still has
plenty of outputs and a serial UART interface)

2) Vex Robotics Platform

I got a Vex kit a few years ago to build a radio-controlled robot to pick up stuff for a high school competition. I constructed the basic "square bot" base that has 4 wheels
driven by two motors. You could substitute other robot bases if you have some other platform you want to drive. The important thing to note is that Vex motors are
essentially continuous rotation servos, they use pulse-width modulation to signal how fast and in what direction to turn. The Vex motors are nice because they have a
high range of operating voltages, somewhere between like 5 to 15 volts. I'm using 12V because I had a 12V battery. For most standard hobby servos, you'll need a
lower voltage (often 6 volts).

3) Battery

A robot is useless without a power supply. For testing I use a standard 9V wall-wart adapter from RadioShack, but for cordless operation I found a 12V NiMH battery
pack in an ancient laptop. Although it doesn't hold enough of a charge to run the laptop it drives my Vex robot just fine. It can also power the Arduino using the Vin input
pin on the power connector, the Arduino will regulate the 12V down to 5 and even output it out the 5V output pin on the power connector.

4) Basic Breadboard

I'm currently using a breadboard to wire everything up. Eventually I'll get a nicer prototyping board and solder on some more permanent connections but for now the
breadboard makes it easy to change things. My breadboard is SparkFun's "basic breadboard", just a breadboard on a metal plate with 3 terminals.

5) MAX232-based RS232-TTL converter

If you want to drive your robot using an RS-232 serial port connection (as opposed to the Arduino's built in USB) you can use an RS232-TTL converter. I'm using a
MAX232 because I had a few of them lying around and I soldered it on a little piece of prototyping board with the required capacitors. I need RS-232 because my old
laptop only has one USB port and I'm using that for a game controller to drive the robot.

6) Extra parts as desired

For easy debugging of the serial protocol, I put an RGB LED on it (got one with my Arduino order cause they sounded cool). The light flashes red, green, blue in
sequence when the Arduino boots up to show the robot has rebooted and then lights up Green when a motor packet has been received, Blue when a fan packet has
been received, and Red when a bad or unknown packet has been received. To drive the fan I used a standard NPN transistor (the same ones I demonstrated in my last
Instructable) and a resistor in between the transistor and the Arduino (the transistor was drawing too much current and heating up the Arduino, so I put a limiting resistor
in to stop it).

Image Notes Image Notes


1. Battery from 1997 laptop. I tore it apart but taped the case back together with 1. It's an Arduino...
blue tape. It's fairly safe since it's NiMH and I just recharge it using a 16V wall 2. Twist-ties are good for holding things to the Vex platform. They are solid but
wart adapter. Don't try this with Lithium (Li-Ion or Li-Poly) batteries. easily removable.
2. Vex Motor 3. With the Arduino powered from a battery and interfaced by serial, neither of
3. PC fan these connectors are needed.
4. Free MAX232 and the box they came in. 4. +5V out to breadboard, Ground, +12V in from battery
5. RGB LED, Serial port
6. Vex Motors on PWM ports
7. Red wire goes to transistor, controls fan.

http://www.instructables.com/id/Simple-Arduino-Robotics-Platform/
Image Notes
1. MAX232 Serial RS232 to TTL converter board. I got the MAX232 IC's free from
samples and threw it on a board with some capacitors and wires. This can be
used instead of USB to control the Arduino.

Step 3: Arduino and PC Programming


To program the Arduino, you'll obviously need the Arduino software and a USB cable. You can also program the Arduino using a serial port and a TTL level converter if
your PC has a serial port. Note that the USB serial interface will not communicate with the Arduino's ATMega processor if there is a level converter connected to
Arduino's serial pins (pins 0 and 1) so disconnect it before using USB.

On the Arduino we will need a serial interface that allows the PC to control the motors. We will also need a PWM servo drive system to send the correct signals to the
Vex motors and make sure they go in the correct directions when given the right values. I also added some simple LED flashing, mainly for status indication but also
because it looks cool.

On the PC we will need to open the serial port and send frames of data that the Arduino program will understand. The PC also needs to come up with motor values. An
easy way to do this is to use a USB game pad or joystick, I'm using an Xbox 360 controller. Another option is to use a networked computer (either a netbook or a small
mini ITX board) on the robot itself to drive wirelessly. With a netbook, you can even use the onboard webcam to stream back a video feed and drive your robot remotely.
I used the Linux sockets system to do network programming for my setup. One program (the "joystick server") is run on a separate PC that has a controller plugged into
it, and another program (the "client" ) is run on the netbook connected to the Arduino. This links the two computers and sends joystick information to the netbook, which
then sends out serial packets to the Arduino that drives the robot.

To connect to the Arduino using a Linux PC (in C++) you must first open the serial port at the correct baud rate and then send the values using a protocol that you have
also used on the Arduino's code. My serial format is simple and effective. I use 4 bytes per "frame" to send the two motor speeds (each is a single byte). The first and
last bytes are hard-coded values that are used to keep the Arduino from sending the wrong byte to the PWM code and causing the motors to go crazy. This is the
primary purpose of the RGB LED, it flashes red when the serial frame was incomplete. The 4 bytes are as follows:

255 (hard coded "start" byte), , , 200 (hard coded "end" byte)

To ensure reliable reception of the data, make sure you put enough delay between program loops. If you run your PC code too fast, it will flood the port and the Arduino
may start dropping or even mis-reading bytes. Even if it doesn't drop information it can also overflow the Arduino's serial port buffer.

For the Vex motors, I used the Arduino Servo library. Since Vex motors are just continuous rotation motors, they use the exact same signaling that servos use.
However, instead of 90 degrees being the center point, it is the stop point where the motor does not spin. Lowering the "angle" causes the motor to start spinning in one
direction, while raising the angle makes it spin in the other direction. The farther away from the center point you are, the faster the motor will spin. While it is not going to
break anything if you send values greater than 180 degrees to the motors, I would advise limiting the values from 0 to 180 degrees (which in this case are speed
increments). Because I wanted more control and less out of control robot driving, I added a software "speed limit" to my program that doesn't allow the speed to increase
above 30 "degrees" in either direction (range is 90 +/- 30). I plan on adding a serial port command that changes the speed limit, so that the computer can remove the
limit on the fly if you want to go fast (I've been testing in small rooms so I don't want it to speed up and crash into the wall, especially with a netbook on it).

For more information, download the attached code at the end of this Instructable.

http://www.instructables.com/id/Simple-Arduino-Robotics-Platform/
Image Notes
1. 360 controller hooked to PC
2. Arduino hooked to PC. PC takes joystick values from the 360 controller, does a little math to get the desired range, then sends that data along with "test numbers"
(numbers that the Arduino uses to check beginning and end of a frame) over serial.

Step 4: Add a Netbook to explore unknown worlds from a distance


With a full PC onboard your Arduino robot, you are able to drive your robot from as far as your WiFi can reach without any cords to limit the robot to one area. A good
candidate for this job is a netbook, because netbooks are tiny, lightweight, have a built-in battery, have WiFi, and most even have built in webcams that can be used to
stream the robot's view back to a safe place where you can control it. Also, if your netbook is equipped with mobile broadband service, your range is practically
unlimited. With enough batteries you could drive your robot to the local pizza place and place an order over the webcam (not recommended, robots aren't usually
allowed in pizza places, even if they were people are likely going to try to steal the robot and maybe even the pizza). It may also be a good way to explore the dark
depths of your basement from the comfort of your office chair, though adding some headlights may be very helpful in this case.

There are many ways to get this working, many are probably a lot easier than mine, though I am not familiar with Processing or script-based languages so I opted to use
Linux and C++ to create a wireless control link between my base station (a.k.a. old ThinkPad) and my new Lenovo IdeaPad netbook that is connected to the Arduino
drive base. Both PC's are running Ubuntu. My ThinkPad is plugged into my school's LAN and my IdeaPad is connected to my WiFi access point that is also connected
to the school's LAN (I couldn't get a reliable video stream from the school WiFi since everyone else is using it, so I set up my own router to provide a good connection). A
good connection is especially important in my case since I have not implemented any error-checking or timeout. If the network connection suddenly drops, the robot
keeps going until it crashes into something or I run and stop it. This is the main factor behind my decision to slow down the drivetrain both by gearing the motors down
and implementing a software speed limit.

http://www.instructables.com/id/Simple-Arduino-Robotics-Platform/
Image Notes Image Notes
1. Redesigned Vex platform has a LEGO "tray" for netbook 1. IdeaPad S10 running Ubuntu 9.10 Desktop runs the code that interprets
2. Arduino is mounted behind the netbook tray, USB cord is coiled inside on top joystick data from the network and sends it to the Arduino.
of battery pack. Vex motors are on the bottom under the battery, geared small-to-
large for more control (less speed).

File Downloads

Arduino Robot Package 1.0.zip (186 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Arduino Robot Package 1.0.zip']
Step 5: Get a Video Feed
After your robotic explorer can drive wirelessly, you'll probably want to have a video feed from the netbook so you can tell where your robot is. If you're using Ubuntu (or
even if you aren't!) I recommend using VLC Media Player to stream. If you haven't installed it, you're really missing out, so install it using the command "sudo apt-get
install vlc", browse for VLC in the Ubuntu Software Center (9.10 only), or download the installer at videolan.org if you're on Windows. You will need VLC running on both
PC's. VLC is capable of streaming as well as playing streams on a network. On the netbook (robot PC) first make sure your webcam (either built-in or
USB connected) works by clicking Open Capture Device and trying Video for Linux 2 (some older devices may need Video for Linux rather than the new 2 version). You
should see the camera's view on the netbook screen. To stream it, select Streaming from the File menu and then pick the Capture Device tab at the top of the window
that appears. Remember that Ubuntu (and many other Linux distros) let you hold down Alt to click and drag windows that are too big for your screen (especially useful on
older netbooks, though even my IdeaPad has an odd 1024x576 resolution for no apparent reason). To reduce delay, click on "Show More Options" and lower the
caching value. The amount that you can lower it sometimes depends on the device, it gets unstable if you lower it too much. At 300ms you may get a slight delay but it
isn't too bad.

Next, click Stream to go to the next menu. Click Next, then select and add HTTP as a new destination. Now set up Transcoding to make the stream smaller. I made a
custom profile that uses M-JPEG at 60kb/s and 8fps. This is because using an advanced codec like MPEG or Theora will eat up massive CPU time on a netbook's Atom
processor and this can lead to your video feed stopping for no apparent reason. MJPEG is a simple codec that is easy to use at low bitrates.

After starting your stream, open up VLC on your other PC, open a network stream, select HTTP, and then type the IP address of your netbook (either local or Internet
depending on how you're connecting) followed by ":8080". You need to specify the port for some odd reason, otherwise it gives you errors. If you have a decent
connection, you should see your webcam's feed on your other PC, but it will have a slight (about a second) delay. I don't know exactly why this delay occurs, but I can't
figure out how to get rid of it. Now open up the control app and start driving your netbook robot. Get a feel for how the delay works when driving so you won't crash into
anything. If it works, your netbook robot is finished.

Related Instructables

Use Your iPod/


iRobot Create: iPhone with wifi, Carlitos'
WiFi Optimizer Bring new life to
even where an old laptop Projects:
Sparky - DIY by vector023 theres only MAYA Budget
with Ubuntu! by Wireless
Web-Based ethernet by Telepresence Speech-
Telepresence your dog Rover by bhylak
hguvg Controlled
Robot by Arduino Robot
sparkyrust by RobotShop

http://www.instructables.com/id/Simple-Arduino-Robotics-Platform/
Comments
8 comments Add Comment

Midwestmariner says: Dec 5, 2010. 4:08 PM REPLY


btw nice dr pepper can on step 4

Midwestmariner says: Dec 5, 2010. 4:06 PM REPLY


great guide! Im gonna get an arduino for christmas probbably. I cant wait for that

paradox116 says: Oct 30, 2010. 1:55 AM REPLY


Wow... Literally about 5 minutes ago I read your comment about that breadboard on SparkFun then stumbled upon this. I love crazy coincidences like this

rhymed says: Jul 11, 2010. 3:22 PM REPLY


When I started playing with Arduinos I did the same thing as you - I devised a control protocol for serial communication and then controlled everything from
my PC. It worked well, but eventually someone told me about the Firmata protocol. A library for it ships with the the Arduino IDE. The Firmata protocol is
intended to be a standard for this type of device-to-device communication. I found the Firmata to be a little difficult to use at first so ended up building a
library of my own that implemented the PC-side of the protocol. I prefer to do my PC coding with C# so the library is Windows-only at the moment, but I'll
create a Mono-compatible version soon so that it'll work on Linux as well. Check it out if you're interested: http://rhyduino.codeplex.com .

CalcProgrammer1 says: Jul 11, 2010. 5:39 PM REPLY


I've heard of Firmata before but it seems fairly complex for something this simple. It is designed to be able to control any part of the Arduino's I/O system
from the PC and has lots of different commands. A simple protocol like this is easier to code for if you just need to drive motors. Plus, I don't know if
Firmata supports configuring the Arduino's PWM outputs for servos. As for Linux programming, I like pure C++, it is a bit more work but doesn't rely on
any proprietary systems and the code is fairly portable. I like GTK+ for graphical interfaces because it is cross-platform, it did not take long to port a
graphical interface I wrote in Linux for my fan controller project to Windows and it worked great on both platforms.

nawook says: Apr 20, 2010. 3:03 AM REPLY


Nice instructable ! But I can't see the links for the PC program on step 3 :(
Could you please re-upload it ? Thanks !

CalcProgrammer1 says: Apr 20, 2010. 8:49 AM REPLY


To be honest I never really finished this Instructable, it still needs some work and I never got around to uploading the code. I'll post a zip file with the
code soon. There are a few things, there's the Arduino code, a program to drive it in Linux using a joystick, and a client/server set of applications (also
for Linux) that let you drive the robot (controlled by a netbook) using another PC. Streaming a video feed isn't covered in my code, you just run a
streaming program like VLC alongside the drive code to get video.

nawook says: Apr 21, 2010. 1:01 AM REPLY


Thanks !

http://www.instructables.com/id/Simple-Arduino-Robotics-Platform/

You might also like