Page 308 - Making PIC Microcontroller Instruments and Controllers
P. 308
3IO I.OGGIIIG DAIA FROIII A SOLAR COLLECTOB
Pf!q,r?m ?14 Reading the sensors
REA.D SETiISORS:
j . . . o
i
ADCIN 4. INEEMP , N _ r Y o t o n a o t . h e p o . s
is to nodify this tenp, add Lhe code to read
REFT'RN
COI{TROLLII{G TIIE FAI{
This routine looks al thc intemal temperatures, and ifthe temperature is above 135'F,
it turns the fan on. 135'F approximates tho tcmpqature of the air coming out ofa res-
ideniial furnace in winter. See Program 22.5.
We will use pin D.3 to conlfol the solid state relay so we can see the condilion ofthe
relay on the bargraph when the relay is turned on. Sone relays have an LED on them,
some don't. We will be covered in either case.
ril?iqii@:?!!€: controrrinstheran
CONAROI, FA!I:
IF IlcrElqP >=135 fHEN;
PORTD.3=1
EIJSE
EAIDIF
RETURAI
UPDATING THE LCD
During each l-second cycle, the system reads all the vadables 10 appear on the LCD
anddisplays them.Itturns the fan on and off as necessary. The display is aconvenience
for the operation of the system- It can accommodate two lines of20 characters each and
we will nll these in as follows:
D=YY:MM:DD:HH:MM:SS
TEMP=TTT FAN-X
This aflangement allows the investigator to look at cunent conditions at any time.
If the investigator needs to know the actual time, they can look al a wrist watch.
Program 22.6 implements the updating ofthe LCD.
lllPaiidSf.e..4lll upcratins rhe LcD
UPDAEE NCD: ;
\t",
rcDOm $FE S80. 'D=", HEK2 RIICYEAR, ",". tc)(2 RItxl,lC|l{TE, !tE:L2
"
RTCDAFE, ',IIEX2 RIICIIR, \:/, IIEX2 RTCMIN, \:'?, HEX2 RECSEC
\UIE!IP=I,, Z
',CDOUT $FE $CO? DECA IN:[EMP, FAN=,I, DEC1 PORTD.3
RETURN

