1 / 32

students.iitk.ac/roboclub

http://students.iitk.ac.in/roboclub. MICRO-CONTROLLER:. A microcontroller is the brain of the robot: These are: Integrated Circuits (ICs) Programmable – You can define what they do. This is what makes them different from other simpler ICs, such as AND gates, inverters, etc

jersey
Download Presentation

students.iitk.ac/roboclub

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. http://students.iitk.ac.in/roboclub

  2. MICRO-CONTROLLER: • A microcontroller is the brain of the robot: These are: • Integrated Circuits (ICs) • Programmable – You can define what they do. • This is what makes them different from other simpler ICs, such as AND gates, inverters, etc • Logic tables relating Input and Output can be defined by you • Many useful features built in to the uC itself

  3. ATMEGA 16 • 16 KB Flash Memory… • 40 pin UC… • 32 I/O Pins • These pins have other functions like UART, ADC, SPI, LCD, Interrupt, TIMERS, etc… • But we will now focus on I/O and TIMER… • Maximum Voltage 5V, current rating about 10 milli-amperes

  4. Atmega8

  5. I/O Pins: • Setting Data Direction (I/O?): DDRX Register • PORTX Register • PINX Register

  6. I/O Registers Input / Output is controlled through special variables called “registers”. Registers are actual hardware memory locations inside the μCs with predefined names and sizes. Assigning a value to these registers in the program changes the corresponding hardware configuration. And, these values can be altered multiple number of time at any point in the program. There are 3 registers that control the I/O pins: DDR, PORT and PIN. Each port has it’s own registers. Hence, DDRA, PORTA, PINA registers forport A; DDRB, PORTB, PINB for port B and likewise.

  7. DDR(Data Direction Register) Decides whether the pin is Input or Output. DDR is an 8 bit register. Each bit corresponds to a particular pin on the associated port. If a bit on the DDR register is 0, then the corresponding pin on the associated port is set as input. Similarly, if the bit is 1, then the pin is set as output. If a pin is configured as input, then it has some floating voltage unless an external voltage is applied. For an output pin, the voltage is fixed to a particular value.

  8. Setting Register Values MSB of DDRA corresponds to the pin A7. If DDRA = 0b10010110, then:

  9. PORT register PORT is also an 8 bit register. The bits on the PORT register correspond to the pins of the associated port in the same manner as in the case of the DDR register. PORT is used to set the output value. If the pin is set as output, then a PORT value of 1 will set voltage at that pin to 5V, and PORT value 0 sets the voltage to 0V. If the pin is configured as an input, PORT value serves the purpose of pull up or pull down.

  10. PIN register PIN is a register whose value can be read, but cannot be changed inside the program. It gives the value of the actual voltage at a particular pin. 1, if the value at the required pinis 5V and 0 for 0V.

  11. Summary

  12. Tools Required -> CVAVR

  13. Compiler -> CVAVR The code is written in C language so we need to convert it into the format that Atmega understands .

  14. Transfer code to Atmega AVR Studio

  15. Avr Programmer

  16. So we need two softwares overall a) CVAVR –> Editor and Compiler b) Avr Studio –> Transfer Code to Atmega

  17. While & For While (conditon) { … ... } for(initialisation; condition; increment) { … … }

  18. Lets Begin by blinking a simple LED

  19. How to program a microcontroller: • A microcontroller understands only binary language (0 and 1)…We write the code in C language in CVAVR (Compiler + IDE). • We compile the code to generate the .hex file (which the machine understands) • We transfer the .hex file to Atmega using a Programmer Hardware: Serial Programmer, STK 500, USB etc… (Contains chips to convert voltage levels and protocols) Software: AVR Studio, AVRDUDE, etc…

  20. Programmer Pin connection with Atmega 8

  21. How to Run Motors through UC? • The Atmega16 has a current rating of 5-10 mA. • The normal DC motor’s current ratings start from 150 mA and above. • So the motor cannot be directly attached to the Atmega, hence a motor-driver is used… (eg: L293, L298, etc…)

  22. TIMERS: • Atmega has: • Timer 0, 8 bit (OC0 at PB3) • Timer 1, 16 bit (2 parts A and B each of 8 bit, OC1A at PD5, OC1B at PD4) • Timer 2, 8 bit (OC2 at PD7) • There are 2 clocks: • System Clock (fs) • Timer Clock (ft = fs or fs/8 or fs/64 or ….)

  23. (For generating 38 KHz in TSOP Sensors)

  24. (For MOTORS)

  25. NOW LET US HAVE A LOOK AT CVAVR AND AVR STUDIO AND HOW TO PRACTICALLY PROGRAM AN ATMEGA 16

  26. THANK YOU

More Related