7-segment Display & ADC Controls with 8051

Similar documents
Conversion Between Analog and Digital Signals

Interfacing Analog to Digital Data Converters

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

4 Character 5x7 LED Matrix Display

24-Bit Analog-to-Digital Converter (ADC) for Weigh Scales FEATURES S8550 VFB. Analog Supply Regulator. Input MUX. 24-bit Σ ADC. PGA Gain = 32, 64, 128

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

Monitoring of Intravenous Drip Rate

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Decimal Number (base 10) Binary Number (base 2)

CHAPTER 11: Flip Flops

PART B QUESTIONS AND ANSWERS UNIT I

Digital to Analog and Analog to Digital Conversion

Interfacing To Alphanumeric Displays

Analog-to-Digital Converters

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

Microcontroller to Sensor Interfacing Techniques

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

Lab 17: Building a 4-Digit 7-Segment LED Decoder

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

8051 Serial Port. Crystal TXD. I/O Device RXD. Embedded Systems Peripherals

A Digital Timer Implementation using 7 Segment Displays

PACKAGE OUTLINE DALLAS DS2434 DS2434 GND. PR 35 PACKAGE See Mech. Drawings Section

Digital To Analog Converter with Sine Wave Output

ADC0808/ADC Bit µp Compatible A/D Converters with 8-Channel Multiplexer

8051 hardware summary

PIC Application Notes

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

PCAN-MicroMod Universal I/O Module with CAN Interface. User Manual. Document version ( )

Hexadecimal and Numeric Indicators. Technical Data

EVAL-UFDC-1/UFDC-1M-16

Measuring Resistance Using Digital I/O

Controlling a Dot Matrix LED Display with a Microcontroller

MACHINE ARCHITECTURE & LANGUAGE

The components. E3: Digital electronics. Goals:

AN108 IMPLEMENTING A REALTIME CLOCK. Relevant Devices. Introduction. Key Points. Overview

Lab Experiment 1: The LPC 2148 Education Board

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Microcontroller Based Infrared Tracking Device In 2D Motion

NETWORK ENABLED EQUIPMENT MONITOR

Flash Microcontroller. Architectural Overview. Features. Block Diagram. Figure 1. Block Diagram of the AT89C core

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

Ultrasound Distance Measurement

8254 PROGRAMMABLE INTERVAL TIMER

3-Digit Counter and Display

Microcontroller Code Example Explanation and Words of Wisdom For Senior Design

STEPPER MOTOR SPEED AND POSITION CONTROL

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

CoE3DJ4 Digital Systems Design. Chapter 4: Timer operation

Touch Screen for Pictiva OLED display. Application Note. Introduction

Measuring Temperature withthermistors a Tutorial David Potter

Counters and Decoders

LADDER LOGIC/ FLOWCHART PROGRAMMING DIFFERENCES AND EXAMPLES

8085 MICROPROCESSOR PROGRAMS

Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

2011, The McGraw-Hill Companies, Inc. Chapter 3

How To Use An Ams 5812 Pressure Sensor With A Usb Starter Kit

8-Bit Microcontroller with Flash. Application Note. Using a Personal Computer to Program the AT89C51/C52/LV51/LV52/C1051/C2051

Asynchronous counters, except for the first block, work independently from a system clock.

ETEC 2301 Programmable Logic Devices. Chapter 10 Counters. Shawnee State University Department of Industrial and Engineering Technologies

Copyright Peter R. Rony All rights reserved.

LABORATORY MANUAL EE0310 MICROPROCESSOR & MICROCONTROLLER LAB

1 Coffee cooling : Part B : automated data acquisition

DS1821 Programmable Digital Thermostat and Thermometer

Features DISPLAY DECODING INPUT INTERFACING

ezsystem elab16m Project 1F: Alarm System (Full Project description)

FR FAMILY MB91460 SPI - DAISY CHAIN COMMUNICATION 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

Experiment # 9. Clock generator circuits & Counters. Eng. Waleed Y. Mousa

12-Bit, 4-Channel Parallel Output Sampling ANALOG-TO-DIGITAL CONVERTER

DS1621 Digital Thermometer and Thermostat

Advanced LED Controller (LED Chaser)

Loop Calibration and Maintenance

Digital Sampling Oscilloscope

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

