0
MICROCONTROLLER<br />THE BRAIN<br />
WHAT ARE MICROCONTROLLERS ?<br />A micro-controller (also MCU or µC) is a functional computer system-on-a-<br />chip. It c...
WHERE WE USE THEM…???<br />
Basic block diagram of a microcontroller<br />
CPU : <br />CPU does all the arithmetic and logic operations.<br />It controls the flow of execution of instructions.<br />
RAM ( Random Access Memory) :<br />RAM holds the set of instructions (program), i.e. being executed by the CPU.<br />It ho...
ROM ( Read Only Memory) :<br />ROM holds very important data and initialization about the microcontroller.<br />It holds t...
Flash Memory :<br />Flash memory is basically EEPROM.<br />It holds the program written by the user.<br />The program can ...
I/0 Ports :<br />Every microcontroller has I/O ports.<br />Each port is made up of n-pins ( mostly 8 pins).<br />Each pin ...
ADC :<br />Most of the real world signals are analog in nature.<br />But a microcontroller is a digital device, thus it ca...
TIMERS :<br />In many applications, time keeping is a must. Eg. If you heating a meal in an oven.<br />Thus microcontrolle...
SOME COMMON MICROCONTROLLERS<br /> Intel - 8051<br /> Atmel – Atmega 16 <br /> PIC<br /> ARM<br />
Question: How a microcontroller works ??? <br />Answer: Microcontroller consists of a Microprocessor (CPU i.e. Central pro...
Question: How to make the code ? <br />Answer: You basically write the program on your computer in any of the high level l...
Question: How to feed the code in the flash of Microcontroller ? <br />Answer: Assuming you have the machine file (.hex) r...
ATMEGA 16 MICROCONTROLLER<br />Manufacturer :  ATMEL CORPORATION,         	            USA.<br />http://www.atmel.com/<br />
ATMEGA 16 SPECIFICATIONS :<br /> Advanced RISC Architecture <br />131 Powerful Instructions – Most Single-clock Cycle Exec...
PIN CONFIGURATION :<br />
Registers<br />All the configurations in a microcontroller is set through 8 bit (1 byte) locations in RAM (RAM is a bank o...
For example : <br />
Digital Input Output Port<br />So let’s start with understanding the functioning of AVR. We will first discuss about I/O P...
Data Direction Register, DDRn<br />Determines the direction of individual pins of ports.<br /> If the bit of the DDR is se...
Port Pin Register, PINn<br />Reading the input pins of port is done by reading PIN register<br />Temp = PINA;<br />Read th...
Port Drive Register, PORTn<br />If the pin is configured as output (DDRn [x] = 1) PORTn register drives the corresponding ...
Port Drive Register, PORTn<br />For pins configured as input (DDRn[x] = 0) microcontroller connects a internal pull up res...
Buzzer On / OFF<br />Buzzer is connected to pin 7 of PORT B.<br />Pin is configured as output<br />DDRB= 0x80;<br />To tur...
Buzzer Function<br />void Buzzer_ON(void)<br />{<br />  PORTB = 0x80;<br />}<br />void Buzzer_OFF(void)<br />{<br />  PORT...
Bump Switch<br /> PORTC (0)<br /> Input port<br />DDRC= 0x00;<br /> Internal pull up<br />PORTC = 0x01;<br /> To read inpu...
void main(void)<br />{<br />init_devices();<br />   //insert your functional code here...<br />   while(1)                ...
WALL HUG USING BUMP SWITCHES:<br />PC2<br />PC3<br />PC1<br />PC4<br />PC0<br />
This is PORTB<br />Pin 0 is connected to LED0.<br />Pin 1 is connected to LED1.<br />Pin 2 is connected to LED2.<br />Pin ...
ADC<br />Analog To Digital Converter<br />
Analog To Digital Converter<br /> 10 bit resolution<br /> 8 channels<br /> PORTA(0 – 7) – (ADC1-ADC7)<br /> Disable intern...
Theory of operation <br />What we have seen till now that the input given to uC was digital, i.e., either +5 V (logic 1) o...
Microcontroller
Upcoming SlideShare
Loading in...5
×

Microcontroller

9,684

Published on

Published in: Technology, Business
1 Comment
6 Likes
Statistics
Notes
  • Hi gys,
    I am student of ece from itm, mahrajganj. i am looking a project for device control using sms.
    pl help us.
    d sahani
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
9,684
On Slideshare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
789
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide

Transcript of "Microcontroller"

  1. 1. MICROCONTROLLER<br />THE BRAIN<br />
  2. 2. WHAT ARE MICROCONTROLLERS ?<br />A micro-controller (also MCU or µC) is a functional computer system-on-a-<br />chip. It contains a processor core, memory and programmable input/output <br />peripherals.<br />Micro suggests that the device is small and controller tells you that the device <br />might be used to control objects, processes or events. <br />Another term to describe a microcontroller is embedded controller because <br />the microcontroller and its support circuits are often built into or embedded<br />in the devices they control.<br />
  3. 3. WHERE WE USE THEM…???<br />
  4. 4. Basic block diagram of a microcontroller<br />
  5. 5. CPU : <br />CPU does all the arithmetic and logic operations.<br />It controls the flow of execution of instructions.<br />
  6. 6. RAM ( Random Access Memory) :<br />RAM holds the set of instructions (program), i.e. being executed by the CPU.<br />It holds important data required by the program.<br />It holds some important data structures like ‘stack’.<br />It is volatile in nature.<br />
  7. 7. ROM ( Read Only Memory) :<br />ROM holds very important data and initialization about the microcontroller.<br />It holds the monitor program.<br />It is written by the manufacturer.<br />
  8. 8. Flash Memory :<br />Flash memory is basically EEPROM.<br />It holds the program written by the user.<br />The program can be erased or written here many times. ( Specified by the manufacturer)<br />
  9. 9. I/0 Ports :<br />Every microcontroller has I/O ports.<br />Each port is made up of n-pins ( mostly 8 pins).<br />Each pin can be configured as either input pin or output pin.<br />If a pin is input pin, it accepts data from the device it is connected to.<br />If a pin is output pin, it sends the data to the device it is connected to.<br />Thus these pins form the input/output medium for the microcontrollers.<br />
  10. 10. ADC :<br />Most of the real world signals are analog in nature.<br />But a microcontroller is a digital device, thus it cannot process analog signals.<br />Thus all microcontrollers have built in A-D converters.<br />ADC digitizes an analog signal and gives it to the microcontroller for further processing.<br />
  11. 11. TIMERS :<br />In many applications, time keeping is a must. Eg. If you heating a meal in an oven.<br />Thus microcontrollers have timers to measure time.<br />
  12. 12. SOME COMMON MICROCONTROLLERS<br /> Intel - 8051<br /> Atmel – Atmega 16 <br /> PIC<br /> ARM<br />
  13. 13. Question: How a microcontroller works ??? <br />Answer: Microcontroller consists of a Microprocessor (CPU i.e. Central processing Unit) which is interfaced to RAM (Random Access Memory) and Flash Memory (EEPROM). You feed your program in the Flash Memory on the microcontroller. Now when you turn on the microcontroller, CPU accesses the instructions from RAM which access your code from Flash. It sets the configuration of the pins and then start performing according to your program. <br />
  14. 14. Question: How to make the code ? <br />Answer: You basically write the program on your computer in any of the high level languages like C, C++, JAVA etc. Then you compile the code to generate the machine file. <br /> All the machines understand only one language, 0 & 1 that is on and off. Now this 0 & 1 both corresponds to 2 different voltage levels for example 0 volt for 0 logic and +5 volt for 1 logic. Actually the code has to be written in this 0, 1 language and then saved in the memory of the microcontroller. But this will be very difficult task. So we write the code in the language we understand (eg. C) and then compile and make the machine file “.hex”. After we make this machine file we feed this to the memory of the microcontroller. <br />
  15. 15. Question: How to feed the code in the flash of Microcontroller ? <br />Answer: Assuming you have the machine file (.hex) ready and now you want to feed that to the flash of the microcontroller. Basically you want to make communication between your computer and microcontroller. Now computer has many communication ports such as Serial Port, Parallel Port and USB (Universal Serial Bus). <br /> Let’s take Serial Port, it has its own definition that is voltage level to define 0 & 1. Serial Port&apos;s protocol is called as UART (Universal Asynchronous Receiver & Transmitter). Its voltage levels are : +12 volt for 0 logic and -12 volt for 1 logic. <br /> Now the voltage levels of our microcontroller are based on CMOS (Complementary Metal Oxide Semiconductor) technology which has 0 volt for 0 logic and +5 volt for 1 logic. Two different machines with 2 different ways to define 0 & 1 and we want to exchange information between them. Consider microcontroller as a French and Computer&apos;s Serial Port as an Indian person. If they want to exchange information they basically need a mediator who knows both the language. He will listen one person and then translate to other person. Similarly we need a circuit which converts CMOS (microcontroller) to UART (serial port) and vice versa. This circuit is called as programmer. Using this circuit we can connect computer to the microcontroller and feed the machine file to the flash. <br />
  16. 16. ATMEGA 16 MICROCONTROLLER<br />Manufacturer : ATMEL CORPORATION, USA.<br />http://www.atmel.com/<br />
  17. 17. ATMEGA 16 SPECIFICATIONS :<br /> Advanced RISC Architecture <br />131 Powerful Instructions – Most Single-clock Cycle Execution<br />32 x 8 General Purpose Working Registers<br /> Up to 16 MIPS Throughput at 16 MHz <br /> 16K Bytes of In-System Self-Programmable Flash <br /> 512 Bytes EEPROM <br /> 1K Byte Internal SRAM <br /> 32 Programmable I/O Lines <br /> In-System Programming by On-chip Boot Program <br /> 8-channel, 10-bit ADC <br /> Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes <br /> One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture <br /> Four PWM Channels <br /> Programmable Serial USART <br /> Master/Slave SPI Serial Interface <br /> Byte-oriented Two-wire Serial Interface <br /> Programmable Watchdog Timer with Separate On-chip Oscillator <br /> External and Internal Interrupt Sources <br />
  18. 18. PIN CONFIGURATION :<br />
  19. 19.
  20. 20. Registers<br />All the configurations in a microcontroller is set through 8 bit (1 byte) locations in RAM (RAM is a bank of memory bytes) of the microcontroller called as Registers. <br />All the functions are mapped to its locations in RAM and the value we set at that location that is at that Register configures the functioning of microcontroller. <br />There are total 32 x 8bit registers in Atmega-16. As Register size of this microcontroller is 8 bit, it called as 8 bit microcontroller. <br />
  21. 21. For example : <br />
  22. 22. Digital Input Output Port<br />So let’s start with understanding the functioning of AVR. We will first discuss about I/O Ports.<br />Atmega 16 has 32 I/O (Input/Output) pins grouped as A, B, C & D with 8 pins in each group. This group is called as PORT. <br /> PA0 - PA7 (PORTA) <br /> PB0 - PB7 (PORTB) <br /> PC0 - PC7 (PORTC) <br /> PD0 - PD7 (PORTD) <br />
  23. 23. Data Direction Register, DDRn<br />Determines the direction of individual pins of ports.<br /> If the bit of the DDR is set (1) the corresponding pin of the port is configured as output pin<br /> If the bit of the DDR is cleared (0) the<br /> corresponding pin of the port is configured as<br /> input pin.<br />DDRA = 0xF0;<br /> 4 MSB pins of PORTA are output pins<br /> 4 LSB pins of PORTA are input pins<br />
  24. 24. Port Pin Register, PINn<br />Reading the input pins of port is done by reading PIN register<br />Temp = PINA;<br />Read the PORTA input and store in temp variable<br />
  25. 25. Port Drive Register, PORTn<br />If the pin is configured as output (DDRn [x] = 1) PORTn register drives the corresponding value on the output pins<br />DDRA = 0xFF;<br />PORTA = 0xF0;<br />Output logic high on 4 MSB pins and logic low on 4 LSB pins<br />
  26. 26. Port Drive Register, PORTn<br />For pins configured as input (DDRn[x] = 0) microcontroller connects a internal pull up resistor if the corresponding bit of PORTn is set<br /> If the PORTn bit is cleared, pin is Tristated<br /> DDRA = 0x00;<br /> PORTA = 0xF0;<br />
  27. 27. Buzzer On / OFF<br />Buzzer is connected to pin 7 of PORT B.<br />Pin is configured as output<br />DDRB= 0x80;<br />To turn on the buzzer output high<br />PORTB = 0x80;<br />To turn off the buzzer output low<br />PORTB = 0x00;<br />
  28. 28. Buzzer Function<br />void Buzzer_ON(void)<br />{<br /> PORTB = 0x80;<br />}<br />void Buzzer_OFF(void)<br />{<br /> PORTB = PORTB & 0x7F;<br />}<br />
  29. 29. Bump Switch<br /> PORTC (0)<br /> Input port<br />DDRC= 0x00;<br /> Internal pull up<br />PORTC = 0x01;<br /> To read inputs<br />portc_copy = PINC<br />
  30. 30. void main(void)<br />{<br />init_devices();<br /> //insert your functional code here...<br /> while(1) //open continuous loop (while)<br /> {<br />portc_copy = PINC; //read contents of port C into the portc_copy variable<br /> if(portc_copy == 0x01) //check if any switch is pressed by comparing bitwise with //0x01 (&apos;==&apos; comparison)<br /> {<br /> PORTB = 0x00; //if condition is true turn OFF buzzer by giving PORTB = 0x00<br /> }<br /> else //if condition is false turn ON buzzer to<br /> { //indicate bump switch is pressed by giving PORTB = 0x80<br /> PORTB = 0x80; <br /> }<br /> }<br />}<br />
  31. 31. WALL HUG USING BUMP SWITCHES:<br />PC2<br />PC3<br />PC1<br />PC4<br />PC0<br />
  32. 32. This is PORTB<br />Pin 0 is connected to LED0.<br />Pin 1 is connected to LED1.<br />Pin 2 is connected to LED2.<br />Pin 3 is connected to LED3.<br />Pin 4 is connected to LED4.<br />
  33. 33. ADC<br />Analog To Digital Converter<br />
  34. 34. Analog To Digital Converter<br /> 10 bit resolution<br /> 8 channels<br /> PORTA(0 – 7) – (ADC1-ADC7)<br /> Disable internal pull up<br /> ADCH & ADCL – Data Register<br /> ADMUX- Channel Select Register<br /> ADCSR – Control & Status Register<br />
  35. 35. Theory of operation <br />What we have seen till now that the input given to uC was digital, i.e., either +5 V (logic 1) or 0V (logic 0). But what if we have an analog input. Then we require a tool that converts this analog voltage to discrete values. Analog to Digital Converter (ADC) is such a tool.<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×