Presentation is loading. Please wait.

Presentation is loading. Please wait.

MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable.

Similar presentations


Presentation on theme: "MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable."— Presentation transcript:

1 http://students.iitk.ac.in/roboclub

2 MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. 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 3. Many useful features built in to the uC itself

3 ATMEGA 16 16 KB Flash Memory… 40 pin U C… 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

5 Atmega8

6 I/O Pins: Setting Data Direction (I/O?): DDRX Register PORTX Register PINX Register

7 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 for port A; DDRB, PORTB, PINB for port B and likewise.

8 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.

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

10 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.

11 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.

12 Summary

13 Tools Required -> CVAVR

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

15 Transfer code to Atmega AVR Studio

16 Avr Programmer

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

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

19

20 Lets Begin by blinking a simple LED

21 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…

22 Programmer Pin connection with Atmega 8

23

24

25

26 How to Run Motors through U C? 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…)

27 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 ….)

28

29 (For generating 38 KHz in TSOP Sensors)

30 (For MOTORS)

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

32 THANK YOU


Download ppt "MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable."

Similar presentations


Ads by Google