Odds and Ends

Make:

So I was at a local electronics store yesterday. They happen to have a book section, and what did I notice but “Maker’s Notebook”. It is a cool blue, semi-hard covered notebook. It is blank for you to put all your project notes in. There is a table of contents, numbered project pages that are graph paper, a few pages with basic electronics information, and it has a back pocket with sheets of stickers. I like it because of the page numbering and table of contents. Now I can organize my ideas for the different projects I am working on. With the graph pages I can draw schematics, write notes, even come up with some mechanical design.

This cool little notebook measures about 5 3/4 inches by 8 3/4 inches. For those of you who use the metric system it measures approximately 14 1/2 cm by 23 cm. You can also purchase it from the Make magazine website by clicking the store tab.

Ordering Parts

It may seem like it would be too soon to order any parts for this project, but it is not. I have a good idea what parts I am going to be using, plus I have a list of parts for other projects. I will look over my list and the requirements for the robot brain and try to combine the common parts. This is so I can get a bigger discount on buying in bulk. Think of it this way, if 10 resistors cost me 10 cents and 100 resistors only cost 75 cents, I am going to buy the 100 resistors. I like to have spare parts and extras for other projects. Two of the biggest catalog suppliers are Digikey and Mouser. You can search their websites for all kinds of parts.

I am also planning a purchase from Sparkfun. I am going to get an Arduino Uno, the motor shield, and a prototyping shield. I have not messed around with the Arduino before so I am going to play with one. Later I will write-up posts on the Arduino from a newbies perspective.

Time

Time is fleeting as they say. Hopefully you will bear with me, because of time constraints I cannot post everyday. The reality is I need time to draw the project’s schematics (which can take days if not a week) and prototype/breadboard the circuits to check the functionality. After which comes the board layout (again it can take a week) and don’t get me started on the software. I have some software routines that I will be able to reuse from my first robot brain. I plan to be able to reuse most of the software I write as I try to code the interface to be generic. Then the specific robot implements the interface in its own way. So I just wanted to thank you for your patience.

What is next?

Like I have said before, my next post will be the final design. In reality I can change the design anytime until I have sent the files out to have circuit boards made. In addition I will talk about the schematic capture software I am using and show you the progress on the schematic. I will include a parts list with part numbers and Digikey/Mouser part numbers so you can follow along.

With the limitations of how much storage I am limited too with WordPress.com, I might start linking the pictures from my posts to pictures on a service like Flickr or Picasa Web Album. We will see. Until then have fun.

Brain Design

Microcontroller

Atmel microcontroller atmega328

An Atmel ATmega328 microcontroller

Last time I said I was going to use 2 microcontrollers – a mega328 and a tiny24. If I feel like I am going to run out of code space on the tiny24, I can quickly swap it out for tiny44 or 84. The surface mount vs. through hole debate has morphed into “why not both”. The schematic will be the same for both, just the PCB layout will be different.

Serial Port

Having a USB port would be nice, but it is not a main requirement. Neither is having an RS-232 level serial port. I can get by with a TTL level serial port. I have USB to serial port adapters that provide RS-232 and TTL voltage levels. I will think about these some more.

Driving Motors

motor driver circuit board for an Arduino

Sparkfun Motor Shield

One of the big decisions to make is about a motor driver. The design of my first robot brain had headers to plug-in a motor driver daughter board. Sparkfun makes a motor shield for the Arduino that plugs in as a daughter board. The issue that comes up is how much prototyping space do I want. If I leave off the motor driver circuit, then I leave myself a larger area for prototyping. Then again I could include the motor driver and make a prototype expansion board. Pololu makes the 3pi robot and they offer an expansion board that mounts on top to give you a good-sized prototyping area. The 3pi has a cool look to it when the expansion board is mounted. It is a good idea to give yourself some area to experiment with. I like to add a few LEDs for debugging purposes or other circuitry for more functions.

Pololu 3pi robot with expansion board mounted on top

A Pololu 3pi with expansion board mounted

So if I put the driver circuit on the main board, which motor driver should I use? I can use the old standby chips like the L293D/SN754410, the L298, a pair of LMD18200Ts, or a FAN8200 if I could find them. These are bipolar transistor parts that have a voltage drop and a bit of current draw while conducting. Looking into MOSFET drivers appeals to me for the lower voltage drop and less current wasted while driving motors. I could use something like a TC4427 or more exotic parts from Allegro and Freescale. They make motor driver chips with extra features. I just have to decide which components I want to use. Either way I have decided that like the Pololu 3pi robot, I will have a separate expansion board for prototyping. This way I can plug it in only when I need to and the robot’s main circuit board does not have to change.