SHENZHEN JINGHUA DISPLAYS CO.,LTD.

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

Accurate Measurement of the Mains Electricity Frequency

1.1 The 7493 consists of 4 flip-flops with J-K inputs unconnected. In a TTL chip, unconnected inputs

Section 3. Sensor to ADC Design Example

PLL frequency synthesizer

INSTRUMENTATION AND CONTROL TUTORIAL 3 SIGNAL PROCESSORS AND RECEIVERS

TDA CHANNEL VOLUME CONTROLLER 1 FEATURES 2 DESCRIPTION. Figure 1. Package

Application Report. 1 Introduction. 2 Resolution of an A-D Converter. 2.1 Signal-to-Noise Ratio (SNR) Harman Grewal... ABSTRACT

Trigno/Vicon System Integration

M25P05-A. 512-Kbit, serial flash memory, 50 MHz SPI bus interface. Features

(Refer Slide Time: 00:01:16 min)

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

DS1621 Digital Thermometer and Thermostat

Introduction to Microcontrollers

SAMPLE CHAPTERS UNESCO EOLSS DIGITAL INSTRUMENTS. García J. and García D.F. University of Oviedo, Spain

A Practical Approach to Education of Embedded Systems Engineering

Android based Alcohol detection system using Bluetooth technology

USB-AD14f Data Acquisition System (USB)

Chapter 6: From Digital-to-Analog and Back Again

TIL311 HEXADECIMAL DISPLAY WITH LOGIC

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Antenna Rotator System

Digital Fundamentals. Lab 8 Asynchronous Counter Applications

FEATURES DESCRIPTION. PT6321 Fluorescent Display Tube Controller Driver

Transcription:

EEE3410 Microcontroller Applications LABORATORY Experiment 5 7-segment Display & ADC Controls with 8051 Name Class Date Class No. Marks 7-segment Display & ADC Controls Objectives To understand the connection of 7-segment display to 8051 To know how to write 8051 assembly program to control 7-segment display To understand the connection of an ADC to 8051 To know how to write 8051 assembly program to control an ADC to acquire data Equipment/Components Required PC compatible computer with Windows XP MedWin 8051 simulation software. ADC & 7-segment Display training board with power supply and connection cable HT1000 89C51 Writer floppy disk/usb flash disk Ver Author(s) Date Remark 1.0 KK SIN 9/2006 Laboratory Experiment 5 1

Part A: Background Information A1. The 7-segment LED numeric display A 7-segment LED numeric display contains 8 LEDs, of which 7 segments are arranged in the shape of the number 8 to display the digits 0-9, and the eighth one is the decimal point (DP). (Ignore the decimal point in this Laboratory.) Basically, it has one common lead (either anode or cathode) which is connected to the power supply, and the remaining 7 individual leads are for each segment. f e a g d b c Dp Segment Pattern Segment displays are driven by connecting each segment to a port bit, or they can be driven by decoder/driver IC designed for the purpose. A decoder/driver chip will accept a parallel input from a 8051 port (binary or ASCII) and drive the display to show the corresponding character. The table shows the corresponding connection of the 8 output port bits to the 8 input terminals of display segments. Output Port bit 7 6 5 4 3 2 1 0 Display segment Dp g f e d c b a There are two common types of configurations; namely, the common-anode configuration and the common-cathode configuration. Common a b c d e f g Dp Common a b c d e f g Dp Common-anode configuration Common-cathode configuration Common-anode configuration Segment will light up if the output port bit is set LOW. Common-cathode configuration - Segment will light up if the output port bit is set HIGH. Normally a resistor of 330Ω is connected between each segment terminal and output port bit in order to protect the LED segment. In this laboratory, you will appreciate how to program the 8051 to control 7-segment LED numeric displays. 2 Experiment 5 Laboratory

EEE3410 Microcontroller Applications A2. Analog-to-digital conversion (A/D) Most real time data (e.g. temperature, voltage, velocity) are analog signal, i.e. the signal is continuous varying with time. Microcontroller is a digital device. It can only read and manipulate data in digital form. If this kind of real time analog data is being controlled by microcontroller, some means must be used first to convert the analog data to digital data before manipulating by microcontroller. The common process to get these analog data is to use a device called a transducer (also called sensor) to measure their values. The transducer normally converts measured value into electrical signal (which is either voltage or current) for further conversion to digital form. An example of transducer is a thermistor. Since its resistance varies with the ambient temperature, so the current passing through it will also vary. As a result, current value depends on the temperature being measured. Measure the current will then be the same as to measure the temperature. Yet, the output from a transducer (voltage/current) is still analog; a device is needed to convert them in digital signals ( digitization ). Such a device is called an analog-to-digital converter (ADC), and this process is called analog-to-digital (A/D) conversion. Once the signal is digitized, it can be sent to the microcontroller for further processing. A2.1 The ADC0804 IC The ADC0804 IC is one of the most popular analog-to-digital converters. It is in the family of the ADC0800 series. It works with a power supply of +5V, and has a resolution (i.e. output) of 8 bits. Pin description of the ADC0804: Chip select ( CS ) Pin CS is used to activate the ADC0804 IC. The IC is activated and ready to use if a LOW signal is set to this pin. Read ( RD ) (Data output enable) Pin RD is also called output enable. It is an active-low output signal. It is used to get the converted data out of the ADC0804 IC. With CS =0, if a high-to-low pulse is applied to RD, the 8-bit digital is then output to the data pins D0-D7 for pick-up. CS RD WR CLK INTR V I + V I - AGND V REF /2 DGND 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 V CC CLKR D0 D1 D2 D3 D4 D5 D6 D7 Pin diagram ADC0804 Laboratory Experiment 5 3

Write ( WR ) (Start conversion) WR is also called start conversion. It is an active-low input signal. It is used to start the ADC0804 IC for data conversion. With CS =0, if a low-to-high pulse is applied to pin WR, the ADC0804 IC will start converting the analog input value at pin V I + to an 8-bit digital number. Once data conversion is complete, pin INTR will be set to LOW. Interrupt ( INTR ) (End of conversion) INTR is also called end of conversion. It is an active-low output signal. It is usually high but once data conversion is complete, it set to LOW to indicate that the converted data is ready for pick-up. V CC V CC is the +5V power supply to the ADC0804 IC. It can be also used as a reference voltage (V REF ) if the pin V REF /2 is open. V REF /2 V REF /2 is an input used for reference voltage other than 0-5V range. But if V REF /2 is left open, the analog input voltage will be in the range of 0-5V. Data pins D0-D7 DB0-DB7 are the digital data output pins, with D7 as the most significant bit (MSB) and D0 as the least significant bit (LSB). They can only be accessed when both CS =0 and RD is LOW. A2.2 Digital output of the ADC804 IC In this Laboratory, the V REF /2 pin is left open, i.e. the analog input voltage (V IN ) is in the range 0-5V. Because the ADC0804 IC has a resolution of 8 bits, the range is divided into 2 8 =256 steps. Or, we can say that there are 255 quantization levels (0V inclusive). The step size, or the resolution of the ADC804 IC, is: step size V 2 = 2 8 2 1 REF VREF = 255 The digital data value (D OUT ) of the ADC804 IC is: V D = IN OUT step size 4 Experiment 5 Laboratory

EEE3410 Microcontroller Applications e.g. : A 5V is set to the V REF pin of a ADC0804, find the digital value output from the ADC if it converts an analog input voltage of 3.5V. Solution: 5 step size = V = 0.0196V ; 255 3.5 D OUT = = 178 or 179 (depends on the accuracy of the ADC) 0.0196 A2.3. Control of ADC0804 IC to carry out analog-to-digital conversion Normally ADC0804 IC is interfaced with microcontroller to form a data acquisition system, circuit shown in fig. A2.1. The microcontroller will send out a fixed sequence of control signals to direct the ADC to complete the A/D conversion process and output the converted value. Fig. A2.2 shows a flowchart gives the steps for signal time issued by a 8051 to control the ADC0804IC Start Set CS to LOW V CC Input analog voltage V I+ V I- CLKR CLK V REF AGND DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 INTR ADC0804 CS RD WR Input bits 8051 Microcontroller Output Control bits Set WR to LOW Next return WR to HIGH Then return CS to HIGH Does INTR change to LOW? Y Set CS to LOW Set RD to LOW N Fig. A2.1 Interface of ADC0804 to 8051 microcontroller Read the ready ADC Data by a 8051 input port Next return RD to HIGH Then return CS to HIGH Repea Fig. A2.2 Flowchart of timing control of ADC0804 Laboratory Experiment 5 5

CS WR D0 D7 Data out INTR Start conversion End conversion Read it Note: CS is set to low for both RD and WR pulses (Fig. A2.3 The read and write signal timing diagram for ADC804) Sequence of signal to control the ADC0804 1. Set CS to LOW. (Select the ADC IC) 2. Send a low-to-high pulse to WR, so as to start data conversion. Return CS to High again to de-select the ADC 3. Keep monitoring INTR. If INTR is LOW, that means the conversion is finished. If INTR is still HIGH, keep polling until it becomes LOW. 4. Set CS to LOW to select the ADC 5. Send a high-to-low pulse to RD so that data read by 8051 input port can be done 6. Return RD to High again to indicate port reading completed 7. Return CS to High again to de-select the ADC 8. Repeat steps for another conversion 6 Experiment 5 Laboratory

EEE3410 Microcontroller Applications A3. ADC & 7-segment Display training board Figure A3.1 shows the circuit diagram of the ADC & 7-segment Display training board. Port 2, Port bit 3.6 and Port bit 3.2 are connected to the 8-bit output, pin WR and pin INTR of ADC0804 respectively. Port 0 is connected to a common-anode 7-segment display. 2-digit 7-segment numeric display is connected to the upper & lower nibbles of Port 1 via a two BCD to 7-segment decoders. Port bits 3.0, 3.1, 3.3 & 3.4 0 are connected to 4 push buttons (S1 to S4) respectively. Laboratory Experiment 5 7

Part B: Procedures B1. Controlling a 7-segment numeric display A source program shown in table B1.1 controls the 7-segment display at Port 0 to show the digits 0-F in counting up manner. B1.1 Complete the lines 29 31 in table B1.1. B2.2 Use the 8051 simulation software to check the correct execution of the program. B2.3 Use the HT1000 89C51 writer to write the HEX file of the program into a blank 89C51 chip. B2.4 Insert the 89C51 chip to the ADC & 7-segment Display training board and observe the result of execution. Table B1.1 Line Label Mnemonics Operands Remarks 1 ORG 00h 2 MOV R3, #0 ;reset the counter 3 MOV DPTR, #TABLE 4 MOV P0, #01000000b ;display 0 5 ;subroutine to count from 0-9 6 COUNT_UP: INC R3 ;increment the counter 7 CJNE R3, #16, CONT ;if R3 10, continue counting 8 MOV R3, #0 ;otherwise count again from 0 9 CONT: MOV A, R3 10 MOVC A, @A+DPTR ;display the value of R3 in 11 MOV P0, A ;7-segment format 12 ACALL DELAY 13 AJMP COUNT_UP 14 15 DELAY: MOV R5, #5 ;sets the delay time 16 LOOP1: MOV R6, #250 17 LOOP2: MOV R7, #200 18 LOOP3: DJNZ R7, LOOP3 ;inner loop 19 DJNZ R6, LOOP2 ;middle loop 20 DJNZ R5, LOOP1 ;outer loop 21 RET ;return to main program 22 23 ;lookup table to convert from hex to a corresponding digit 24 TABLE: DB 01000000b, 01111001b ;0, 1 25 DB 00100100b, 00110000b ;2,3 26 DB 00011001b, 00010010b ;4, 5 27 DB 00000010b, 01111000b ;6, 7 28 DB 00000000b, 00010000b ;8, 9 29 DB b, b ;A, b 30 DB b, b ;C, d 31 DB b, b ;E, F 32 END 8 Experiment 5 Laboratory

