Having trouble reading this email? View it on your browser.

MAKE Robots

April 14, 2010

Welcome to Our 5th Dispatch!

BRAINS!!!!

This week, we're talking about robot control systems, the brains that take sensor input from a robot's interactions with its environment (we'll discuss sensors next week) and use it to "actuate" motors, to direct movement, or to get the bot to do some sort of useful work. For more discussion on this topic, check out the Robot Control Systems topic in the MAKE Forums.

And, as always, if you have any questions, you can ask us in the Forums or email us.

Let's Make: Robots!

Gareth and Matt

back to top

Anatomy of an MCU

By Gareth Branwyn

Most bots have brains. Even BEAM robots, simple analog bots, popular with hobbyists, use analog ICs and combinations of resistors, capacitors, and transistors to oscillate (pass back and forth) a signal (via the IC), and time and amplify that signal (the RCs and the transistors) to move a robot or to get it to do something useful. The majority of small robots use what are called microcontroller units (or MCUs, or even µCs, if you wanna get really geeky about it). An MCU is a computer on a chip that contains a processor, a clock and timers, memory, and input/out lines. These tiny computers are usually flash-programmable (you download a program onto it coded on another computer) or are single-use and have a program baked into them (and are not re-programmable). You may have heard the term "embedded systems" before, which basically is what an MCU is: a tiny computer embedded in your car, your household appliances, medical instruments, and thousands of other applications.
 

arduinoMega.jpg

CPU – As with any computer, the central processing unit (CPU) is the traffic controller for the whole system, for executing programming instructions, and for processing the data of inputs and outputs.

Clocks – Some MCUs have clocks built right into the chip. Many MCU boards have a clock (aka “crystal oscillator”) on them that the MCU uses. Either way, these clocks affect how fast the MCU can perform its duties. Clock speeds are measured in MHz. On MCUs, clock speeds from 4MHz up to 75MHz are common. (The ATmega328 used in some of the Arduino family, including the Solarbotics Ardweeny, runs at up to 20MHz, a common MCU speed.)

Memory (Program and Data Memory) – Most popular MCUs use Flash memory, which enables you to read and write to the memory space over and over again. Like all EEPROM (electrically erasable programmable read-only memory), Flash retains data in it even when powered down. Flash memory is where the programs and permanent data are stored. As with your desktop computer, RAM is where all of the temp data (such as sensor input) is stored. The size of the EEPROM or Flash limits the size of the programs you can run on your MCU. The amount of RAM limits the amount of temporary data the controller can handle.

I/O (Analog and Digital) – Physical pins on the MCU chip, or more likely, broken out into plug-in "headers" on the MCU PCB, enable you to plug sensors and other components into the controller. In buying an MCU, you always want to make sure you have enough inputs for the sensors you'll be using (and a few more for future additions). Most MCUs have bidirectional I/O pins that can be programmed for input or output. If there are fixed I/O pins (as opposed to bidirectional), there are usually fewer outputs available. Some MCUs have both regular output pins and pins specifically designed for motor control.

PWM (Pulse Width Modulation) – PWM is a way of creating a controllable output signal, for controlling the speed of motors, the intensity of lights, etc., by pulsing a digital signal on/off (aka the "duty cycle") to create a sort of faux continous wave/analog signal. The speed of the on/off pulses are so fast, they smooth out, like a waveform. The on-time percentage, or pulse width, determines the speed of the modulation.

UART (Universal Asynchronous Receiver/Transmitter) – The way that an MCU talks to the world, and the computer that feeds it programs, is through a serial data connection; that serial communication, which gets translated back into parallell communications on either end of the pipe, is usually handled by the UART chip (or region of a chip). The UART feeds to a serial port, which is usually a set of male pins for a female header (think: plug) or a serial-to-USB converter jack. On the Ardweeny board, there's a 6-pin male header into which can be pluged a serial-to-USB conversion cable, or a serial-to-USB breakout board (a little PCB) into which a standard USB cable can be plugged.

ADC (Analog-Digiital Converter) – Computers are, of course, digital creatures. But a lot of the inputs (and the sensors that love them) are analog. For a digital machine to understand an analog signal, it must first be converted into something approxinating the on/off, binary nature of that digital machine. The mechanism for doing that is called an analog-digiital converter (or ADC). Most MCUs have these available on several pins. You can go the other way too, using a DAC (digital-analog converter), but that functionality is not common on most MCUs.

Other parts usually found on an MCU board are a power supply circuit – with a voltage regulator, power input jack, power selection switch or jumpers, communication ports (such as the serial-to-USB port mentioned above), and other communicatons types (such as I2C, a comms connection standard designed for embedded systems), a reset switch (reboot! reboot!), status indicator LED(s), and a power switch. Oh, and power output pins, for sending power out to sensors and other circuitry you wish to power from the board.

If you are using Arduino to control your CoasterBot, check out this basic SlideShare intro to Arduino. A general introduction to microcontrollers can also be found in a simple SlideShare presentation.

Also, check out the official Arduino site for tons of documentation and datasheets on the different MCU hardware used in Arduino.

back to top

Understanding Motor Controllers

By Matt Mets

robot_build_newsletter_l293dne.JPG

Critical to any robot that moves, a motor controller is the part that turns the motors on and off, and controls what direction they move in. There are as many different kinds of controllers as there are types of motors (lots!), but they all basically do the same thing: switch power on/switch power off.

For the CosterBot, you're probably going to be using DC motors to power your drivetrain. DC motors are pretty easy to turn on — all you have to do is hook them up to a battery! If you only need a motor to spin in one direction, then your motor controller would consist of a single switch, or transistor. This would be the case for, say, a vibrator motor in your cellphone, which only needs to turn on or off. For a robot drive wheel, though, you probably want it to be able to go backwards as well as forwards. To do this, you need a way to flip the connections between the battery and the motor, so that the motor lead that was plugged into the positive side of the battery is now connected to the negative side, and vice versa. One way to do this is to use a series of four switches:

H_bridge_diagram.jpg

In the above schematic, the lines represent wires, the circle on the left is the battery, and M is the motor. There are four switches, which are used to connect each motor lead to either the positive or negative side of the battery. To get the motor to turn in one direction, you close switches S1 and S4, which connects the left side of the motor to positive, and the right side to negative:

H_bridge_diagram_2.jpg

To get it to turn in the other direction, open those first two switches, then connect S2 and S3:

H_bridge_diagram_2.jpg

These switches would work great for controlling a motor by hand, but how can we hook it up to our microcontroller? Well, it turns out that there is a circuit designed to do just this. Called an H-bridge, it uses transistors as switches, so that control signals from a microcontroller can be used to turn them on and off. You could build the circuit yourself using individual transistors (it's a great way to really learn how they work!), but usually, it's better to use a pre-made chip, such as the L293DNE. Check out the DC Motor Control article at the ITP website for a good overview of how to use this chip with your microcontroller.

back to top

Inside the Ardweeny

By Gareth Branwyn

ardweenyNL.jpg

The Ardweeny is an Arduino-compatable breadboard-based MCU that uses a backpacking printed circuit board. That means that the support electronics for the MCU and the header for communications are on a board that sits right over the top of the 28-pin ATmega328 chip. The header pins you solder onto the board then get soldered directly onto the pins of the ATmega chip. That chip then plugs into a breadboard. This creates an MCU that's about as small as it can be. What the Ardweeny doesn't have is a power circuit or any baked-in means of communication. For the power, you need to get a voltage regulator. For the Jameco kit, we spec'd the Solarbotics Breadboard Voltage Regulator Kit. Like the Ardweeny, it has a small footprint, few parts, and is easy to put together. There are also lots of how-tos online for building a simple 5V breadboard power supply. Just do a search.

For the USB connection with your computer, the easiest thing to do is to buy a USB-TTL serial converter cable. This plugs into the 6-pin header on the MCU and has a USB plug on the other end. The circuitry to translate from the TTL (transistor-transistor logic) of the chip to USB is built into the USB jack itself. The Maker Shed sells the most common version of this cable. If you get ambitious, you can hack up your own cable much more cheaply, although it's a bit of work. Again, do a web search and you'll find instructions on such projects.

solderDanceNL2.jpg

Do the solder dance! It's the geek dance craze that's sweeping the nation!

Some people who haven't soldered before might be intimidated by it. You really shouldn't be! It's really not that hard. You simply need a few basic soldering tools (borrow from your nearest geek, if you don't already have them and don't care to invest just yet). And then spend a few hours practicing, desoldering and resoldering old technojunk. Just keep it hot, keep it clean, and move relatively quickly. And make sure you have good lighting and good ventilation. We did a whole summer "MAKEcation" series on soldering. Here's a Toolbox column I did on essential soldering tools. And here's a link to my Thumbnail Guide to Soldering , featuring the "soldering dance," illustrated by MAKE Editor-in-Chief Mark Frauenfelder. If, after that, you still need some help, check out all of the soldering articles, videos, and tutorials we've run on MAKE.

Note: The Ardweeny has the same functionality as a regular Arduino, but because of its small size, the I/O pins are arranged in a different order. See the official diagram on the Arduno site to find out which pin is which.

back to top

Maker Profile: Jasmine and Her Dad

TeamJasmine.jpgThis week we meet one of our robot building teams, Jasmine and her dad (not pictured: Turtle --yes, an actual turtle-- the inspiration for their robot)

Hi! My name is Jasmine. I'm 11, I'm learning about robotics, and my dad is teaching me. We are going to work on a robot for the contest, and we hope to improve our robotic skills a lot. My dad has put me in charge of communications for this project, so here I am.

My dad is a mechanical engineer, and he sells tiny electric motors, and our robots are usually driven by them. We have built a few line followers, and a robot-like car. The microcontrollers for them have been BASIC Stamp, PIC, and Athena. We have been collecting many parts for this occasion, and we really look forward to participating in the contest.

back to top