Title: The Firefly, WinAVR, and Programming in C
1The Firefly, WinAVR, and Programming in C
2Botrics Firefly Overview
3Atmel AVR ATmega168 Microcontroller
- The brains of your robot.
- Runs at 8MHz.
- 16Kb Flash ROM
- 1Kb SRAM
- Uses five volts regulated power (the battery puts
out around six)
4Motor Control
The L293 H-Bridge takes input from the
microcontroller about how fast and in what
direction to run the motors and then puts out
enough current to do so. The motors are run
directly from the battery voltage.
The outputs of the H-Bridge are pinned out here.
5Serial Communications
The serial port connector, a female DB9.
The MAX232 buffer driver chip converts the TTL
logic level serial communications on the
microcontroller (5V/0V) to standard RS-232 logic
levels (0V/-12V). Basically, all you need to
know is that this is how your computer talks to
the robot.
6Analog Input
The microcontroller has eight analog input ports,
labeled C0-C7. The Firefly allows easy access to
C0-C5. Each port samples the voltage presented
at it between 0 and 5 volts and translates this
to a number between 0 and 255. Readings below 0
volts read 0 readings above 5 volts read 255.
The potentiometer is attached to port C6.
Rotating the dial reduces the voltage on C6 in
one direction and increases it in another.
7Digital Input/Output
The buttons are convenient digital inputs,
reading 0 if not pressed or 1 if depressed.
The analog ports are also capable of digital
input and output.
8Other Output
The power LED is a small red light which
indicates whether or not the Firefly is receiving
power. It does not tell you if it is receiving
enough, however.
The piezo buzzer can output tones of varying
frequencies.
The orb is three LEDs (red, green, and blue) in
one package surrounded by a diffuser. It can
output around sixteen million colors.
The user LED is a small green light useful for
displaying one bit of information.
9Other Important Things
Power switch.
Battery connector.
Fuse. If this blows, your robot will
mysteriously stop working.
Five volt regulator keeps the processor happy
by keeping the voltage constant.
In-System Programming Header for initially
programming the ATmega168.
10WinAVR
- WinAVR (pronounced "whenever") is a suite of
executable, open source software development
tools for the Atmel AVR series of RISC
microprocessors hosted on the Windows platform.
It includes the GNU GCC compiler for C and C. - http//winavr.sourceforge.net/
11WinAVR
- GNU Binutils 2.15
- GNU GCC 3.4.3
- avr-libc 1.2.3
- avrdude 4.4.0 cvs (native Win32 app)
- uisp 20050207
- avrdude-gui 0.2.0
- GNU Debugger (GDB) 6.1
- Insight 6.1
- avarice 2.3
- simulavr 0.1.2.1
- SRecord 1.21
- MFile
- Programmers Notepad 2.0.5.32
- Many native Win32 GNU programs and utilities
including make and bash. - Documentation in many formats for the various
projects. - Makefile Template that you can copy and modify
for your projects.
12WinAVR
- GNU Binutils 2.15
- GNU GCC 3.4.3
- avr-libc 1.2.3
- avrdude 4.4.0 cvs (native Win32 app)
- uisp 20050207
- avrdude-gui 0.2.0
- GNU Debugger (GDB) 6.1
- Insight 6.1
- avarice 2.3
- simulavr 0.1.2.1
- SRecord 1.21
- MFile
- Programmers Notepad 2.0.5.32
- Many native Win32 GNU programs and utilities
including make and bash. - Documentation in many formats for the various
projects. - Makefile Template that you can copy and modify
for your projects.
13WinAVR
The Gnu Compiler Collection is a set of open
source compilers (including C and C) which are
essentially free (GPLed). They are of a high
quality and conform to ANSI standards. Compiling
produces machine code in a HEX file that the AVR
ATmega168 can understand.
AVR Libc is a high quality C library for use with
GCC on Atmel AVR microcontrollers.
The AVR Downloader and Uploader is just that a
program that interfaces between the Firefly and
the host computer to program and read the
ATmega168.
14Programmers Notepad
15Programmers Notepad
- Programmers Notepad is the IDE we will use in
FwR. - IDE stands for Integrated Development
Environment. - Write your code
- Compile your code
- Download your code to the robot
16Programmers Notepad
Menu bar
File tabs
Current file
Output
Status bar
17Programmers NotepadWriting Your Code
File tabs
Current file
18Programmers NotepadCompiling Your Code
Click!
Output
19Programmers NotepadProgramming Your Robot
Click!
Output
20The Workaround
Some cluster PCs dont let you click make all
and make program
21The Workaround
so youll have to tell the computer to run the
commands manually.
22The Workaround
so youll have to tell the computer to run the
commands manually.
Move to the folder with your code
23The Workaround
so youll have to tell the computer to run the
commands manually.
Tell the computer where to find WinAVR
24The Workaround
so youll have to tell the computer to run the
commands manually.
Compile your code
25The Workaround
so youll have to tell the computer to run the
commands manually.
Program your code onto the robot