Friday 7 August 2015

BASICS OF MICRO CONTROLLER

BASICS OF MICRO CONTROLLER:



        Processor are two types:
                   
                       1.System on chip, integrated processors all are placed combine.
                     
                        2.stand-alone processor.



WHAT IS MICRO CONTROLLER:-


                Micro controller may be  called """"""computer on chip""""""" since it has basic features
of micro controller with internal  ROM, RAM, PARALLEL and  SERIAL PORTS with in single chip.


                             OR
   Micro processor with memory and ports is called as  micro controller

APPLICATION:


**Washing machines,
**AC'S
**ROBOTICS
**INDUSRIES



HISTORY:

               


The 8051 Micro controller is first micro controller of MCS-51 family introduced by INTEL corporation at end of 1970's.


           It 8 bit micro controller, means it can read, write and process 8 bit data. this is mostly used in robotics and industries etc.....

 FEATURE:


** It is a 40 pin IC/dip
**   It has 4 i/o ports
**   1 serial port
**  128 byte RAM
**  4KB ROM
**  2 TIMERS
** 5 INTERRUPTS


ROM:

          In 8051, 4 KB read only memory(ROM). It is useful for storing program. It is a Non volatile memory. We can interface up to 64 KB ROM memory externally.


WE WILL DISCUSS SLOWLY one by one


*****************************************************************************



DATA BUS:

                     It is transfer the data with in """""microprocessor and  Input and out put devices"""".

if 8 bit micro controller  has 8 bit data bus.
if 16 bit micro controller has 8 bit, 16 bit  data bus.


ADDRESS BUS:

 
                         It is to specify the address.



CONTROL BUS:


                        Micro processors uses control bus to process data, that is what do with selected memory allocation.  some control signals are read,write, op code fetch etc.
various operations are performed by micro processor with help of control bus,


                                           TIMERS/COUNTERS


INTRODUCTION:-



  • In 8051,  2 timers are there  i.e  T0, T1. These  timer are 16 bit registers
  • The timer puls run at 1/12th clock cycle.
  • The clock frequency for serial communication is 11.0592 M Hz 
  •  So a single machine cycle run "1" instruction the timing is =1.0892 us i.e  {12/11.0592 M Hz} 
APPLICATIONS:-
  • Generate a delay 
  • Event Counter
  • Baud rate for serial communication
  • Timers can be used as a timer as well as counter but not at a time
  • each timer is a 16 bit wide
  • Each timer can split two equal  parts  i.e TL{0/1} and  TH{0/1}
FOR T0:


15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0

<----------------TH0------------------------------------> <-------------------------TL0------------------------>


FOR T1:


15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0

 <----------------TH0------------------------------------> <-------------------------TL0------------------------>
                                                                                   

Timer registers:-


  • In 8051, six timer registers are there 
  1. TMOD Register
  2. TCON Register
  3. TH0
  4. TL0
  5. TH1
  6. TL1

TMOD REGISTER:-

  • TMOD Register is a 8 bit register. 
  • Which is a Byte addressable register.
  • This register is used for timer mode section , timer  start by what  and finally  timer or counter selection either timer 0 or timer 1
              i.e   We should n't set bit by bit in this register

        
7
G
6
C/T
5
M1
4
M0
3
G
2
C/T
1
M1
0
M0

                <--------------TIMER1---------------------------> <------------TIMER0---------------------------->

GATE (G);-

  •    If  G=0, Then Timer start by  software  / Program
  •    If   G=1, Then Timer start by Hardware /  External   
COUNTER / TIMER  (C/T);-

  • If  (C/T)=0 , i.e  Timer will be selected
  • If (C/T)=1, i.e  Counter will be selected

MODE SELECTION BITS (M1,M0):-



M1

M0

MODE

SELECTION

0


0

0

13 BIT TIMER

0

1

1

FULL 16 BIT TIMER

1

0

2

8 BIT AUTO RELOAD TIMER

1

1

3

SPLIT TIMER

















TCON:-

  • Timer Control register is 8 bit register.
  • It is bit addressable register.  i.e  we can change bit by bit
  • Timer control register is used to  control the timer i.e we can start and stop by using this register

  • TIMER OVER FLOW FLAG [TF]:-
                  This  TIMER OVER FLOW  SET by  hardware  i.e TF=1   When the timer gets overflow.
               
                   FOR TIMER0:-
                       
                                        TF0=1
                    
                    FOR TIMER1:-
           
                                        TF1=1


                 This TIMER OVERFLOW  FLAG is CLEAR by software, when the timer  is overflow.


                              FOR TIMER0:-
                       
                                        TF0=0
                    
                              FOR TIMER1:-
           
                                        TF1=0
  • TIMER CONTROL  BIT [ TR  ]:-
                                If  TR bit is SET then the timer will start.

                                           
                              FOR TIMER0:-
                       
                                        TR0=1
                    
                              FOR TIMER1:-
           
                                        TR1=1

     
                              If TR bit  is CLEAR then the timer will stop.


                                  
                              FOR TIMER0:-
                       
                                        TR0=0
                    
                              FOR TIMER1:-
           
                                        TR1=0

  • EXTERNAL INTERRUPT  [ IE ]:-
                           External interrupt edge flag is  set / clear by hardware  when interrupt is processed.

  • TIMER INTERRUPT [ IT ]:-
                            These are timer interrupt flags. These bare  SET for negative  edge trigger/  CLEAR  for level trigger


