Chapter 6 Interfacing of PIC Microcontroller II The

  • Slides: 35
Download presentation
Chapter 6: Interfacing of PIC Microcontroller- II The PIC 18 Microcontroller Prof. Swati A.

Chapter 6: Interfacing of PIC Microcontroller- II The PIC 18 Microcontroller Prof. Swati A. Thete J. E. S. I. T. M. R. Nashik 1

Unit- 6: w PIC ADC interfacing (pg. no. 512) w Measurement of physical parameters

Unit- 6: w PIC ADC interfacing (pg. no. 512) w Measurement of physical parameters such as temperature, pressure, level, flow, voltage, current etc. (pg. no 652 ) w Interfacing of DAC with PIC 18 F 458 (pg. no. 661) 2

ADC Device 3

ADC Device 3

1] Resolutions : - step size is depend upon Vref. 2] Conversion time: -

1] Resolutions : - step size is depend upon Vref. 2] Conversion time: - is dictated by clock pulse connected to ADC in addition to fabrication and conversion method & technology. 3] Vref : - is the input voltage for the reference voltage 4

5

5

330_02 6

330_02 6

330_02 7

330_02 7

ADC interfacing 330_02 8

ADC interfacing 330_02 8

ADC interfacing 330_02 9

ADC interfacing 330_02 9

10

10

11

11

ADCON 0 & ADCON 1 Register w ADCON 0 register are used to select

ADCON 0 & ADCON 1 Register w ADCON 0 register are used to select conversion time and analog input channel. w In order to reduce power consumption of microcontroller, ADC features is turned off when microcontroller is power up. 330_02 12

ADCON 0 register 13

ADCON 0 register 13

ADCON 1 Register 14

ADCON 1 Register 14

330_02 15

330_02 15

330_02 16

330_02 16

17

17

330_02 18

330_02 18

330_02 19

330_02 19

20

20

21

21

DAC interfacing w Two methods for DAC w 1] Binary weighted w 2] R/2

DAC interfacing w Two methods for DAC w 1] Binary weighted w 2] R/2 R ladder 330_02 22

Interfacing of DAC with PIC 18 330_02 23

Interfacing of DAC with PIC 18 330_02 23

24

24

Measurement of physical parameters w Transducers : - which converts physical data such as

Measurement of physical parameters w Transducers : - which converts physical data such as temperature, light intensity, flow, & speed to electrical signals. w Depending on the transducer, the output produced is in the form of voltage, current, resistance, or capacitance. w For e. g. Thermister converts temperature to electrical quantity. Which is nonlinear so LM 34, 35 manufactured by national semiconductor for liner quantity so easy software programming. 25

Signal Conditioning w Most of the transducers gives output in the form of voltage,

Signal Conditioning w Most of the transducers gives output in the form of voltage, charge, current, resistance or capacitance. We need to convert this signals into voltage to give input to ADC. This conversion is called signal conditioning. 26

Temperature measurement w LM 34 & LM 35 is used for measurement of temperature.

Temperature measurement w LM 34 & LM 35 is used for measurement of temperature. w LM 34 is gives output voltage is linearly proportional to Fahrenheit temperature. And LM 35 gives in centigrade. w For both 34 & 35 no need of external calibration it is internally calibrated. 27

Temperature measurement 28

Temperature measurement 28

Temperature measurement 29

Temperature measurement 29

Program for Read the sensor & display it on PORT D CLRF TRISD BSF

Program for Read the sensor & display it on PORT D CLRF TRISD BSF TRISA, 0 BSF TRISA, 3 MOVLW 0× 81 MOVWF ADCON 0 MOVLW 0×C 5 MOVWF ADCON 1 Over ; CALL DELAY BSF ADCON 0, GO BACK ; BTFSC ADCON 0, DONE BRA BACK MOVFF ADRESL, 0× 20 MOVFF ADRESL, 0× 21 CALL ALGO_10_to_8 MOVFF BIN_TEMP, PORTD BRA OVER : PORTD output port : RA 0 input pin for analog volt : RA 3 input pin for Vref volt : Fosc/64, ch. 0, A/D on : right justified, fosc/64 : AN 0 =analog, AN 3=vref+ : Wait for Tad : start conversion : Keep polling end of conversion : save low byte to location 20 H : save high byte to location 21 H : make it 8 bit : Display the temp on PORTD 30

w ALGO_10_to_8 : : RRNCF 20 H, f : rotate right twice RRNCF 20

w ALGO_10_to_8 : : RRNCF 20 H, f : rotate right twice RRNCF 20 H, W ANDLW 0× 3 F : mask the upper 2 bits MOVWF 20 H RRNCF 21 H, f : rotate right through carry twice RRNCF 21 H, w ANDLW 0×C 0 : mask lower 6 bits IORWF 20 H, W : combine low and high MOVWF BIN_TEMP RETURN 31

w Pressure, Level, & flow measurement can be done same as temperature measurement. w

w Pressure, Level, & flow measurement can be done same as temperature measurement. w Only instead of LM 34 or 35 different sensors or transducers will be used for respective measurement of physical quantity, or sensor. w For e. g. level sensor or Bellows 32

w Voltage & Current will be measured by ADC. w For measurement of current

w Voltage & Current will be measured by ADC. w For measurement of current only current to voltage converter is connected in block diagram then that voltage quantity is applied to ADC for conversion. w So program will be same for voltage & Current. 33

END Questions? ? ? ? ? 34

END Questions? ? ? ? ? 34

THANKS ALL THE BEST …. µµµµµµ…. 35

THANKS ALL THE BEST …. µµµµµµ…. 35