Page 309 - Making PIC Microcontroller Instruments and Controllers
P. 309

UPDATII|G THE LCD  0 t l



                  SEI{DII{G  THE DATA TO A COMPUTER
                  The mutine in Pro$mn 22.7 checks the  time on the intemal clock to determine  when to send
                  the data  to the computer It monitors the seconds  display. When 1 minute has  passed,  the
                  seconds  go  to 00.  At that time, the  prcgram  jumps  to  ihe Send  mutine ard aI lhe data  to be
                  recorded is sent  to the computer for storage. Then, it pauses  for I second  to make sure it will
                  not see 00 in the seconds  counter again within this minute and condnues.

                  Lgi*Ub!!gK?l:    sendins  data to the computer
                   SEND_DATA:
                                       'SENDING
                   I,CDOUT  $FE.  $80,           DATA
                   r,cDour  $FE. sco.  "
                   sEROm  PORfC.5,  T2400,  IRTCYEAR,  RTO,TOA]]E.RICDAEE,  RE(IIR,   RTCMIII,  _
                   RT.CSEC. TNTEMP, PORTD.3.  10,  13I
                   EIJSE
                   ENDIF
                   PAUSE 1OO O
                   RETI'RN

                    If there has been a power failure, the appropriate compensation will  be made when
                  the data  is analyzed. lf  for some re.rson the  power is off for morc than a day,  there will
                  be a  problem  with data lost for lhat day, but for an investigation of dris kind that is not
                  really critical.
                    When we combine  all of the  precedirg  routines in one  lisling, we get  whatt  shown  jn
                  Progran 22.8. This program  is set up to record the data every 5 seconds  so you can see
                  what is  going  on both in the  LAB-X I and in the computer in real time.  The computer must
                  be set up as a dumb terminal  to match the requiremenls of the outpul  from the LAB-XI
                  for all this to work as desired.  Afler you are sure the  program  is working as expected,  you
                  can  charye the time between tmnsmissions to once  a minute or whatever is desired.

                  iis.iii€nilg*lt   The linished program  for lhe solar collector (Solar  collector-based
                    dala  logglng)

                    CI.EAR
                    DEFINE   OSC  {                     detuae osc  speed
                    INCI.I'DE'MODEDEFS.   BAS"          include  shifbin/out   nodes
                    DEFINE   '.CD  DREG  PORTD          def,ne  the  LCD connecLions
                    DEFINE  t.CD  DBIT  4
                    DEFINE  I.CD  RSREG  PORTE
                    DEFINE  t.CD  RSEIIT  O
                    DEFINE   I.CD  EREG  PORTE
                    DEFINE  I.CD  EBIT  1
                    DEEINE  ADC,BITS   S                set  nuhber  of  birs  in  result
                    DEFINE  TDC_CLOCK  3                se!  inlernal  cLock source  i3=rc)
                    DEFINE  ADC_SAITPIJEUS  50          se!  saipling   Line  in  us
                    !o$I  PORlrE.2

                                                                                (Continue.,
   304   305   306   307   308   309   310   311   312   313   314