DELAY GENERATION:

  • Delay can  generate i  two ways
  1. Software delay
  2. Hardware delay

software delay:

The delay can generate by using software.  The following program is example for software delay.


     void delay()

                       {

                    

                           int x,y;   

                           for(x=0;x<200;x++) 

                            for(y=0;y<600;y++);

                  }


hardware delay:

steps for hardware delay:


  • Select TIMER 0 or  TIMER 1 In Any one of Timer Mode  i.e user choice { timer mode 0, timer mode 1 ,  timer mode 2, timer mode 3}  
  • SET TMOD Register
  • Load Timers  { TH0 and TLO or  TH1 and TL1 }
  • Start Timer i.e   TR0 OR TR1 is SET
  • Wait for timer flag over flow i.e     while(TF0 or TF1==0);
  • Clear TF and TR BITS
  • Delay completed.

program for hardware delay:-

void delay() 

{

 TMOD=0X01;

TH0=0X4B; 

TL0=0XFD; 

TR0=1;

 while(TF0==0); 

TR0=0;

 TF0=0; 

}


LED'S  ARE  ON AND OFF WITH 1 SECOND DELAY.



#include<at89x51.h>  //  It is header file for 8051

void delay()     // delay function called by main

{

 TMOD=0X01;

TH0=0X4B; 

TL0=0XFD; 

TR0=1;

 while(TF0==0); 

TR0=0;

 TF0=0; 

}


}

void main()

{

while(1)

{

P0=0XFF;   // led's are connected to P0 so LED'S  ON

 delay();  // delay for 1 sec

 P0=0X00;   // LED'S  are OFF

delay();     // Delay for 1 sec

}





         LCD (LIQUID CRYSTAL DISPLAY)


  • This LCD Display the characters so we called as also CHARACTER LCD
  • If we give liquid. It is "1" for  BLACKNESS, "0" for WHITENESS   
                                              BLACK=1
                                              WHITE=0
  • We are using 16*2 LCD
  • By using this 16*2 LCD,  we can display 16 characters in 2 lines
  • For a single character we have to use  5*7 pixels

LCD  pins:


  • LCD having 16 PINS, Each having specific function.
  1.   Vss  --  GROUND
  2.   Vcc  --   POWER SUPPLY
  3.   Vee  --  CONTRAST (Intensity of blackness of pixel)
  4.   RS  --   Register Select
  5.  R/W -  Read or write
  6.  E   --   Enable
     7-14  D0-D7  --   Data bus
     15  +Vref   --   black light  +ve
     16   -Vref   --    black light -ve


D7 Bit  we call as BUSY FLAG


* lcd having  2 memory's

      1. Data memory (Display data RAM)

      2. Command memory ( Character Generator  RAM )
       
*  If   RS=0 , we selected as a  command memory

* If  RS=1, We  selected as a data memory.

* E = 1, Then  the character will fetch from  lcd memory to 8051 port.

* E =0, Then the fetching will stop.

* Internally  LCD having  30 positions  for each line  but it display only 16 positions.

* When  the     1st line of  30 position is completed  then  the next character display at 2nd line of 1st
 position.

* When  2nd line of 30 position  completed , Then the next character can display at  1st line of 1st  position

* Internally  in LCD  lines are circular.




LCD COMMANDS:


0X01       :      CLEAR DISPLAY

0X02       :       RETURN HOME

0X04       :       DECREMENTED  CURSOR (  SHIFT CURSOR TO LEFT) 

0X06       :       INCREMENTED CURSOR   (  SHIFT CURSOR TO RIGHT )

0X05       :        SHIFT DISPLAY RIGHT

0X07       :        SHIFT DISPLAY TO LEFT

0X08       :        DISPLAY OFF CURSOR OFF
0X0A      :        DISPLAY OFF CURSOR ON

0X0E       :        DISPLAY ON  CURSOR OFF

0X0F        :       DISPLAY   ON  CURSOR ON

0X28        :        4 BIT LCD

0X38        :         8 BIT LCD



ANALOG TO DIGITAL CONVERTER:

  • Transducer:-
                              Which converts one form of energy to  another form of energy. i.e  
 A physical quantity is converted into  electrical  signal is called " Transducer "
  • Sensor:-
                         Which converts any form of energy  to voltage level.

  • Resolution:-   
                         A smallest change that can be detected  by   "ADC".    When  resolution is more  then  accuracy  may be in minutes.

  • In 8051, we don't have ADC internally  so   we are connecting the   0804 ADC  externally.

  • Converts time:-
                                 The time taken by to change  ( or )  converts  analog signal to digital signal.  It may varies depending on clk signal applied to the   clkR and clkI pins.
           

FEATURES OF ADC 0804:-



  •  Manufactured by NATIONAL   SEMICONDUCTORS
  • It belongs to 800 series
  • Working on  +5V
  • 8 bit resoltution.


1 comment: