Hi,
I'm looking at using an external Eprom (something like an 24LC256) to store time and temperatures, which can then be downloaded to a PC application via the serial port. However I need some pointers from you guys.
I currently have a RTC chip from which I use just time information at present.
Code:
I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl] ; read DS1307 chip
I then have the following routine to give me Hrs and Mins which I use in parts of the program where I need to compare the current time to pre-sets
Code:
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) 'convert the BCD format of the mins register and store in variable timeM
Temperatures are read from a DS18B20 (4 off) and simply end up and an array variable - Temperatures[0] - [3], and are represented by a 3 digit decimal, so 234 would be 23.4C.
There should not be much change in the temperatures as this is for my thermostat project, so the logging interval doesn't need to be too frequent (as in realtime !) probably once per minute, maybe once every 5 min - depending on the amount of data I could store in the chip. So I guess I need to use something like
Code:
IC2write, address, timeH, timeM, temperatures[0], temperatures[1], temperatures[2], temperatures[3]
I would then have a "download data" button on the PC application which would send something like "D" to the RS232 port and then once detected jumps to a subroutine where it then reads the chips contents, sends them as a data stream back to the PC application, so a single data line would probably look like
So sending that via serial
Code:
Hserout [dec TimeH, TimeM]
Hserout [DEC3 Temperatures(0)]
Hserout [DEC3 Temperatures(1)]
Hserout [DEC3 Temperatures(2)]
Hserout [DEC3 Temperatures(3)]
This is where I get stumpped !
I would probably need to use some form of delimiting character to indicate the end of a data line, or could simply send a long data stream and let the software start a new line after every 16 digits. Either way I would need to loop the above in some way for each line of data. I would also would like the memory contents cleared after the "log file" has been downloaded, so would need suggestions on how to do that.
I would welcome your ideas, and if possible some sample code.
Bookmarks