ADC Interfacing



Comments



Description

ADC INTERFACINGDOEACC Society, Chandigarh Centre Interface 8051 with the following Input / Output Devices  Transducer/Sensors  Analogue-to-Digital Conversion (ADC)  Digital-to-Analogue Conversion (DAC) Topic to cover 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. Transducer/sensors 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. Temperature (°C) Thermistor Resistance (kO) 0 29.490 25 10.000 50 3.893 75 1.700 100 0.817 Temperature sensors (Thermistor) Table 10.1 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. Item Temperature Range Accuracy Output LM34 -50 F to +300 F +3.0 F 10 mV/F LM34C -40 F to +230 F +3.0 F 10 mV/F LM35 -55 °C to +150 °C +1.5 °C 10 mV/°C LM35C -40 °C to +110 °C +1.5 °C 10 mV/°C LM35D 0 °C to +100 °C +2.0 °C 10 mV/°C Temperature sensors (LM34 and LM35) Table 10.2 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. Analog-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. n-bit Number of steps Step Size (mV) 8 2^8 = 256 5/255 = 19.61 10 2^10 = 1024 5/1023 = 4.89 12 2^12 = 4096 5/4095 = 1.22 16 2^16 = 65536 5/65535 = 0.076 Analog-to-digital converter (ADC ) 1 2 ÷ = n cc V Size Step Vcc is the reference voltage of ADC with n-bit resolution Table 10.3 : Resolution versus Step Size for ADC (if Vcc = 5V) ADC0804 Chip (Free Running Mode) Vin(+) Vin(÷) A GND Vref/2 CLK R CLK in CS RD D GND 20 6 7 8 9 18 17 16 15 14 13 12 11 19 4 1 2 10 3 5 D0 D1 D2 D3 D4 D5 D6 D7 WR INTR +5V To LEDs Normally open START 10k POT 10k 150 pF ADC08 04 Figure 10.1 Port of 8-bit uC ADC0804 Chip (Free Running Mode) (INTR tied to WR with. CS = 0 V) Continuous Conversions (Extracted from Page 11 Of Spec sheet of ADC0804) Pin diagram ADC0804 D0 D1 D2 D3 D4 D5 D6 D7 V I + V REF /2 V I - CLK INTR WR RD CS CLKR AGND V CC DGND 20 19 18 17 16 15 14 13 12 11 1 2 3 4 5 6 7 8 9 10 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. 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. 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. 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 255 V 1 2 2 V 2 size step REF 8 REF = ÷ × = Pin Vref/2 is open, Step size =19.6mV ADC0804 has resolution of 8 bits 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: 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. size Step V D in out = Question: An analog input voltage of 3.5V, Pin Vref/2 is open. Solution: Dout = 3.5V / 19.6mV = 178 or 179 (depends on accuracy of ADC) 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. Signal control on ADC0804 Read it End conversion Start conversion Data out CS WR D0 – D7 INTR RD Note: CS is set to low for both RD and WR pulses The timing diagram of ADC0804 Figure 10.2 Testing the ADC0804 P2.5 P2.6 P1.0 P1.7 P2.7 RD WR D0 : : : : : D7 INTR CS A GND Vref/2 D GND V CC CLK R CLK IN 10k POT +5V 8051 ADC0804 V in (+) V in (÷) P2.5 P2.6 Example 10-1 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 Referred to Example 10.1, the digital values output from the ADC0804 correspond to the analogue voltage inputs. It is calculated by: 1 2 ÷ = n cc V Size Step V Size Step 019608 . 0 255 5 1 2 5 8 = = ÷ = Analogue input voltage V in (V) Digital Value Output D out 0 0/0.019608 = 0 0.5 0.5/0.019608 = 26 1.0 1.0/0.019608 = 51 1.5 1.5/0.019608 = 77 2.0 2.0/0.019608 = 102 size Step V D in out = 5.0 5.0/0.019608 = 255 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 Example of ADC Application Interfacing with the LM35 (Temperature Sensor) P2.5 P2.6 P1.0 P1.7 P2.7 RD WR D0 D7 INTR CS A GND Vref/2 D GND V CC CLK R CLK IN +5V 8051 ADC0804 XTAL1 XTAL2 Q Q D Q V in (+) V in (÷) Set to 1.28V LM35 Clock freq ÷ 4 Q Q D Q  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: BH or x D out 9 155 38 . 154 01004 . 0 01 . )) 55 ( 100 ( = = ÷ ÷ = Example ADC Application size Step V D in out = ADC 0808/0809 CHIP WITH 8 ANALOG CHANNEL  ADC 0804 has one input, this chip has 8 inputs.  A,B,C addresses to select IN0-IN7 and activate ALE to latch in the address  SC to start conversion  SC is same as WR  EOC – end of conversion  EOC is same as INTR  OE – output enable(READ)  OE is same as RD ADC0808/0809 ANALOG CHANNEL SELECTION Selected Analog Channel C B A IN0 0 0 0 IN1 0 0 1 IN2 0 1 0 IN3 0 1 1 IN4 1 0 0 IN5 1 0 1 IN6 1 1 0 IN7 1 1 1 ALGORITHM  Select an analog channel by provide bits to A, B, C.  NOTE : there is no self-clocking and clock must be provided from an external source to the CLK pin. Hence Enable clock  Activate ALE (address latch enable) with a low-to-high pulse.  Activate SC (start conversion) with a high-to-low pulse The conversion is begun on the falling edge of the start conversion pulse.  Monitor EOC (end of conversion) Pin .After conversion this pin goes high.  Activate OE (output enable) with a low-to-high pulse to read data out of the ADC chip. SELECTING A CHANNEL AND READ TIMING PROGRAM 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-to-Analog (DAC) Conversion D0 D7 DAC Digital inputs Analog output (Voltage or current) Figure 10.5 DAC0808 Chip (MC1408) P2.5 P2.6 P1.0 P1.7 V ref (e.g +5V) 8051 V out = 0 to 10V D0 D7 Comp. V ee V CC DAC0808 V in (+) V in (÷) GND +5V R ref1 I out ÷ 15V I ref = V ref /(R ref1 +R ref2 ) = 2mA (Typical) To Scope I ref R ref 2 R 0 ÷ + Figure 10.6 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 out 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: Converting I out to voltage (V out ) Connect the output pin I out to a output standard resistor and hence convert this current to a voltage. | . | \ | + + + + + + + = 256 D 128 D 64 D 32 D 16 D 8 D 4 D 2 D 0 1 2 3 4 5 6 7 ref out I I Output voltage, V out = I out x R o Solution: (a) 99H = 153 10 (b) C8H = 200 10 Example Assume that Ro = 5kO, R ref1 = 1k O, R ref2 = 1.5k O 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) mA I ref 2 1500 1000 5 = + = mA mA I out 195 . 1 256 153 ) 2 ( = = V k mA V out 975 . 5 ) 5000 )( 195 . 1 ( = O = mA mA I out 562 . 1 256 200 ) 2 ( = = V k mA V out 8125 . 7 ) 5000 )( 562 . 1 ( = O = Example 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 Example 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 u)] 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 u. 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). Table : Angle vs Voltage Magnitude for Sine Wave Angle u (degree) Sine u Vout 5V + (5sin u ) 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 Vout x 256/10 256 steps and full scale Vout is 10 volts 9.33*256/10 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 Display on the Generating Sine Wave on CRO 30 90 150 210 270 330 10 9 8 7 6 5 4 3 2 1 0 u /Degrees V / Volts V = 5 + 5 * sin u FFh 80h D7..D0 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).  Review Questions Topic to cover Interface 8051 with the following Input / Output Devices  Transducer/Sensors  Analogue-to-Digital Conversion (ADC)  Digital-to-Analogue Conversion (DAC) 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. Temperature sensors (Thermistor) Temperature can be converted to electrical signals by thermistor.700 0.817 . But its response is not linear. Thermistor is a kind of resistor responds to temperature change by changing its resistance.490 10.1 Temperature (C) 0 25 50 75 100 Thermistor Resistance (k) 29. Table 10.893 1. as seen in the Table 10.000 3.1 below. They require no external calibration since it is internally calibrated.0 C 10 mV/C 10 mV/C .5 C Output 10 mV/F 10 mV/F 10 mV/C LM35C LM35D -40 C to +110 C 0 C to +100 C +1.2 Item LM34 LM34C LM35 Temperature Range -50 F to +300 F -40 F to +230 F -55 C to +150 C Accuracy +3. Table 10.Temperature sensors (LM34 and LM35) 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.0 F +1.0 F +3.5 C +2. Their output voltage changes 10mV for each degree of temperature change. .Analog-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. where n can be 8. The higher-resolution ADC provides a smaller step size. 12. ADC are the most widely used devices for data acquisition ADC has n-bit resolution. 16 or even 24 bits. Step size is the smallest change that can be recognized by ADC. Analog-to-digital converter (ADC ) An ADC has a resolution of 8 bits. the range is divided into 2^8=256 steps (from 0 – 255).89 5/4095 = 1.076 . But there are 255 quantization levels.22 16 2^16 = 65536 5/65535 = 0.61 5/1023 = 4.3 : Resolution versus Step Size for ADC (if Vcc = 5V) n-bit 8 10 12 Number of steps 2^8 = 256 2^10 = 1024 2^12 = 4096 Step Size (mV) 5/255 = 19. Vcc Step Size  n 2 1 Vcc is the reference voltage of ADC with n-bit resolution Table 10. 1 .ADC0804 Chip (Free Running Mode) +5V 20 10k POT 6 Vin(+) 7 Vin() 8 A GND 9 Vref/2 19 CLK R CLK in CS RD D GND 10k 150 pF 4 1 2 10 ADC08 04 D0 D1 D2 D3 D4 D5 D6 D7 18 17 16 15 14 13 12 11 Port of 8-bit uC To LEDs WR INTR 3 5 Normally open START Figure 10. ADC0804 Chip (Free Running Mode) Continuous Conversions (Extracted from Page 11 Of Spec sheet of ADC0804) CS RD WR CLK INTR VI + VI AGND VREF/2 DGND 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 VCC CLKR D0 D1 D2 D3 D4 D5 D6 D7 Pin diagram ADC0804 (INTR tied to WR with. CS = 0 V) . the INTR pin is forced low by the ADC0804. If CS = 0 when WR makes a low-to-high transition. . 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.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 the data conversion is complete. the ADC0804 starts converting the analog input value of Vin to an 8-bit digital number. WR (start conversion) Active low input used to inform the ADC0804 to start the conversion process. The clock affect the conversion time and this time cannot be faster than 110s. it goes low to signal the CPU that the converted data is ready to be picked up. INTR (end of conversion) This is an active low output pin. . When the conversion is finished.1RC). f = 1/(1. Vin (+) and Vin () These are the differential analog inputs where Vin = Vin (+)  Vin (). we make CS = 0 and send a high-to-low pulse to the RD pin to get the data out of the ADC0804 chip. Often the Vin () pin is connected to ground and the Vin (+) pin is used as the analog input to be converted to digital.ADC0804 Chip CLK IN and CLK R Connect to external capacitor and resistor for self-clocking. After INTR goes low. the analog input voltage for the the ADC is ranged from 0 to 5 volts.5 Vin (V) 0 to 5 0 to 4 0 to 3 0 to 2.ADC0804 Chip VCC VREF V step size  8 2  REF 255 2 1 2 This is the +5V power supply.28 1.84 1/255 = 3. 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.0 0. Step size =19.56/255 = 10.76 2.60 4/255 = 15. If this pin is open.6mV . Vref/2 (V) Not connected 2.69 3/255 = 11.56 0 to 2 0 to 1 Step Size (mV) 5/255 = 19.04 2/255 = 7.0 1.92 ADC0804 has resolution of 8 bits Pin Vref/2 is open.5 1. 5V. Pin Vref/2 is open. Question: An analog input voltage of 3.6mV = 178 or 179 (depends on accuracy of ADC) . These are the tri-state buffered and the converted data is accessed only when CS = 0 and RD is forced low.ADC0804 Chip D0 – D7 D0 – D7 are the digital data output pins. The output voltage: Dout 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.5V / 19. Solution: Dout = 3. Keep monitoring the INTR pin. 2. 3. keep polling until it goes low. . If INTR is high. After the INTR has become low. the conversion is finished and we can go to the next step. we make CS = 0 and send a Hto-L pulse to the RD pin to get the data out of the ADC0804 IC chip.Signal control on ADC0804 Make CS = 0 and send a L-to-H pulse to pin WR to start the conversion. 1. If INTR is low. 2 Read it Note: CS is set to low for both RD and WR pulses .The timing diagram of ADC0804 CS WR D0 – D7 INTR Start conversion Data out End conversion RD Figure 10. 7 P2.5 P2.0 ADC0804 RD WR D0 : : : : : D7 VCC CLK R CLK IN Vin(+) Vin() +5V 10k POT P1.6 P1.Testing the ADC0804 8051 P2.7 A GND Vref/2 D GND CS INTR . make P1=input BACK: CLR P2. Then call a subroutine to display the input value on a 7-segment display. MOV P1.5 .6 = WR (Start conversion needs a L-to-H pulse) .0 – P1.7 = D0 – D7 of the ADC0804 .7. wait for end of conversion CLR P2. . P2.6 . display the data SETB P2. P2. P1. Do this continuously. WR=0 SETB P2.5 . WR=1 L-to-H to start conversion HERE: JB P2.5 = RD (H-to-L will read the data from ADC chip) .Example 10-1 Write a program to monitor the INTR pin and bring the digital input value into register A. end-of-conversion) . read the data ACALL DATA_DISPLAY .7 = INTR (When low. make RD=1 for next round SJMP BACK .6 . conversion finished. #0FFH . P1 .P2. enable RD MOV A. HERE . Referred to Example 10.019608 = 51 1.0/0.019608 = 255 . the digital values output from the ADC0804 correspond to the analogue voltage inputs.0 0.5/0.0 1.5 2.5 1.5/0.019608 = 0 0.019608 = 77 2.1.019608 = 26 1.0 5. It is calculated by: V Step Size  n cc 2 1 5 5 Step Size  8   0.0/0.0/0.019608 = 102 5.019608V 2  1 255 Dout  Vin Step size Analogue input voltage Vin (V) 0 Digital Value Output Dout 0/0. which correspond to the measured temperature. They are then handled by the 8051 .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. 7 INTR Set to 1.Interfacing with the LM35 (Temperature Sensor) 8051 XTAL1 XTAL2 P1.5 P2.0 D Q Q P1.28V .6 LM35 Vin(+) Vin() A GND Vref/2 D GND CS D7 P2.7 D Q Q Clock freq  4 ADC0804 RD WR D0 VCC CLK R CLK IN +5V P2. 38  155 or 9 BH 0. Step size of the ADC0804 = (1. which correspond to the measured temperature.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  154.Example    ADC Application  The ADC0804 converts the output voltages from the LM35 into digital signals.01004 Dout  Vin Step size Dout  . C addresses to select IN0-IN7 and activate ALE to latch in the address  SC to start conversion   SC is same as WR EOC is same as INTR EOC – end of conversion   OE – output enable(READ)  OE is same as RD .  A.B. this chip has 8 inputs.ADC  0808/0809 CHIP WITH 8 ANALOG CHANNEL ADC 0804 has one input. ADC0808/0809 ANALOG CHANNEL SELECTION Selected Analog Channel C B A IN0 IN1 IN2 0 0 0 0 0 1 0 1 0 IN3 IN4 IN5 IN6 IN7 0 1 1 1 1 1 0 0 1 1 1 0 1 0 1 . Hence Enable clock Activate ALE (address latch enable) with a low-to-high pulse. C.  Activate SC (start conversion) with a high-to-low pulse The conversion is begun on the falling edge of the start conversion pulse.After conversion this pin goes high.  Monitor EOC (end of conversion) Pin .ALGORITHM  Select an analog channel by provide bits to A.  Activate OE (output enable) with a low-to-high pulse to read data out of the ADC chip. B.  NOTE : there is no self-clocking and clock must be provided from an external source to the CLK pin.  . SELECTING A CHANNEL AND READ TIMING . PROGRAM . . D0 Digital inputs D7 DAC Analog output (Voltage or current) Figure 10. It does the reverse operation of an ADC The resolution of DAC depends on the no. An 8-input DAC provides 256 discrete voltages (or current) levels of output. of binary bits input to it.5 .Digital-to-Analog (DAC) Conversion The digital-to-analog converter (DAC) is a device widely used to convert digital values to analog signals. (The 12-bit DAC gives 4096 discrete levels). The common ones are 8. 10 and 12 bits. 7 D7 Vee  15V GND Figure 10.6 .6 VCC Rref1 Vin(+) Vin() Iref Rref 2 Iout R0  + Vref (e.0 D0 DAC0808 8051 Comp.g +5V) Iref = Vref/(Rref1+Rref2) = 2mA (Typical) P1.DAC0808 Chip (MC1408) +5V P2.5 P2. To Scope Vout = 0 to 10V P1. • Then by connecting a resistor to the Iout pin. Output voltage. • The total current provided by the output Iout pin is a function of the reference current (Iref) and is follows: D  D D D D D D D I out  I ref  7  6  5  4  3  2  1  0  4 8 16 32 64 128 256   2 Converting Iout to voltage (Vout) Connect the output pin Iout to a output standard resistor and hence convert this current to a voltage. the digital inputs are converted to corresponding current (Iout).DAC0808 Chip (MC1408) Operating Principle • In the DAC0808. Vout = Iout x Ro . the current will further convert to voltage level. 562 mA )( 5000 k)  7. Rref2 = 1.195 mA )( 5000 k)  5.195mA 256  (1.975V 200  1.5k  and using a standard 5V supply connected to Vref(+). (a) 1001 1001 (99H) (b) 1100 1000 (C8H) Solution: I ref  5  2mA 1000  1500 (a) 99H = 15310 I out  (2mA) Vout 153  1.Example Assume that Ro = 5k.562mA 256 (b) C8H = 20010 I out  ( 2mA) Vout  (1.8125 V . calculate Vout for the following binary inputs. Rref1 = 1k . Example In order to generate a star-step ramp. let DAC work and recover . Solution: ORG 0H CLR MOV INC ACALL SJMP END AGAIN: A P1. set up the circuit as in Figure 10.6 and connect the output to an oscilloscope. A A DELAY AGAIN . count from 0 to FFH . send data to DAC . Then write a program to send data to the DAC at port 1 to generate a stair-step ramp. Vout = [5 + (5 sin )] V A table is drawn up to list the magnitude of the sine of angles between 0 and 360 degrees. draw the display on the CRO screen. .6. Solution: Assume 10V full-scale voltage for the DAC output.5 gives the angles. The table values are integer numbers representing the voltage magnitude for the sine . the voltage magnitudes and the integer values representing the voltage magnitude for each angle (with 30 interval).Example Use the circuit in Figure 10. If the output is connected to a CRO. Table 10. the sine values. write a program to generate a sine wave of full-scale 10V output. 669 2.5 0 7.866  0.5 0.5 9.Vout x 256/10 Table : Angle vs Voltage Magnitude for Sine Wave Angle  (degree) 0 30 60 90 120 Sine  0 0.866 1.669 0 0.33*256/10 .5  0.5 5 2.33 10 9.33 Voltage Values sent to DAC 128 192 238 255 238 150 180 210 240 270 300 330 360 0.866  1.5 0  0.5 0.0 0.866 Vout 5V + (5sin  ) 5 7.0  0.5 5 192 128 64 17 0 17 64 128 256 steps and full scale Vout is 10 volts 9. 0. 128 . . 238. 238. #TABLE MOV R2. To get a better looking sine wave. ORG 300 TABLE: DB 128.Program Generating a Sine Wave ORG 0H AGAIN: MOV DPTR. 17.A INC DPTR DJNZ R2.@A+DPTR MOV P1. 192 DB 128. 192. 64. BACK SJMP AGAIN . regenerate the look-up table for 2-degree angles END . #COUNT BACK: CLR A MOVC A. 17. 255. 64. Display on the Generating Sine Wave on CRO D7..D0 FFh V / Volts 80h 10 9 8 7 6 5 4 3 2 1 0 30 90 150 210 270 330 V = 5 + 5 * sin   /Degrees . 8. DAC0808 is a9n) ___-bit D-to-A converter. In the ADC0804. send a(n) ______ pulse to pin _____ . Assume Iref = 2mA. to begin conversion. The output of DAC0808 is in _________ (current. 7. input is ________ (digital. output) 2. analog). Which pin of the ADC0804 indicates end-of-conversion? 4.Find the Iout for the digital input 1110 1110 to DAC0808. 9. 3. Find the step size for an ADC0804 chip if Vref/2 =1. the INTR signal is an _____ (input. In a DAC. In the ADC0804.To get a smaller step. find the Vin for the D7 –D0 = 1001 1001 output. With Vref/2 =0. 12. Review Questions 1. we need a DAC with _____ (more. voltage).The LM35 provides ____mV for each degree of _______ (Fahrenheit. Celsius). 6. In a ADC. .9V . analog). 11.64V. input is ________ (digital. analog) and output is _______ (digital. 10. analog) and output is _______ (digital. 5. fewer) digital inputs.
Copyright © 2024 DOKUMEN.SITE Inc.