290 likes | 593 Views
The Firefly, WinAVR, and Programming in C. Botrics Firefly Overview. Atmel 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). Motor Control.
E N D
Atmel 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)
Motor 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.
Serial 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.
Analog 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.
Digital 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.
Other 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.
Other 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.
WinAVR • 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/
WinAVR • 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.
WinAVR • 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.
WinAVR 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 AVRDownloader and Uploader is just that – a program that interfaces between the Firefly and the host computer to program and read the ATmega168.
Programmers 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
Programmers Notepad Menu bar File tabs Current file Output Status bar
Programmers NotepadWriting Your Code File tabs Current file
Programmers NotepadCompiling Your Code Click! Output
Programmers NotepadProgramming Your Robot Click! Output
The Workaround Some cluster PCs don’t let you click “make all” and “make program”
The Workaround … so you’ll have to tell the computer to run the commands manually.
The Workaround … so you’ll have to tell the computer to run the commands manually. Move to the folder with your code
The Workaround … so you’ll have to tell the computer to run the commands manually. Tell the computer where to find WinAVR
The Workaround … so you’ll have to tell the computer to run the commands manually. Compile your code
The Workaround … so you’ll have to tell the computer to run the commands manually. Program your code onto the robot