Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4745

Serial data transmission period

$
0
0
Guys,

Need some advice for a bit of crude dirty code to send the time and temperature out via serial port.

Code:

main:
                     
    OWOUT TEMPIN,1,[$CC,$44]
    OWOUT TEMPIN,1,[$CC,$BE] 
    OWIN TEMPIN,0,[TempT.LowByte,TEMPT.HighByte]
    TempC = (TempT*/1600)
    LCDout $FE,$80,"Temp ",DEC (TempC/100),".",#TempC dig 1,"C"   
    tempc=tempc/10
   

I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl]  ; read DS1307 chip

LCDOut $FE,$c0+11,hex2 RTCHour,":",hex2 RTCMin

timeH=(RTCHour>>4)                                                      'convert the BCD format of the hours register and store in variable timeH
timeH=(timeH &$03)*10
timeH=timeH+(RTCHour&$0F)

timeM=(RTCMin>>4)
timeM=(timeM &$07)*10
timeM=timeM+(RTCMin&$0F)

Hserout [dec TimeH,":",dec TimeM," ",DEC(TempC/10),".",#TempC dig 1,13,10]

Pause 5000

goto main

This works fine, although I would rather data is sent once every 5 minutes. I did try and do a time match so that if minutes = 5 and seconds =0 it would send, but the program loops so fast that I still got multiple results.

So I'm just after a quick and simple bit of code to allow me to record the temperature and time stamp every 5 minutes

TIA

Malc

Viewing all articles
Browse latest Browse all 4745

Trending Articles