Gorobotics is the perfect blog for everyone looking to learn how to make a robot, gather knowledge about DIY robotics projects, and stay in touch with the latest robotics news.
Arduino is fast becoming one of the most popular microcontrollers used in robotics.There are many different types of Arduino microcontrollers which differ not only in design and features, but also in size and processing capabilities. In this article, you’ll understand the differences between the Arduino Microcontrollers (as of 2012).
There are many features that are common to all Arduino boards, making them very versatile. All Arduino boards are based around the ATMEGA AVR series microcontrollers from ATMEL which feature both analog and digital pins. Arduino also created software which is compatible with all Arduino microcontrollers. The software, also called “Arduino”, can be used to program any of the Arduino microcontrollers by selecting them from a drop-down menu. Being open source, and based around C, Arduino users are not necessarily restricted to this software, and can use a variety of other software to program the microcontrollers.
There are many additional manufacturers who use the open-source schematics provided by Arduino to make their own boards (either identical to the original, or with variations to add to the functionality). For example, the most popular board, the Diecimilla / Duemilanove (and now the Uno) has dozens of look-alike boards from other suppliers which differ slightly (different USB port, color etc) from the original.
The smallest Arduino product is the Arduino Mini Light which is a 24-pin microcontroller without any connectors soldered. The unit features 8 analog pins and 14 digital pins. The module is based around the ATMEGA168 processor. The only different between the Arduino Mini and the Arduino Mini Light is that the Arduino Mini has pre-soldered pin headers. The Mini lineup will be changed and will likely include the new 32U4 processor.
Microcontroller ATmega328
Operating Voltage 5V
Input Voltage 7-9 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 8 (of which 4 are broken out onto pins)
DC Current per I/O Pin 40 mA
Flash Memory 32 KB (2 KB used by bootloader)
SRAM 2 KB
EEPROM 1KB
Clock Speed 16 MHz
The Mini and Mini lite are really intended to be used with breadboards. In order to program these, you need a separate USB to serial adapter.
The Arduino Pro Mini 8MHz and 16MHz are also breadboard mountable and are a bit longer than the Arduino Mini. The Pro Mini 8MHz operates on 3.3V while the 16Mhz operates at 5V. Both feature 6 analog I/O and 14 digital I/O. The manufacturer has marked the back of the PCB to indicate which is which.
Microcontroller ATmega328
Operating Voltage 3.3V or 5V (depending on model)
Input Voltage 3.35 -12 V (3.3V model) or 5 – 12 V (5V model)
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
Flash Memory 16 KB (of which 2 KB used by bootloader)
SRAM 2 KB
EEPROM 1 KB
Clock Speed 8 MHz (3.3V model), 16 MHz (5V model)
The Pro is one of the fastest and smallest (and still one of the lightest) of the boards.
The last breadboard mountable Arduino is the Arduino Nano. This microcontroller distinguishes itself from the others by having the USB to serial chip and connector onboard. The Nano has 8 analog pins and 14 digital pins. There are the ISCP headers to re-flash the ATMega chip. There is also the Arduino Nano Lite which does not include the downward facing pin headers.
Microcontroller Atmel ATmega328
Operating Voltage (logic level) 5 V
Input Voltage (recommended) 7-12 V
Input Voltage (limits) 6-20 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 8
DC Current per I/O Pin 40 mA
Flash Memory 32 KB (2KB used by bootloader)
SRAM 2 KB
EEPROM 1 KB
The Nano was the first mini breadboard-compatible board to have onboard USB.
Next is the Arduino Lilypad. The Lilypad stands out from all other microcontrollers because of its round, purple PCB. The lilypad was originally intended to be sewn into clothing, though enthusiasts have found many other applications for it. If you’re cautious, the Lilypad can also be washed along with the clothing. The Lilypad requires as little as 2.7V to work.
Microcontroller ATmega168V or 328V
Operating Voltage 2.7-5.5 V
Input Voltage 2.7-5.5 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
Flash Memory 16 KB (of which 2 KB used by bootloader)
SRAM 1 KB
EEPROM 512 bytes
Clock Speed 8 MHz
The Lilypad is intended for use with clothing and fabric-related projects. There are many Lilypad accessories (LEDs, buzzers, sensors etc.) in the same format which can be connected via conductive fabric.
Arduino Leonardo
The next Arduino boards have the classic Arduino board shape and can’t be mounted on breadboards. The smallest in this line is the Arduino Leonardo. The Leonardo is available with or without shield stacking headers.
Microcontroller ATmega32U4 (onboard USB Transceiver)
Operating Voltage 5 V
Input Voltage 2.7-5.5 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 12 (10 bit resolution)
DC Current per I/O Pin 40 mA
Flash Memory 32 KB (of which 2 KB used by bootloader)
SRAM 3.3 KB
EEPROM 1024 bytes
Clock Speed 16 MHz
The Leonardo is (currently) the newest Arduino to use the 32U4 chip and lowers the price of Arduino boards.
A very similar board to the Leonardo is the Arduino Pro. Some of the advantages to this board are its operating voltage range, which is 3.3 to 12V, its smaller footprint and lighter weight. The Pro doesn’t come with pin headers and although it’s smaller than other Arduino boards, it’s still compatible with Arduino shields.
Microcontroller ATmega168
Operating Voltage 3.3V
Input Voltage 3.35 -12 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
Flash Memory 16 KB (of which 2 KB used by bootloader)
Next is the most popular of the Arduino microcontrollers; the Uno. The Uno has almost the same appearance as its predecessor, the Duemilanove, but uses an ATMega8 for USB to serial conversion. The Duemilanove was previously the Diecimilla which had a less powerful ATMega168 chip. These boards come pre-assembled and ready to use. The Duemilanove is based around the ATMEGA328 chip while the Diecimilla used the ATMEGA128.
Microcontroller ATmega168 or 328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 16 KB (ATmega168) or 32 KB (ATmega328)
of which 2 KB used by bootloader
On one side of the board there are 14 digital input/output pins as well as a ground pin and a reference pin which acts as voltage reference for the analog pins. Pin zero doubles as serial input, and pin 1 doubles for serial output. On the other side of the board, you’ll find 6 analog pins, as well as a voltage input pin, two ground pins and a reset pin. The board also has both a 3.3V and 5V output pins.
You can power the board any of three ways: directly via the USB port, using the power connector, or the Vin and ground pins. The ATMEGA chip is removable from the board. This is especially useful if you have fried the processor and need to replace it, or you can use the board alone as a USB to serial interface. R3 of the Uno adds two new pins on the digital side: SDA and SCL
The Arduino Ethernet is essentially a normal Arduino Uno where the ATMega8 chip and USB plug are changed for an Ethernet port. The PoE (power over ethernet) version means you don’t need a separate power supply (wall adapter for example), although your router must also be PoE compatible. A similar setup can be done using a standard shield-compatible Arduino and an Ethernet shield.
Microcontroller ATmega328
Operating Voltage 5 V
Input Voltage 7-12 V (36 to 57V PoE)
Digital I/O Pins 10* (of which 6 provide PWM output)
Analog Input Pins 6 (10 bit resolution)
DC Current per I/O Pin 40 mA
Flash Memory 32 KB (of which 2 KB used by bootloader)
SRAM 3.3 KB
EEPROM 1024 bytes
Clock Speed 16 MHz
*In order to use the Ethernet, pins 10 to 13 are reserved.
Next on the list is the Arduino Bluetooth. The layout of the board is identical to that of the Duemilanove, but with one big difference: the Arduino Bluetooth board replaces the USB plug with a Bluetooth module, meaning you program it remotely. Take note that the board has different power requirements than the Duemilanove and doesn’t have a 3.3V output pin. The 9V output pin indicated on the board is not actually functional.
Microcontroller ATmega328
Operating Voltage 5V
Input Voltage 1.2-5.5 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 8 (4 are broken out onto pins)
DC Current per I/O Pin 40 mA
Flash Memory 16 KB (of which 2 KB used by bootloader)
The most recent addition to the Arduino lineup is the Arduino MEGA. This board is physically larger than all the other boards and offers significantly more digital and analog pins. The MEGA uses a different processor allowing greater program size and more.
Microcontroller ATmega1280 or 2560
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 54 (of which 14 provide PWM output)
The Arduino ADK is intended to connect to Google Android based devices. Note that a cell phone will attempt to draw power from the board (often more than a USB connected to a computer can supply); an external battery or wall adapter is highly suggested.
Microcontroller ATmega1280 or 2560
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 54 (of which 14 provide PWM output)
Analog Input Pins 16
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 128 KB or 256KB
SRAM 8 KB
EEPROM 4 KB
Clock Speed 16 MHz
Arduino is open source; you are free to download the schematics and programming software and develop them as you wish. If you want to market your new design as an Arduino however, there is an approval process. For more information about the Arduino microcontrollers, different variants and accessories, click here.
This article is a follow-up to the RobotShop Grand Tutorial Series and includes all the hardware chosen in the “Practical Example” at the bottom of each lesson. The RobotShop Rover for Arduino is a small tracked platform designed around the popular Arduino USB microcontroller.
The first product that one might look for after having received the package is the frame. The RobotShop Rover for Arduino aluminum frame (RB-Rbo-11) is powder coated a deep blue and comes with a variety of different mounting hardware used to complete the kit. Aside from standard washers, nuts, and rivets, the hardware also includes a 9V battery clip and leads. On its own, the RobotShop Rover for Arduino frame doesn’t do much, so in order to make a functional tracked mobile robot, you would additional parts.
There are two Solarbotics GM9 gear motors included with the kit capable of up to 66rpm and a maximum of 3kg-cm of torque. These are not the fastest of motors but do allow the robot to carry additional payload. The Standard GM Track Kit includes all the links and pins you need to make two tracks, as well as two drive sprockets and two idler sprockets. To hold the idler sprockets in place, the kit comes with two Shoulder Bolts with matching washer and nut. Next a standard AA battery holder holds four AA batteries which power the drive motors and servos.
All the parts listed so far are included with the RobotShop Rover for Arduino Tank Kit (RB-Rbo-13). The RobotShop Rover Tank Kit is ideal if you already have your own Arduinomicrocontroller or want to use your own parts to complete the robot. In order to make a fully functional robot however, you need additional electronics, starting with a microcontroller.
The Arduino USB Microcontroller is essentially the brain of the RobotShop Rover and includes an ATMega328 processor already installed. To connect the board to your computer, the RobotShop Rover Complete Kit comes with a 6 foot USB cable.
The Arduino board can’t produce a high current, which is why a 5 Amp Low Voltage Dual Serial Motor Controller (RB-Pol-16) is included to power both drive motors. You may notice the pin headers are not soldered onto the board – this allows you to mount it horizontally or vertically, or even solder wires directly to the controller.
At this point you have all the essential parts you need to make a mobile robot, but you may find connections are not easy. To help you easily connect electronics and wires, the kit includes three mini solderless breadboards, a pre-formed jumper wire kit and 25 feet of 22 gauge hook-up wire. The extra wire is used mainly to connect the motors. There are also two mini power switches included whose pins are spaced perfectly for breadboards.
One very attractive aspect to the RobotShop Rover for Arduino is that there is a slot at the front for a standard sized servo. The RobotShop Rover Complete Kit therefore includes a Lynxmotion pan and tilt system with two Hitec HS-422 servo motors. If you have only received the Tank Kit, you are free to add a Hitec HS-422 servo to create a pan system. To complete the kit, the popular Sharp GP2D120 infrared range sensor and associated Sharp IR cable are included to give the robot feedback about its environment.
Appropriate USB cable (Arduino boards draw power from the USB port – no batteries yet)
Analog accelerometer, gyroscope and/or IMU
Connectors (between the IMU and the Arduino
Accelerometers, gyroscopes and IMUs are incredibly useful little sensors which are being integrated more and more into the electronics devices around us. These sensors are used in cell phones, gaming consoles such as the Wii wireless remote control, toys, self-balancing robots, motion capture suits and more. Accelerometers are used mainly to measure acceleration and tilt, gyroscopes are used to measure angular velocity and orientation and IMUs (which combine both accelerometers and gyroscopes) are used to give a complete understanding of a device’s acceleration, speed, position, orientation and more.
When choosing an accelerometer, gyroscope or IMU, it is also important to consider the type of output; depending on the type of sensor, readings can be output as:
Serial data (Tx pin)
I2C (SDA, SCL)
Analog
TTL
others…
In this tutorial we’re only going to cover analog output. The code shown below includes the output for a single axis sensor and factors in the rest value.
Accelerometer
Accelerometers measure acceleration in one to three linear axes (x, y, z). A single axis accelerometer can measure acceleration in whichever direction it is pointed. This may be good for a rocket, an impact, a train or other scenario where the device really moves in one basic direction. Knowing the acceleration and time, you can use mathematics to find the distance traveled by the object. There are fewer and fewer single and double axis accelerometers on the market because a triple axis accelerometer can do so much more. Thanks to low manufacturing costs the three axes accelerometers are not much more expensive than single or double.
Acceleration due to gravity is a constant and is in fact measurable using an accelerometer. When placed parallel to the ground, acceleration due to gravity would only be “felt” by one axis. However, when tilted, this acceleration would appear as components of two (or three) axes. You can get an idea of how to use an accelerometer to measure tilt here and here.
Connect the accelerometer to the Arduino; each output pin goes to one of the analog pins on the Arduino, the Vin pin goes to the 5V pin on the Arduino (read the user guide to ensure the Vin pin is 5V as opposed to 3.3V), and connect the GND pin to the GND pin on the Arduino. Note that there is no need for additional electronics! Next, open the sample sketch File -> Examples -> Sensors -> ADXL3xx. Upload to the Arduino and see the values change.
In order to choose the right accelerometer, consider the maximum linear acceleration the sensor will be subjected to. If you are planning to add an accelerometer to a small mobile robot, you will likely use a 2g accelerometer (even that is likely overkill), whereas if you are attaching it to a rocket, a 16g accelerometer is likely a better choice. When connected to a 10 bit ADC, the 2g accelerometer will have an accuracy of 2 / 1024 = 0.002g, and the 16g accelerometer will have and accuracy of 16 / 1024 = 0.0156. Therefore if you only need a range of 2g, but purchase a 16g accelerometer, you will only have about 128 possible readings, instead of the full 1024. Conversely, if you choose a 2g accelerometer when you really needed a 16g, you will get a lot of “maximum (1024) “readings since the acceleration is “off the scale”.
Gyroscope
Gyroscopes measure angular velocity in α, β, γ (see image below). Gyroscopes can be used to help with stabilization and well as changes in direction and orientation. Unlike accelerometers, gyroscopes do not have a fixed reference, and only measure changes. To choose the right gyroscope for your needs, consider the maximum angular rate of change (degrees per second) your product will be subjected to. A remote control will likely rotate at less than 1 rotation per minute (360 degrees per second), while a rocket tumbling out of the sky may be rotating at 1500 degrees per second. When connected to the same microcontroller (10 bit for example), the 360 degree/s gyro will have an accuracy of 360 / 1024 = 0.35 deg/s, whereas the 1500 deg/s gyro will have an accuracy of 1500 / 1024 = 1.46 deg/s. Therefore if you chose a 1500 deg/s gyro when you only needed a 360 deg/s gyro, you will only get about 245 readings as opposed to 1024.
Courtesy: Wikipedia
IMU
An IMU (Inertial Measurement Unit) usually consists of an accelerometer and gyroscope and is used to measures an object’s orientation, velocity etc. Often additional sensors (magnetic, temperature) are included to improve accuracy. The number of “degrees of freedom” indicates the number of different axes measured by the chip. For example, combining a three axis accelerometer with a two axis gyroscope would be consider a 3+2 = 5 DoF IMU.
Additional Considerations
When using accelerometers, gyroscopes or inertial measurement units (IMUs) to obtain positions in space, it is important to note that there are several additional factors that will affect the readings, the main obstacle being the sampling rate. Microcontrollers require a certain amount of time to read values being provided to them by the sensor, and because of this, the values between these readings are lost. There are several mathematical methods (a Kalman filter being a popular choice) that attempt to compensate for this. A second source of error is that readings are often affected by fluctuations in temperature. Most datasheets associated with micro-electro-mechanical systems (MEMS) attempt to describe how temperature affects the output.
Want to learn more? Start with the material put out for free by Analog Devices, makes or many MEMS acceleromters, gyroscopes and other sensors.
Force “sensors” are actually “force sensing resistors” (FSRs). Similarly, bend “sensors” are actually products whose resistance changes with flexing. These can all be categorized as “variable resistors”. To interface a product whose resistance changes with a microcontroller, you need a voltage divider circuit. This “circuit” is nothing complex – aside from wires, the only part you are missing is a resistor.
To create the circuit, add the variable resistor in series with a similar (standard) resistor of roughly the same resistance (in ohms). Connect a wire between the two – this wire goes to the analog input of the board. There should only be two wires left – one end of the standard resistor, and one end from the variable resistor – these ends are connected to +5V and GND respectively. You can now use it as a regular sensor with analog output.
The output of this “mini circuit” is a signal between 0 to 5V (this is referred to as an analog signal), which is connected to an analog pin of the microcontroller. The microcontroller’s on-board analog to digital converter (ADC) interprets this voltage and assigns it a number which you can use in your code. For 10 bit ADC (210), you will get a number between 0 and 1024 representing 0V to 5V. You would need an equation in your code to use this number to send the appropriate signal to a motor controller. As you might have suspected, the code is now identical to that used to get an analog input.
To get sample code, open the Arduino software and go to File -> Examples -> Analog -> AnalogInOutSerial
The video above shows a bend sensor connected to an Arduino, and the Arduino is connected to a small servo motor. The analog value associated with the flex sensor is read by the Arduino, and that value is converted to a rough position. You would merge the Analog example code with the servo code, and add a single line to convert the 0 to 1024 value to 0 to 180 degrees. It is easy to see how, with many of these sensors, you can create a data glove which controls a robotic hand.
Appropriate USB cable (Arduino boards draw power from the USB port – no batteries yet)
Standard servo motor (current consumption <50mA)
Pin headers / cables
Controlling a servo motor directly from the Arduino is quite easy. However, a servo motor may require significantly more current than the Arduino can provide. The following example uses a standard sized servo (without any load) powered directly from the Arduino via USB. When powering the servo directly from the Arduino board:
Connect the black wire from the servo to the GND pin on the Arduino
Connect the red wire from the servo to the +5V pin on the Arduino
Connect the yellow or white wire from the servo to a digital pin on the Arduino
Alternatively, you can plug the servo’s wire into three adjacent pins, and set the pin connected to the red lead to “HIGH” and the pin connected to the black lead to “LOW”. If you want to use a more powerful servo, or if you want to connect it to a separate power supply, you would connect the battery / power supply’s red (5V) and black (GND) wires to the servo’s red and black wires, and connect the signal wire to the Arduino. Note that you also need to connect the batter’s GND line to the Arduino’s GND pins (“common ground”).
pinMode(pin number, OUTPUT);
This sets a pin number as dedicated input or output. In this case, we called the pin “servopin” and assigned it a value of 4. The term “pulse” is in black as it is not a reserved word and can be changed by the user. It is best to use descriptive variables when coding to understand what each does, or the information it will contain. Servos operate by sending a timed +5V pulse (usually between 500us and 2500us) to the onboard electronics, which is repeated every ~20ms. This pulse corresponds to a servo position, usually from 0 to 180 degrees.
5V for 500 microseconds = 0.5 milliseconds and corresponds to 0 degrees
5V for 1500 microseconds = 1.5 milliseconds and corresponds to 90 degrees
5V for 2500 microseconds = 2.5 milliseconds and corresponds to 180 degrees
The relationship is linear, so use mathematics to determine the pulse which corresponds to a given angle. Note that if you send a signal that is greater or lower than the servo can accept (for example, Firgelli linear actuators accept 1 to 2 ms), you might damage the actuator.
Another option for controlling servos is to use the Arduino “servo library” (previously separate from the basic Arduino software, it is now included with V1.0). The servo library manages much of the overhead and includes new, custom commands. If you want to control multiple servo motors, you should use a servo motor controller and a separate power supply between 4.8V to 6V.