How to Guide AVR

From GT RoboJackets

Jump to: navigation, search
The Butterfly

Contents

Introduction

The AVR butterfly is an all-in-one super dev kit for Atmel's Atmega169P micro-controller. It includes all sort of toys including a temperature sensor, a voltage sensor, light sensor, buzzer, real-time clock capability, 3V coin cell battery holder, an LCD and a pin so you can proudly wear your embedded creation. And you get all this for the super low price of $21.00 from Digikey.com! The butterfly comes shipped with a little application program that allows you to play with all the devices on the board but you can upload your own code via a serial port and a loader such as AVRdude. There are several options for compilers to build programs for the butterfly and other AVR chips, with the most popular (and free) choice being the gnu tool-set which can either be built from source in Linux or installed in Windows with the WinAVR program.

Hardware

The AVR butterfly comes out the box with all the hardware you need to get it up an running and displaying all kinds of useless info. But before you can develop programs for the butterfly you will need to add a few pieces of hardware.

Headers

The butterfly come with through-holes for all the ports but no headers. The first thing that needs to be added are pin headers for each port. This shouldn't be that hard to add if you know how to use a soldering iron. The pitch of the through-holes is the standard 0.1. Below is a pin-out for the AVR. Note that PORTD is used to drive the LCD along with a pin from PORTB. If you are using the LCD you can't use these pins.

AVR Pinout
Serial Header and Cable
AVR Serial Connections

In the picture to the above you can see how to hook-up a serial connector to the AVR so you can program it. The red wire in the picture goes to TXD (Pin 2) on the serial connector; the blue wire to RXD (Pin 3;) and the green wire is of course ground (Pin 5). On the AVR side the number is from the top down. If you don't have serial on your laptop or computer we have serial to usb converters.

Installing the tools

The popular gnu toolset is used to compile C/C++ source code for the butterfly. You can either install the toolset in Windows with WinAVR or build the tools in linux

Windows

Go to the WinAVR website and download the installer and follow the directions. Easy as cake.

Linux

This may take some work depending on your system. The AVRLibc page has great instructions that are easy to follow. You also want to install the latest tools as support for the LCD in AVRLibc is a fairly recent development. Remember to set your paths, both your bintils and your library. For a little easier install see a script that someone on AVRFreaks wrote up. If you need help installing the tools the avrfreaks.net forum is a great resource.

Ubuntu

For people running Ubuntu (Gutsy or newer), you can just run the following command to install what you need.

sudo aptitude install avrdude gcc-avr avr-libc

Note For me the above didn't work. For some reason the gcc-avr package does not install the latest version of gcc. Support for the LCD didn't come until 4.0? (Not quite sure on that. I built it with 4.1.1) You also need the latest stable version of avr-libc because again no LCD support.

NOTE: If you plan on using a USB-SERIAL converter make sure to also remove the brltty package as it will interfere with the USB-SERIAL port. This can be done with:

sudo aptitude purge brltty

Training Sessions Using the AVR

Overview

RoboJackets is offering a tool training class in using the AVR and micro-controllers in general. The classes which take place each Sunday, are about one to two hours long and are designed take members who are new to the AVR or micro-controllers in general and use the Butterfly dev kit to teach embedded design concepts. No experience is necessary to take any of the classes though they taught as if all the attendees have attended each class in order. In other words there will be no review or backtracking. There are though some recommended requirements:

  • A laptop running XP, Vista, or Ubuntu (OS X users, sorry your on your own here)
  • The Butterfly
  • The recommended electronics goodie bag. (The parts list can be accessed here.)
  • Some ability to code

The goodie bag is good to have because it allows the participant the opportunity to work on each weeks project from home.

Format and Class topics

Each weeks class will cover a set of topics relating to a small project that will be started at the end of the session. Participants are encouraged to complete each weeks project and prizes will be given to those who do. Working code for each project will be handed out or otherwise sent to participants at the beginning of each session.

Class Topics

Week One: Introduction to Micro-Controllers
In this session we will talk about the basics of micro-controllers and embedded design. The project for the week leading up to and following this first session is to install the dev-tools, build the serial header, install the reset switch, build the 5V supply, and upload code to the butterfly. A prize will be given for having a working development environment (Installed tools, modified Butterfly, and GCC compiled app code) by the following week.

Week Two: Attack of the Cylons
Now that you have a micro that you can send code to, its time to put it to good use. The topics for this session will be assembly and C code for AVRs, port I/O circuits and software interface, clocks and timers, and LEDs. We will we will then use some LEDs to build some | Cylon eyes thereby moving man on step closer to the robot apocalypse! We will use several methods to make the LEDs blink. Again a prize is given for completing the project.

Week Three: $20 Thermometer




Example Code

  • Comming Soon. Look on the net if you want it know.

Links

AVRFreaks www.avrfreaks.net AVR Lib C Homepage

http://www.nongnu.org/avr-libc/

AVRDude (avr isp programmer)

http://www.nongnu.org/avrdude/

AVR Butterfly Development Platform

http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3146

Butterfly Application Code (GCC port) http://www.siwawi.arubi.uni-kl.de/avr_projects/

Personal tools