B2. Controlling 7-segment numeric displays through BCD decoder/driver EEE3410 Microcontroller Applications A source program shown in table B2.1 is expected to control the 2-digit 7-segment display at Port 1 to show the values from 00 to 99 in counting up manner. But it cannot correctly display the values ONE after ONE in sequence. You are required to correct the program in table B2.1 to give the right result. B2.1 By using the 8051 simulation software, correct the program as required. B2.2 Write the HEX file of the program into a blank 89C51 chip. B2.3 Check the program by the ADC & 7-segment Display training board. Table B2.1 Line Label Mnemonics Operands Remarks 1 ORG 00h 2 MOV A, #0 ;reset the counter 3 4 COUNT_UP: MOV P1, A ;display the value of A 5 ACALL DELAY 6 INC A ; A = A + 1 7 CJNE A, #100, CONT ;if A 100, continue counting 8 MOV A, #0 ;otherwise count again from 0 9 CONT: AJMP COUNT_UP 10 ; 11 DELAY: MOV R5, #5 ;sets the delay time 12 LOOP1: MOV R6, #250 13 LOOP2: MOV R7, #200 14 LOOP3: DJNZ R7, LOOP3 ;inner loop 15 DJNZ R6, LOOP2 ;middle loop 16 DJNZ R5, LOOP1 ;outer loop 17 RET ;return to main program 18 END 19 20 21 B3. Controlling ADC A source program is given in table B3.1 which controls an 8-bit ADC0804 IC repetitively to acquire analog voltage signals from a potentiometer, and convert the signals to 8-bit digital values and finally to output the values to the Port 2 of 8051. After the 8-bit digital value is inputted, the 8051 has to convert the 8-bit value to an equivalent decimal value and display it by the 2-digital 7-segment display. When you turn the potentiometer, the analog voltage input to the ADC will change and similarly, the digital values displayed will also change. Problem: it is found that the analog voltage input, measure by a DMM, to the ADC cannot be correctly displayed by the 2-digital 7-segment display. Laboratory Experiment 5 9

B2.1 By using the 8051 simulation software, correct the program as required. B2.2 Write the HEX file of the program into a blank 89C51 chip. B2.3 Check the program by the ADC & 7-segment Display training board. Table B3.1 Line Label Mnemonics Operands Remarks 1 ORG 00h 2 MOV P1, #0 ;Display 00 3 MOV P2, #0FFh ;set port 2 as input port 4 MOV P3, #0FFh ;set port 3 output to High 5 ; 6 STARTCON : CLR P3.6 ;Set port bit 3.6 to Low, 7 NOP ;start ADC conversion 8 SETB P3.6 ;reset port bit 3.6 to High 9 NOP 10 CHK_END: JB P3.2, CHK_END ;check for end of conversion 11 NOP 12 READ: MOV A, P2 ;input from ADC 13 ; 14 MOV P1, A ;output to port 1 15 ACALL DELAY 16 AJMP STARTCON 17 18 19 20 21 22 ; 23 DELAY: MOV R5, #5 ;sets the delay time 24 LOOP1: MOV R6, #250 25 LOOP2: MOV R7, #200 26 LOOP3: DJNZ R7, LOOP3 ;inner loop 27 DJNZ R6, LOOP2 ;middle loop 28 DJNZ R5, LOOP1 ;outer loop 29 RET ;return to main program 30 END Note: As the pins of CS and RD are directly connected to the ground in the training board, they are always at LOW input. That means the ADC is always selected and ready for output. So the source program in the above table has not necessary to include any instructions for chip selection and read action of the ADC. 10 Experiment 5 Laboratory

EEE3410 Microcontroller Applications B2.4 After the program is corrected and executed by a 89C51 chip, complete the table below by first turning the potentiometer knob at the end of counter clockwise direction, record the voltage input to the ADC by a DMM and the value displayed by the 2-digit 7-segment display. Then slowly turn the knob in clockwise direction until at the end position. Record down the values displayed at any four intermediate positions. Compare with the voltage values measured by DMM. Position of knob Value indicated by the 2-digital 7-segment display Analog voltage inputted to the ADC (Volts) At Full counter clockwise 0 0 0 V At Intermediate position 1 At Intermediate position 2 At Intermediate position 3 At Intermediate position 4 At Full clockwise Laboratory Experiment 5 11

Part C: Exercise C1. Assume that pin V ref /2 is connected to a reference voltage of 2V. Determine the following. (a) Step Size: (b) Maximum range for V in (c) D7 D0 value if V in = 1.2 V (d) V in if D7 D0 = 1111 1111 (e) V in if D7 D0 = 1101 1011 C2. What is the value for V ref /2 to set the ADC0804 has a step size of 8 mv. - End - 12 Experiment 5 Laboratory