So I still have a few more things to think about. Next time I will go through the pros and cons of having the motor driver circuit on the main controller board. I will also post a few more pictures and details on my current mini sumo robots. At some point talking about the software tools will come up. Schematics, PCB layout, and parts lists are going to be required at some point. Check back for the next exciting article, or at the very least better than average.

New Brain Design

The Idea…

So all of that AVR overview was to get us here, the design of a new robot brain. I compete in Mini Sumo at different robotic competitions. What I like is that it involves mechanical, electrical, and software engineering. The competition is autonomous, so none of this radio control stuff. The robot has to compete on its own. It comes down to whether I made a good design, or do I need to go back to the drawing board (or in this case computer programs).

Mini Sumo robot controller circuit board

This is the first robot controller I designed

So let’s get into the design process. My original brain board used an Atmel ATmega48 microcontroller. The mega48 had more than enough program memory to handle mini sumo. Since I used the DIP (dual inline package) version, I ran out of I/O pins for a couple extra features I wanted. The original plan was to have 4 IR LEDs, on individual I/O pins, and 4 IR detectors. I changed the plan to use 1 output each for 2 LEDs. After a few more changes, I came up with the circuit board you see on the right. The board is blue because I liked the color of the Arduino, so I made mine the same. Though the boards are the same color, I did not design my board to be compatible with the Arduino or its programming tools. This time I think I will make the board compatible with Arduino. Not physically as I need it to fit the size requirements on mini sumo, but in function. I will use a mega328, which the Arduino boot loader can be programmed into the chip. Then the Arduino programming tools can be used.

Now that I picked a microcontroller (the mega328), I can work out some other details. Originally I used the 16 bit Timer 1 for creating the 38kHz frequency use for the IR LEDs. This left me with Timer 0 for driving the servos. After looking over the internet for code to drive servos, it became clear that everyone was using Timer 1. Now I had to write my code for driving the servos as I could not use anything from the internet. Where is this leading? Well this time around I will use Timer 1 for the servos. So what about the IR LEDs? Here is where I have a few choices. I could use a 74xx04 logic chip to create an adjustable oscillator centered around 38kHz, a 555 Timer chip – again to create a 38kHz frequency signal, or maybe another microcontroller. I really like the idea of adding another micro. In this case I am looking at using a ATtiny24. It will have enough I/O and timers to deal with IR object detection.

Arduino Uno board

The Arduino Uno

What about USB? The Arduino only has a USB port for downloading the program into the micro. The board has a USB to serial port chip. Do I want to add this to my design? If I don’t, I would need an external USB to serial port converter to download programs using the boot loader. Should I put on a RS-232 transceiver chip (like a MAX3232E) to interface with a standard serial port?

Other Design Decisions

We have been dealing with some of the higher level design decisions. There are many smaller decisions to be made. Should I include a motor driver chip on the board? If so which one? The IR LEDs for the obstacle avoidance detectors need to be shielded from leaking IR light into the sensors. Is heat shrink ok, or should I use the plastic shrouds that Parallax (makers of the Basic Stamp) sells? How about having some prototyping area, or headers for plugging in a daughter board. These are just some of the decisions I have to make. The biggest decision I need to make now is to use surface mount components or go with through hole parts. This really depends on if I want to sell it as a kit. As a kit through hole components work better as more people could build it. If I go surface mount, then it might be left to me to install the parts and sell it as a partially completed product. Or what if I just designed both version, posted all the information here, and let you figure out which one you want to build, if any.

Well, that is all for now. Until next time here are a couple pictures of my Mini Sumo robots.

This is a modified Parallax Sumobot

My very modified Parallax Sumobot

Mini Sumo robot with Tony's brain board on top

My brain board on Parallax Mini Sumo chassis

Software Tools

Software, Languages, and Tools

This time we are going to look at some of the software, languages, and programming tools for the AVR. This will finish up my overview on the AVR. My next series of articles will be on the new robot brain board that I plan to design and build. The board I am designing will be for Mini Sumo, but could be used for other projects.

Atmel

Atmel again you say, ha! When it comes to AVR development, everything starts with Atmel. Atmel provides a nice tool called AVR Studio. AVR Studio is the IDE (integrated development environment) you use for assembly language and higher level programming. What is nice about AVR Studio is all the features you get with it. An example would be simulation. Write your code, run the simulator, and watch the bits toggle. You can even change the I/O bits to simulate external devices connected to the AVR. One of the features of AVR Studio is that it will link with WinAVR (a toolchain for compiling C/C++ programs). This information has changed somewhat recently. With AVR Studio version 4 and before, you had to install WinAVR separately. Now with Atmel releasing AVR Studio 5, WinAVR is part of the software.

Basic

Where AVR Studio is a tool for coding and testing your program, BASIC is a language. There are a few options when programming in BASIC, and the options come with a nice IDE similar to AVR Studio. I am only going to talk a little bit about two choices, but just do a search and you’ll turn up several options.

BASCOM from MSC Electronics is one of the most popular choices for programming AVRs’ in BASIC. You get a good development environment, with the ability to download your code from within the tool. BASCOM comes in a free 4K code limited edition, and the full tool for $120 US. Download the demo and give BASCOM a try.

mikroBasic from Mikro Elektronika also has a BASIC compiler (yes compiler not interpreter) for the AVR. Again, Mikro provides a full IDE for developing your code. Mikro provides a free 2K code limited version along with a $149 US paid full version. I have not heard much about this program, so I would suggest you do some research before purchasing.

C

When you get to the C programming language you have many more choices. You can go completely free to full professional with the price tag to match. We are going to work our way from cheap (not because of features) to expensive.

WinAVR

WinAVR is the defacto standard when you are talking free C compilers. WinAVR is based on AVR-GCC, which both are based off the GNU compiler toolchain. For Windows PC users you’ll be using WinAVR, while for Mac OS X or Linux it will be AVR-GCC. Don’t worry, they are the same. WinAVR and the rest of the tools are just packaged into a nice Windows installer. There is tons of information out there on WinAVR. Take a look at the WinAVR web site, then hop on over to AVR Freaks for more info.

Here is a short blurb on WinAVR. Programmer’s Notepad comes bundled with WinAVR. PN is a simple IDE for programming in different languages. Again with Atmel including WinAVR in their latest version of AVR Studio, you don’t even need download anything else.

Make Hack Void

Since WinAVR was picked up by Atmel, another group of programmers decided to take on building a toolchain like WinAVR. Make Hack Void is a web site that releases a replacement for WinAVR. They call their tool MHV AVR. I am in the process of testing it to see if it is a good replacement.

Arduino

Another free option that I know of is Arduino. Arduino is hardware, but they also provide free software for programming the Arduino. Arduino is also the programming environment. Arduino is based on Wiring (which itself is based on Processing) which is a simplified C/C++ IDE. It was designed for people without prior microcontroller programming experience. Take a look at the Arduino web site for more information.

Low cost C compilers are not low-cost because they lack features. For the most part the only real difference between high cost professional compilers and the low-cost version is code density. The pro packages can optimize the code better. Dense code does hurt you in the debugging stage as your lines of C code don’t match up to the assembly language listing.

Imagecraft

Imagecraft makes a nice low-cost C compiler that compares well with the more expensive options. Imagecraft’s product is ICCAVR.  The IDE is full featured including an applications building tool. The only thing is the interface looks like it came out of the Windows 16-bit days. The interface is slated for an overhaul in the near future. They have a fully working demo for 45 days. After the 45 day demo period, the program is reduced to 4K code limit. You can also purchase a non-commercial license for $49, and full-blown license for $249. Take a look at their website, as they offer compilers for different microcontrollers.

Mikro Elektronika

Mikro Elektronika also provides a low-cost solution for programming AVRs’ in C. Again, this tool provides a full development environment. The interface looks current and seems to have many project management features. I will say I have no experience with this compiler as of yet, but I have downloaded the full functional (but code limited) demo and intend to try it.

CodeVision

CodeVision is another choice in the low-cost arena. This compiler I do not know much about. They have light and standard versions that range from $127 to $211 US. In this case I will say use at your own risk. The IDE looks nice, but I know nothing about its features. It looks as though it is only a little more advanced than Programmer’s Notepad.

When we get into the professional packages, the pricing really jumps. Now you’ll be spending several thousands of dollars to purchase and several hundred dollars in maintenance fees. Since this is way out of the range of most hobbyists, I am just going to drop names. If you want to take a look, check out their web sites. The big name in AVR development is IAR.  Take a look and see what you think.

C++

