354 39 Solutions Instructor Manual 12 Interface Examples Chapter 12

December 12, 2017 | Author: Saravanan Jayabalan | Category: Microcontroller, Input/Output, Electronic Engineering, Areas Of Computer Science, Technology
Share Embed Donate


Short Description

microcontroller ppt...

Description

Microprocessors and Microcontrollers

Kumar, Saravanan & Jeevananthan

Chapter 12  Interface examples  Solutions to THINK AND ANSWER Exercises 1. Explain the interfacing of four seven-segment LED displays with the 8051, using the multiplexed display concept.

IC  8279  is  a  programmable  keyboard  and  display  interface  controller,  that  can  be  used  for  interfacing multiplexed display with the 8051  microcontroller.  Figure shows the interfacing of  seven‐segment LEDs with the 8051 using the 8279. The lines A0 – A3 and B0 – B3 of 8279 are  used  to  give  the  display  data  to  the  devices.  The  scan  lines,  SL0  and  SL1  are  used  to  select  a  display device among the four. The  seven‐segment displays  are  all common  anode type  and  a  transistor driver is used with each display device. A logic low is required to turn on the transistor  driver; it is generated using the decoder IC. Common decoder ICs such as IC 74138 can be used  as these ICs can give an active low signal on any of their outputs. The segments of the display  devices are all connected together on a common bus and connected to the A0 – A3 and B0 – B3  outputs  of  the  8279.  As  the  displays  are  all  of  common  anode  type,  the  data  output  for 

 

© Oxford University Press 2011

9‐1

Microprocessors and Microcontrollers

Kumar, Saravanan & Jeevananthan

illuminating the LEDs must be logic low. This means that a logic 1 in the data lines A0 – A3 and  B0  –  B3  blanks  the  display  and  a  logic  0  displays  all  the  segments.    8279  uses  two  addresses  selected by A0 address input to 8279.  The program for displaying the data to the seven segment display through 8279 is given below.  Label   

Mnemonics  MOV DPTR,  #COMMAND_PORT  START:  MOV A, #00H     

MOVX @DPTR,A   MOV A, #0C0H 

   

MOVX @DPTR,A   MOV A,#90H 

                       

MOVX @DPTR,A   MOV DPTR, #DATA_PORT  MOV A,# DATA1  MOVX @DPTR,A   MOV A, #DATA2  MOVX @DPTR,A   MOV A,#DATA3  MOVX @DPTR,A   MOV A, #DATA4  MOVX @DPTR,A    

 

Comments  ;Load the command port address of 8279 to data  pointer  ; Load the mode set command word in the  accumulator.  ; Output it to the command port.  ; Load the clear display command word in the  accumulator.  ; Output it to the command port.  ; Load the write display RAM command word in the  accumulator.   ; Output it to the command port.  ;Load the data port address of 8279 to data pointer  ; Load the first data in the accumulator.   ; Output it to the seven‐segment display.  ; Load the second data in the accumulator.  ; Output it to the seven‐segment display.  ; Load the third data in the accumulator.  ; Output it to the seven‐segment display.  ; Load the fourth data in the accumulator.  ; Output it to the seven‐segment display.  ; end of display interface program. 

© Oxford University Press 2011

9‐2

Microprocessors and Microcontrollers

Kumar, Saravanan & Jeevananthan

2. Interface an ADC chip and an intelligent LCD with the 8051. Explain the algorithm needed to read data from the ADC and display it in the LCD.

START: MOV A,#01H CALL COMMAND MOV A, #0EH

CALL COMMAND MOV DPTR, #9000H MOV R0, #0FH NEXT: MOVX A, @DPTR CALL DISP INC DPTR DJNZ R0, NEXT

COMMAND: MOV P1,A CLR P2.2 CLR P2.1 SETB P2.0 CLR P2.0 CALL DELAY

 

; Load the control word to clear the display in the LCD. ; Call the subroutine to issue this command to the LCD. ; Load the control word to initialize the cursor to home position, and switch on the display and the cursor. ; Call the subroutine to issue this command to the LCD. ; Initialize the memory pointer. ; Initialize the counter for the number of characters to display. ; Load the display data in the accumulator. ; Call the subroutine to issue this data to the LCD. ; Point to the next data for display. ; Decrement the count for the number of data to be displayed. If it is not zero, loop again.

; Give the control word to the data lines of the LCD ; RS = 0 (command) ; R/W = 0 (write) ; E = 1 (apply a high pulse) ; E = 0 (apply a low to E, so that there will be a H-to-L pulse) ; Wait for a predefined time delay

© Oxford University Press 2011

9‐3

Microprocessors and Microcontrollers

Kumar, Saravanan & Jeevananthan

RET

; Return from subroutine

DISP: MOV P1,A SETB P2.2 CLR P2.1 SETB P2.0 CLR P2.0

; Give the data to the data lines of the LCD. ; RS = 1 (data) ; R/W = 0 (write) ; E = 1 (apply a high pulse) ; E = 0 (apply a low to E, so that there will be a H-to-L pulse) ; Wait for predefined time delay ; Return from subroutine.

CALL DELAY RET

DELAY: MOV R1, #COUNT1 LOOP1: MOV R2, #COUNT2 LOOP2: DJNZ R2, LOOP2 DJNZ R3, LOOP1 RET

; Load a register with a count value, COUNT1. ; Load another register with a count value, COUNT2, for more delay. ; Decrement it. ; Decrement until the required time delay is obtained. ; When the required time delay has been produced, return from subroutine.

3. Interface a DC motor and two switches with the 8051 and explain the software needed for controlling the direction of the DC motor using the switches.

 

© Oxford University Press 2011

9‐4

Microprocessors and Microcontrollers

Kumar, Saravanan & Jeevananthan

Mode Pin A/ P1.1 /P2.0 Pin B/ P1.0 / P2.1 Motor 0

0

0

Off

1

0

1 (5 V)

Reverse

2

1 (5 V)

0

Forward

3

1 (5 V)

1 (5 V)

Off

START: MOV C,P2.0 MOV P1.0,C MOV C, P2.1 MOV P1.1,C

;Load the P2.0 contents to carry flag ;Give the data in carry flag to P1.0 for motor ;Load the P2.1 contents to carry flag ;Give the data in carry flag to P1.1 for motor

The interfacing of the DC motor that can be driven bidirectional is given above. The port pins P1.0 and P1.1 will control the direction of the motor as given in the table. The switches are interfaced in the port pins P2.0 and P2.1. The program for driving the motor is given which just reads the data on the Port 2 pins and outputs it on port 1 pins. Remember that if both the input pins are at logic 0, the motor will not rotate. Similarly, if both the input pins are at logic 1, then also the motor will not rotate. If P2.0 is 1 and P2.1 is 0, then the motor will rotate in a particular direction. The motor direction is reversed if P2.0 is 0 and P2.1 is 1.

Solutions to NUMERICAL/DESIGN-BASED EXERCISES 1. Design a microcontroller-based system for a weighing machine. [Hint: Use a load cell or any other suitable transducer, instead of a thermistor, in the example discussed in section 12.12.] 2. Design a microcontroller-based controller for turning on and off the lights in a building, based on the movement of people in the building. [Hint: Use an IR sensor to detect persons in the building and accordingly either turn on or turn off the light, as done in the traffic light control example.]  

 

© Oxford University Press 2011

9‐5

Microprocessors and Microcontrollers

Kumar, Saravanan & Jeevananthan

   

 

© Oxford University Press 2011

9‐6

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF