EEE3410 Microcontroller Applications Department of Electrical Engineering. Lecture 10. Analogue Interfacing. Vocational Training Council, Hong Kong.

Similar documents
EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 11 Motor Control

Module 13: Interfacing ADC. Introduction ADC Programming DAC Programming Sensor Interfacing

The University of Texas at Arlington Lecture 10 ADC and DAC

Dedan Kimathi University of technology. Department of Electrical and Electronic Engineering. EEE2406: Instrumentation. Lab 2

PART 1: DESCRIPTION OF THE DIGITAL CONTROL SYSTEM

Embedded Control. Week 3 (7/13/11)

Lecture 6: Digital/Analog Techniques

BASIC Stamp I Application Notes

CHAPTER ELEVEN - Interfacing With the Analog World

ANGULAR POSITION CONTROL OF DC MOTOR USING SHORTEST PATH ALGORITHM

Analog to Digital Conversion

ELG3336: Converters Analog to Digital Converters (ADCs) Digital to Analog Converters (DACs)

6-Bit A/D converter (parallel outputs)

Real Time Embedded Systems. Lecture 1 January 17, 2012

AppKit: Using the LTC bit Analog-to-Digital Converter

MARMARA UNIVERSITY CSE315 DIGITAL DESIGN LABORATORY MANUAL. EXPERIMENT 7: Analog-to-Digital Conversion. Research Assistant Müzeyyen KARAMANOĞLU

ADC Resolution: Myth and Reality

EEE312: Electrical measurement & instrumentation

Analog I/O. ECE 153B Sensor & Peripheral Interface Design Winter 2016

Data Conversion and Lab Lab 3 Spring Analog to Digital Converter

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

Software Programmable Gain Amplifier AD526

Analytical Chemistry II

Linear Integrated Circuits

L9: Analog Building Blocks (OpAmps,, A/D, D/A)

In this lecture, we will look at how different electronic modules communicate with each other. We will consider the following topics:

P a g e 1. Introduction

ADC Bit µp Compatible A/D Converter

LM12L Bit + Sign Data Acquisition System with Self-Calibration

UNIT III Data Acquisition & Microcontroller System. Mr. Manoj Rajale

ANALOG TO DIGITAL (ADC) and DIGITAL TO ANALOG CONVERTERS (DAC)

Outline. Analog/Digital Conversion

Sampling and Quantization

Analogue to Digital Conversion

TS100. RTD - PT100 - Temperature Sensor. March, 2017

Ch 5 Hardware Components for Automation

Chapter 5: Signal conversion

Quad 12-Bit Digital-to-Analog Converter (Serial Interface)

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

ADC0844/ADC Bit µp Compatible A/D Converters with Multiplexer Options

Lecture 7: Analog Signals and Conversion

Data Converters. Lecture Fall2013 Page 1

DSP Project. Reminder: Project proposal is due Friday, October 19, 2012 by 5pm in my office (Small 239).

Automatic Railway Gate Control & Track Switching

L10: Analog Building Blocks (OpAmps,, A/D, D/A)

BINARY AMPLITUDE SHIFT KEYING

arxiv:physics/ v1 [physics.ed-ph] 19 Oct 2004

University of Pittsburgh

Data Converters. Dr.Trushit Upadhyaya EC Department, CSPIT, CHARUSAT

L10: Analog Building Blocks (OpAmps,, A/D, D/A)

LM12454,LM12458,LM12H458

Design of Frequency Characteristic Test Instrument Based on USB

NI 6013/6014 Family Specifications

I hope you have completed Part 2 of the Experiment and is ready for Part 3.

VCC. Digital 16 Frequency Divider Digital-to-Analog Converter Butterworth Active Filter Sample-and-Hold Amplifier (part 2) Last Update: 03/19/14

ELG4139: Converters Analog to Digital Converters (ADCs) Digital to Analog Converters (DACs)

ADC0801/ADC0802/ADC0803/ADC0804/ADC Bit µp Compatible A/D Converters

ENGN Analogue Electronics Digital PC Oscilloscope

EE283 Electrical Measurement Laboratory Laboratory Exercise #7: Digital Counter

Lab Experiments. Boost converter (Experiment 2) Control circuit (Experiment 1) Power diode. + V g. C Power MOSFET. Load.

CAV444 C/V transmitter IC with adjustable output voltage for capacitive input signals

Laboratory Experiments in Instrumentation and Control

A-D and D-A Converters

