1 / 7

Atmega32 Microcontroller

Atmega32 Microcontroller. This is a small computer with an RTOS, Real Time Operating System, running on it. Honestly, this is more powerful than you will ever need for any robot.

beau
Télécharger la présentation

Atmega32 Microcontroller

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Atmega32 Microcontroller • This is a small computer with an RTOS, Real Time Operating System, running on it. Honestly, this is more powerful than you will ever need for any robot. • This chip along with most microcontrollers is made up of various types of I/O. With respect to robotics and art we can program these chips to do anything. Ask me, anything! • We will use them to: • Control servomotors (for dog legs and wheels) • Read and log data from sensors (for sensing toxins) • React to sonar for mobile guidance • Interface with other software (LabVIEW) for data analysis

  2. Atmega32Specs • Review front page specs on Atmega32 Microcontroller at: http://www.atmel.com/dyn/resources/prod_documents/2503S.pdf • The Atmega32 is an 8 bit RISC microcontroller. • Pronounced risk, acronym for Reduced Instruction Set Computer, a type of microprocessor that recognizes a relatively limited number of instructions keeping it simple and yet fast. • 8 bit tells us how much information each register can support. It refers to information stored or processed; there are 256 different operations stored/processed per 8 bit register.

  3. Hex/Binary/Decimal Conversion • Go to pg. 63 of the atmega32 manual to look at registers: http://www.atmel.com/dyn/resources/prod_documents/doc2503.pdf • In order to access registers, or turn things on and off you need to be able to convert between these numbering schemes. • Binary: 1s and 0s. • Decimal: 1, 2, 3, 4, 5…..100, 101…, base 10 • Hexidecimal: 0xc1, base 16 • Here’s a great source: http://www.stcsc.edu/OCL/hex_to_decimal_conversion.htm

  4. Embedded C Programming in 1 Slide • Functions: main, void, int, return • Loops: If else, while, for, do while etc. • Commenting: //, /* • End commands with a semi-colon ; yourMom(void); • There are many ways to program an operation. The efficient way is preferred because it saves processor time.

  5. Programming Order of Operations • Write pseudo code: basically a flowchart of the program, so you don’t immediately bog yourself down with code and syntax. • Write your program in a code editor (WinAVR, Emacs, etc.) • Compile (Gnu-GCC) and then debug if necessary. Compilers figure out if your code has errors; if it does, it will point them out and you can fix them; if it doesn’t, it will create machine code in the form of a *.hex file. • Send the *.hex file to the microcontroller using Hyperterminal or some other serial port terminal program. • Run your program!

  6. Programming Example #include <avr/io.h> void delay(void) { volatile int i,j; for (j=0; j < 10; j++) for (i=0; i < 0xFFFF; i++) ; } int main(void) { DDRB = 0xFF; // set port B to outputs PORTB = 0x01; // write to PA0 on PORTB delay(); //delay for about 1 second PORTB = 0x00; // do not write anything return 0; }

  7. Avr-libc Libraries • All microcontrollers have libraries of functions for use in your programs, so that you don’t always have to rewrite common algorithms. • Examples: timer.c, pwm.c, a2d.c, servo.c etc etc. • You can call use a library by including the header file at the top of your program: #include "timer.h“ // include timer function library (timing, PWM, etc)

More Related