It is possible to program the AVR in C++. C++ will take up more code space, but if you are careful it can be done. I am not going to do a full write up as before since most of the tools are the same. Free software again is WinAVR, MHV AVR, and Arduino. They allow C++ programming. Arduino does have some built-in functions that do make life a little easier. As for pro packages, look at IAR. I am not sure if other vendors do C++, but as I always say “just look at their website”.

Finally…

We made it to the end. As you can see there is more information out there than I can fit into a blog. There were a few things I left out of this last article. There are a few free IDEs that I forgot to mention. The one that I use is Eclipse. I plan to show you how to set up a free development environment using Eclipse in a later series of articles. I will add other tools to my Eclipse installation that will make it look and act like a professional package costing thousands of dollars – all free!

So see you next time when we start designing a new brain for my robot.

AVR Overview – Hardware

Hardware

This time I am going to discuss hardware platforms, mainly where you can get them. There are many vendors where you can get board with an AVR micro on it. I am just going to mention a few that I have dealt with before. I am going to move quick, so I hope you can keep up.

Atmel

I am going to start with Atmel. Through Digikey, Atmel sells the AVR Butterfly. The Butterfly has a mega169V micro, a LCD, joystick, and tons of I/O. The board runs about $20 from Digikey. If you read the magazine Nuts & Volts, you might have seen the articles “Smiley’s Workshop”. He uses the Butterfly to teach C programming for the AVR. I recommend you check out the articles.

Pololu

Pololu is another vendor, and a great place to get robotic parts. They carry a line of sensors, motor drivers, motor controllers, and AVR microcontroller boards. Their Orangutan series of boards range from small 24 pin DIP modules to large multi-micro/multi-board designs. So take a look around Pololu’s web site, you won’t be disappointed.

Sparkfun

All I can say about Sparkfun is WOW! They have more electronic offerings than I can mention. They have a long list of AVR development boards along with other microcontrollers. You will just have to check out there site to see everything.

Wright Hobbies

Wright Hobbies is a smaller supplier of electronics. They have 2 different boards for sale. The first is the M32 DevBoard. It uses the mega32 micro. All of the pins are brought out to headers. The second board is the Chibots Controller board. This board was developed by the owner Eddy Wright for Chibots – the Chicago Area Robotics Group. The Chibot Controller carries a mega48 and a motor driver. The board was designed for some of the simpler robotic games held by Chibots. We will hear more about Wright Hobbies in later articles.

Megabitty

The Megabitty is a very small 1″ square microcontroller board with dual 500mA motor drivers. The chip is a mega8, but could be replaced with a mega48/88/168/328 as they all use the same pin out. You will have to check the Megabitty web site to see where to buy the kit.

Arduino/Freeduino

Un Arduino Diecimila

Image via Wikipedia

I decided to lump these together because they are similar boards. In fact there are many copies of the Arduino platform that you could buy, one of them being the Freeduino. First place to look up information on Arduino is the web site. The Arduino is supported by a very large community committed to the platform. Arduino is a board and a programming environment. The resources are too numerous to list here, so I just suggest doing a search in your favorite search engine, for Arduino.

Next Time…

There are many more options out there, but since I plan to build my own. I will leave the rest of the searching up to you. Next time I am going to talk about programmers and debuggers.

Project Ideas

So some of the electronic project ideas I have had are:

  1. New brain and motor driver board for my Mini Sumo robot
  2. SD card interface to an AVR microcontroller
  3. A DDS Function Generator that can go up to 10MHz
  4. A vision system based off of an Analog Devices Blackfin 531/32/33 DSP
  5. A robot brain for a Hexapod robot
  6. Finally, a CPLD/FPGA experimenter board

I know some of my ideas are robotics related, but as you notice not all of them are. The function generator is just a piece of test equipment I want to build, where as the CPLD/FPGA experimenter’s board is just so I can play around with those devices.

The first thing I am going to be working on is my new brain for my mini sumo ‘bot. The current plan is to use an Atmel mega328 (compatible with Arduino) as the main controller, and maybe add a second controller that only handles the IR object detectors and reports back to the ‘328. Then I need to pick a motor driver chip, and decide if I want to use surface mount or through hole parts. If I go surface mount and other people like my design, they might not be able to build it. If I use all through hole, anyone could build it. I could even go as far as to make it a kit. Then again a surface mount board just looks high-tech and has that “Cool!” or “Wow!” factor. This is something I will have to think about.

Well I just want this to be a quick post, so I am ending it here.