2.7 V to 5.5 V, 400 ksps 8-/10-Bit Sampling ADC AD7813

MT1531 Series. CMOS, Programmable Linear Hall Effect Sensor. Features. Applications. 1 / 15

UNIVERSITI MALAYSIA PERLIS

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

Technical Brief FAQ (FREQUENCLY ASKED QUESTIONS) For further information, please contact Crystal Semiconductor at (512) or 1 (800)

Unit-6 PROGRAMMABLE INTERRUPT CONTROLLERS 8259A-PROGRAMMABLE INTERRUPT CONTROLLER (PIC) INTRODUCTION

Module 3. Embedded Systems I/O. Version 2 EE IIT, Kharagpur 1

INTEGRATED CIRCUITS. AN109 Microprocessor-compatible DACs Dec

Hardware Platforms and Sensors

Analogue to Digital Conversion

Lab Exercise 6: Digital/Analog conversion

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

Design and Implementation of Microcontroller Based Programmable Power Changeover

ENGR 210 Lab 12: Analog to Digital Conversion

). The THRESHOLD works in exactly the opposite way; whenever the THRESHOLD input is above 2/3V CC

Tel: Fax:

NI 6023E/6024E/6025E Family Specifications

A 4 GSample/s 8-bit ADC in. Ken Poulton, Robert Neff, Art Muto, Wei Liu, Andrew Burstein*, Mehrdad Heshami* Agilent Laboratories Palo Alto, California

EE 368 Electronics Lab. Experiment 10 Operational Amplifier Applications (2)

8-Bit, high-speed, µp-compatible A/D converter with track/hold function ADC0820

Data acquisition and instrumentation. Data acquisition

Input Drive Circuitry for SAR ADCs. Section 8

L9: Analog Building Blocks (OpAmps, A/D, D/A)

Analog to Digital Conversion

Analog to Digital Conversion

Analog-to-Digital Converter (ADC) And Digital-to-Analog Converter (DAC)

DIGITAL TO ANALOG CONVERTER (DAC)

IL8190 TECHNICAL DATA PRECISION AIR - CORE TACH / SPEEDO DRIVER WITH RETURN TO ZERO DESCRIPTION FEATURES

ADC0844/ADC Bit µp Compatible A/D Converters with Multiplexer Options

FYS3240 PC-based instrumentation and microcontrollers. Signal sampling. Spring 2017 Lecture #5

Transistor Design & Analysis (Inverter)

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

8-Bit A/D Converter AD673 REV. A FUNCTIONAL BLOCK DIAGRAM

Lecture Week 5. Quiz #2 Ohm s Law Homework Power Review Shorthand Notation Active Components Ideal Op-amps

MICROCONTROLLER PRODUCTS. AN428 Using the ADC and PWM of the 83C752/87C752. Author: Greg Goodhue December Philips Semiconductors

Multiplexer Options, Voltage Reference, and Track/Hold Function

10-Bit µp-compatible D/A converter

Transcription:

Department of Electrical Engineering Lecture 10 Analogue Interfacing 1

In this Lecture. Interface 8051 with the following Input/Output Devices Transducer/Sensors Analogue-to-Digital Conversion (ADC) Digital-to-Analogue Conversion (DAC) 2

Transducer/sensors Digital computer/microcontrollers use binary values, but in the physical world most things is in analog nature (continuous). Data (such as temperature, pressure, humidity, velocity, voltage) are analog data. A device called transducer is used to convert the physical quantity to electrical signals (i.e. voltage, current). Transducer are also referred to as sensors. Sensors for temperature, velocity, pressure, light, and many other natural quantities can produce an output voltage (or current) which the value is proportional to the quantity being measured. Then an analog-to-digital converter is used to translate the analog voltage to digital numbers so that microcontroller can read and process them. 3

Temperature sensors (Thermistor( Thermistor) Temperature can be converted to electrical signals by thermistor. Thermistor is a kind of resistor responds to temperature change by changing its resistance. But its response is not linear, as seen in the Table 10.1 below. Table 10.1 Temperature ( C) 0 25 50 75 100 Thermistor Resistance (kω) 29.490 10.000 3.893 1.700 0.817 4

Temperature sensors (LM34 and LM35) EEE3410 Microcontroller Applications LM34 series are precision integrated-circuit temperature sensors whose output voltage is linearly proportional to Fahrenheit temperature. LM35 series are precision integrated-circuit temperature sensors whose output voltage is linearly proportional to Celsius temperature. They require no external calibration since it is internally calibrated. Their output voltage changes 10mV for each degree of temperature change. Table 10.2 Item LM34 LM34C LM35 LM35C LM35D Temperature Range -50 F to +300 F -40 F to +230 F -55 C to +150 C -40 C to +110 C 0 C to +100 C Accuracy +3.0 F +3.0 F +1.5 C +1.5 C +2.0 C Output 10 mv/f 10 mv/f 10 mv/ C 10 mv/ C 10 mv/ C 5

Analog-to to-digital converter (ADC ) Need to have some means to convert them into digital signal so that computers can handle Analog-to-digital converter (ADC) is a device which can convert analogue voltage to digital numbers so that microcontrollers can handle and process the data. ADC are the most widely used devices for data acquisition ADC has n-bit resolution, where n can be 8, 12, 16 or even 24 bits. The higher-resolution ADC provides a smaller step size. Step size is the smallest change that can be recognized by ADC. 6

Analog-to to-digital converter (ADC ) An ADC has a resolution of 8 bits, the range is divided into 2^8=256 steps (from 0 255). But there are 255 quantization levels. Step Size Vcc = 2 n 1 Vcc is the reference voltage of ADC Table 10.3 : Resolution versus Step Size for ADC (if Vcc = 5V) n-bit 8 10 12 16 Number of steps 2^8 = 256 2^10 = 1024 2^12 = 4096 2^16 = 65536 Step Size (mv) 5/255 = 19.61 5/1023 = 4.89 5/4095 = 1.22 5/65535 = 0.076 7

ADC0804 Chip (Free Running Mode) +5V 20 10k POT 10k 6 7 8 9 19 Vin(+) Vin( ) A GND Vref/2 CLK R CLK in 150 pf ADC 4 1 2 10 Figure 10.1 CS RD D GND 0804 D0 D1 D2 D3 D4 D5 D6 D7 WR INTR 18 17 16 15 14 13 12 11 3 5 To LEDs Normally open START 8

ADC0804 Chip CS Active low input used to activate the ADC0804 chip. RD (data enable) Active low input used to get converted data out of the ADC0804 chip. When CS = 0, if a high-to-low pulse is applied to the RD pin, the 8-bit digital output shows up at the D0-D7 data pins. WR (start conversion) Active low input used to inform the ADC0804 to start the conversion process. If CS = 0 when WR makes a low-to-high transition, the ADC0804 starts converting the analog input value of Vin to an 8-bit digital number. When the data conversion is complete, the INTR pin is forced low by the ADC0804. 9

ADC0804 Chip CLK IN and CLK R Connect to external capacitor and resistor for self-clocking, f = 1/(1.1RC). The clock affect the conversion time and this time cannot be faster than 110µs. INTR (end of conversion) This is an active low output pin. When the conversion is finished, it goes low to signal the CPU that the converted data is ready to be picked up. After INTR goes low, we make CS = 0 and send a high-to-low pulse to the RD pin to get the data out of the ADC0804 chip. Vin (+) and Vin ( ) These are the differential analog inputs where Vin = Vin (+) Vin ( ). Often the Vin ( ) pin is connected to ground and the Vin (+) pin is used as the analog input to be converted to digital. 10

ADC0804 Chip V CC This is the +5V power supply. It is also used as a reference voltage when the Vref/2 (pin 9) input is open. Vref/2 Input voltage pin used for the reference voltage. If this pin is open, the analog input voltage for the the ADC is ranged from 0 to 5 volts. Table 10.4 Vref/2 (V) Vin (V) Step Size (mv) Not connected 0 to 5 5/255 = 19.60 2.0 0 to 4 4/255 = 15.69 1.5 0 to 3 3/255 = 11.76 1.28 0 to 2.56 2.56/255 = 10.04 1.0 0 to 2 2/255 = 7.84 0.5 0 to 1 1/255 = 3.92 11

ADC0804 Chip D0 D7 D0 D7 are the digital data output pins. These are the tri-state buffered and the converted data is accessed only when CS = 0 and RD is forced low. The output voltage: D out = Vin Step size Analog Ground and Digital Ground Analog ground is connected to the ground of the analog signal while digital ground is connected to the ground of the Vcc pin. 12

Signal control on ADC0804 1. Make CS = 0 and send a L-to-H pulse to pin WR to start the conversion. 2. Keep monitoring the INTR pin. If INTR is low, the conversion is finished and we can go to the next step. If INTR is high, keep polling until it goes low. 3. After the INTR has become low, we make CS = 0 and send a H-to-L pulse to the RD pin to get the data out of the ADC0804 IC chip. 13

The timing diagram of ADC0804 CS WR D0 D7 Data out INTR RD Start conversion End conversion Figure 10.2 Read it Note: CS is set to low for both RD and WR pulses 14

Testing the ADC0804 8051 ADC0804 +5V P2.5 P2.6 RD WR V CC CLK R CLK IN P1.0 P1.7 D0 : : : : : D7 V in (+) V in ( ) A GND Vref/2 D GND 10k POT P2.7 INTR CS Figure 10.3 15

Example 10-1 EEE3410 Microcontroller Applications Write a program to monitor the INTR pin and bring the digital input value into register A. Then call a subroutine to display the input value on a 7-segment display. Do this continuously. ; P2.6 = WR (Start conversion needs a L-to-H pulse) ; P2.7 = INTR (When low, end-of-conversion) ; P2.5 = RD (H-to-L will read the data from ADC chip) ; P1.0 P1.7 = D0 D7 of the ADC0804 ; MOV P1, #0FFH ; make P1=input BACK: CLR P2.6 ; WR=0 SETB P2.6 ; WR=1 L-to-H to start conversion HERE: JB P2.7, HERE ; wait for end of conversion CLR P2.5 ; conversion finished, enable RD MOV A, P1 ; read the data ACALL DATA_DISPLAY ; display the data SETB P2.5 ; make RD=1 for next round SJMP BACK 16

Referred to Example 10.1, the digital values output from the ADC0804 correspond to the analogue voltage inputs. It is calculated by: Step Size Vcc = 2 n 1 5 5 Step Size = = = 0. 019608V 8 2 1 255 Analogue input voltage V in (V) 0 0.5 1.0 1.5 2.0 Digital Value Output D out 0/0.019608 = 0 0.5/0.019608 = 26 1.0/0.019608 = 51 1.5/0.019608 = 77 2.0/0.019608 = 102 17

Example of ADC Application Temperature detection A temperature sensor (LM34 or LM35) is interfaced to the 8051 via an ADC (ADC0804) The output voltage from the LM34/LM35 is linearly proportional to the measuring temperature The ADC0804 converts the output voltages from the LM34/LM35 into digital signals, which correspond to the measured temperature. They are then handled by the 8051 18

Interfacing with the LM35 (Temperature Sensor) 8051 ADC0804 +5V XTAL1 XTAL2 P2.5 P2.6 P1.0 RD WR D0 V CC CLK R CLK IN LM35 D Q Q D Q Q P1.7 P2.7 D7 INTR V in (+) V in ( ) A GND Vref/2 D GND CS Set to 1.28V Clock freq 4 Figure 10.4 19

Example 10.2 ADC Application EEE3410 Microcontroller Applications The ADC0804 converts the output voltages from the LM35 into digital signals, which correspond to the measured temperature. Step size of the ADC0804 = (1.28)x(2)/255 = 0.01004V Clock input to the ADC0804 = clock frequency 4 If the following data of LM35 are given the temperature range of the temperature sensor LM35 is -55 C to 150 C and its output scale is 10mV/ C, and the output value of the ADC0804 is 00H when the LM35 senses -55 C then the value output from the ADC0804 for a measuring temperature 100 C is: (100 ( 55)) x.01 D out = = 154.38 = 155 or 9BH 0.01004 20

Digital-to to-analog (DAC) Conversion The digital-to-analog converter (DAC) is a device widely used to convert digital values to analog signals. It does the reverse operation of an ADC The resolution of DAC depends on the no. of binary bits input to it. The common ones are 8, 10 and 12 bits. An 8-input DAC provides 256 discrete voltages (or current) levels of output. (The 12-bit DAC gives 4096 discrete levels). Digital inputs D0 DAC Analog output (Voltage or current) D7 Figure 10.5 21

DAC0808 Chip (MC1408) +5V V ref (e.g +5V) P2.5 P2.6 V CC V in (+) R ref1 I ref = V ref /(R ref1 +R ref2 ) = 2mA (Typical) P1.0 D0 V in ( ) I ref R ref 2 R 0 8051 DAC0808 Comp. I out + To Scope V out = 0 to 10V P1.7 D7 V ee 15V GND Figure 10.6 22

DAC0808 Chip (MC1408) Operating Principle In the DAC0808, the digital inputs are converted to corresponding current (I out ). Then by connecting a resistor to the I ou t pin, the current will further convert to voltage level. The total current provided by the output I out pin is a function of the reference current (I ref ) and is follows: I out = I ref Converting I out to voltage (V out ) 2 D + 4 D + 8 D4 + 16 D3 + 32 D2 + 64 D1 + 128 Connect the output pin I out to a output standard resistor and hence convert this current to a voltage. + D 256 D7 6 5 0 Output voltage, V out = I out x R o 23

Example 10.3 Assume that Ro = 5kΩ,, R ref1 = 1k Ω, R ref2 = 1.5k Ω and using a standard 5V supply connected to V ref(+), calculate V out for the following binary inputs. (a) 1001 1001 (99H) (b) 1100 1000 (C8H) Solution: (a) 99H = 153 10 5 I ref = = 2mA 1000 + 1500 153 I out = ( 2mA) = 1. 195mA 256 V out = ( 1.195mA)(5000kΩ) = 5. 975V (b) C8H = 200 10 200 I out = ( 2 ma ) = 1. 562 ma 256 V out = ( 1.562mA)(5000kΩ) = 7. 8125V 24

Example 10.4 In order to generate a star-step ramp, set up the circuit as in Figure 10.6 and connect the output to an oscilloscope. Then write a program to send data to the DAC at port 1 to generate a stair-step ramp. Solution: ORG 0H CLR A AGAIN: MOV P1, A ; send data to DAC INC A ; count from 0 to FFH ACALL DELAY ; let DAC work and recover SJMP AGAIN END 25

Example 10.5 Use the circuit in Figure 10.6, write a program to generate a sine wave of full-scale 10V output. If the output is connected to a CRO, draw the display on the CRO screen. Solution: Assume 10V full-scale voltage for the DAC output. V out = [5 + (5 sin θ)] V A table is drawn up to list the magnitude of the sine of angles between 0 and 360 degrees. The table values are integer numbers representing the voltage magnitude for the sine θ. Table 10.5 gives the angles, the sine values, the voltage magnitudes and the integer values representing the voltage magnitude for each angle (with 30 interval). 26

Table 10.5 Angle vs Voltage Magnitude for Sine Wave Angle θ (degree) Sine θ Vout 5V + (5sin θ ) Voltage Values sent to DAC 0 0 5 128 30 0.5 7.5 192 60 0.866 9.33 238 90 1.0 10 255 120 0.866 9.33 238 150 0.5 7.5 192 180 0 5 128 210 0.5 2.5 64 240 0.866 0.669 17 270 1.0 0 0 300 0.866 0.669 17 330 0.5 2.5 64 360 0 5 128 27

Program Generating a Sine Wave ORG 0H AGAIN: MOV DPTR, #TABLE MOV R2, #COUNT BACK: CLR A MOVC A,@A+DPTR MOV P1,A INC DPTR DJNZ R2, BACK SJMP AGAIN ; ORG 300 TABLE: DB 128, 192, 238, 255, 238, 192 DB 128, 64, 17, 0, 17, 64, 128 ; ; To get a better looking sine wave, regenerate the look-up table for 2-degree angles END 28

Display on the Generating Sine Wave on CRO Volts 10 9 8 7 6 5 4 3 2 1 0 30 90 150 210 270 330 360 Degrees 29

Read reference The 8051 Microcontroller and Embedded Systems - Using Assembly and C, Mazidi Chapter 13 P.373 P.405 30

Review Questions 1. In the ADC0804, the INTR signal is an (input, output) 2. In the ADC0804, to begin conversion, send a(n) pulse to pin. 3. Which pin of the ADC0804 indicates end-of-conversion? 4. In a ADC, input is (digital, analog) and output is (digital, analog). 5. Find the step size for an ADC0804 chip if V ref /2 =1.9V. 6. With V ref /2 =0.64V, find the Vin for the D7 D0 = 1001 1001 output. 7. In a DAC, input is (digital, analog) and output is (digital, analog). 8. DAC0808 is a9n) -bit D-to-A converter. 9. The output of DAC0808 is in (current, voltage). 10. Find the I out for the digital input 1110 1110 to DAC0808. Assume I ref = 2mA. 11. To get a smaller step, we need a DAC with (more, fewer) digital inputs. 12. The LM35 provides mv for each degree of (Fahrenheit, Celsius). 31

Department of Electrical Engineering END of Lecture 10 Analogue Interfacing 32