This is 2.2 portion of the PICBasic Pro lab. Read the LM35 temperature sensor da
ID: 2082915 • Letter: T
Question
This is 2.2 portion of the PICBasic Pro lab. Read the LM35 temperature sensor datasheet. Figure out how the output of the temperature sensor voltage corresponds to the actual temperature in Centigrade.
Using the program written in 2.1, add the PICBasic Pro statements need to do the following:
If the temperature sensor output voltage V0 3.33V, blink the Red LED.
If the temperature sensor output voltage is 1.67V < V0 <3.33V, blink the Green LED.
If the temperature sensor output voltage is V0 <1.67V, blink the Blue LED.
DEFINE LCD_DREG PORTC ; Set LCD Data Port C
DEFINE LCD_DBIT 4 ; Set starting bit 4
DEFINE LCD_RSREG PORTC ; Set Register Select Port C
DEFINE LCD_RSBIT 0 ; Set Register Select bit 0
DEFINE LCD_EREG PORTC ; Set Enable Port C
DEFINE LCD_EBIT 1 ; Set Enable bit 1
DEFINE LCD_LINES 2 ; Set to 2 line display
DEFINE LCD_COMMANDUS 1640 ; Set command delay time 1.64ms
DEFINE LCD_DATAUS 44 ; Set data delay time 44us
DEFINE ADC_BITS 10 ; Set number of bits in digital value
ADCON0.7=1 ; Right justify digital value
ADCON0.6=0 ; 5V is reference
TRISC=%00001100 ; Set up bit of Port C for outputs
ANSEL=%11001111 ; Set up bits for digital I/O
ANSELH=0 ; Set up bits for digital I/O
; Declare 16-bit variables
adcval VAR WORD
adcint VAR WORD
adcdec VAR WORD
PAUSE 500
; Wait for LCD to warm up
loop:
ADCIN 2,adcval
; Read A/D channel 2
adcval=adcval*49/10
; Correct for resolution
adcint=adcval/1000
; Get integer value
adcdec=adcval//1000
; Get decimal value
LCDOUT $FE,1
; Clear LCD screen
LCDOUT DEC adcint, “.”, DEC adcdec, “ V”
; Display voltage
END
PAUSE 1000
GOTO loop
; Wait for 1 second
; Start over
16F690 Pinout
LM35 Datasheet
http://www.ti.com/lit/ds/symlink/lm35.pdf
PAUSE 500
; Wait for LCD to warm up
loop:
ADCIN 2,adcval
; Read A/D channel 2
adcval=adcval*49/10
; Correct for resolution
adcint=adcval/1000
; Get integer value
adcdec=adcval//1000
; Get decimal value
LCDOUT $FE,1
; Clear LCD screen
LCDOUT DEC adcint, “.”, DEC adcdec, “ V”
; Display voltage
END
PAUSE 1000
GOTO loop
; Wait for 1 second
; Start over
OSC2 OUT DIG 10 U/DIG 54 00T 11U 11E +OABC_+ P IC 16F690 DCCT C-D OORFEDGDU 456789Explanation / Answer
Layout Guidelines The LM35 is easily applied in the same way as other integrated-circuit temperature sensors. Glue or cement the device to a surface and the temperature should be within about 0.01°C of the surface temperature. The 0.01°C proximity presumes that the ambient air temperature is almost the same as the surface temperature. If the air temperature were much higher or lower than the surface temperature, the actual temperature of the LM35 die would be at an intermediate temperature between the surface temperature and the air temperature; this is especially true for the TO-92 plastic package. The copper leads in the TO-92 package are the principal thermal path to carry heat into the device, so its temperature might be closer to the air temperature than to the surface temperature. Ensure that the wiring leaving the LM35 device is held at the same temperature as the surface of interest to minimize the temperature problem. The easiest fix is to cover up these wires with a bead of epoxy. The epoxy bead will ensure that the leads and wires are all at the same temperature as the surface, and that the temperature of the LM35 die is not affected by the air temperature. The TO-46 metal package can also be soldered to a metal surface or pipe without damage. Of course, in that case the V terminal of the circuit will be grounded to that metal. Alternatively, mount the LM35 inside a sealedend metal tube, and then dip into a bath or screw into a threaded hole in a tank. As with any IC, the LM35 device and accompanying wiring and circuits must be kept insulated and dry, to avoid leakage and corrosion. This is especially true if the circuit may operate at cold temperatures where condensation can occur. Printed-circuit coatings and varnishes such as a conformal coating and epoxy paints or dips are often used to insure that moisture cannot corrode the LM35 device or its connections. These devices are sometimes soldered to a small light-weight heat fin to decrease the thermal time constant and speed up the response in slowly-moving air. On the other hand, a small thermal mass may b
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.