
Originally Posted by
sayzer
This is one good way

It seems that when this condition gets true, then it will send data for the duration of whole 1 minute.
If you also add "Second" to this condition, it will also send the data for the duration of "1" whole Second.
So a better way is to insert a flag into it.
Uhmmmm.. still not working using the example you gave
Code:
SendFlag var byte
Sendflag =1
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
LCDOut $FE,$c0, dec sendflag
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)
If (TimeM//5) = 0 and SendFlag = 0 then
Hserout [hex2 RTCHour,":",hex2 RTCMin," ",DEC(TempC/10),".",#TempC dig 1,13,10]
SendFlag = 1
ELSE
If (TimeM//6) = 0 then SendFlag = 0
ENDIF
'pause 1000
goto main
At 8:00 for example (the programmed initial time on startup), the code would send data to the serial port as a constant stream every loop of the program rather than a single entry. I added a pause statement (commented out in the code above) so I could see what was happening, and the flag kept changing from 0 to 1 and back each loop of the code. When the time changed to 8:01 the value of the flag remained static at 1, and the data stream stopped, having sent 41088 bytes through the serial port.
At 8:05 the flag remained at 1 and no data was sent. At 8:06 the flag changed to a value of 0 but again no data was sent, presumably as the condition to do so hasn't been met as whilst the flag is now zero, TimeM doesn't equal the 5 minute value ?
The flag value remained at 0 until 8:10 when a single entry was sent to the serial port. The flag then changed to 1 remained at 1 as the time changed to 8:11 until 8:12 when it changed to 0 and remained at zero
At 8:15 a single entry was sent to the port, the flag was set to 1 and remained at 1 until 8:18 when the flag value changed to 0
The flag value remained at 0 until 8:20 when a single entry was sent to the serial port. The flag then changed to 1 remained at 1 until 8:24 when it changed to 0 and remained at zero
At 8:25 a single entry was sent to the port, the flag was set to 1 and remained at 1
At 8:30 the code sent data to the serial port as a constant stream every loop of the program rather than a single entry, with the LCD displaying a blur as the value alternated between 0 and 1. At 8:31 the data stream stopped and the flag was set to 0,
So it seems to be following a pattern. Hope this feedback helps debug the code... it's beyond me !!
edit:
At 9:00 the code sent data to the serial port as a constant stream every loop of the program
Bookmarks