Bayside888
Active member
First of all, thanks to Flenser and bpowell for their comments to help get this project started. It reads a pressure and a temp sensor and stores the data in regular intervals, then downloads to a terminal for storage when a button is pressed.
It works just right when storing to the internal PicAxe data locations, but that limits the amount of storage space. The read/write commands are shown below, commented out. So, now I amusing a 24LC128 EEprom with the hi2cout and hi2Cin commands. The circuitry works, because I get good data out when the variables are just byte-sized. However, I get large (65,000+/-) values when the data stored are larger than 255. This may be a very simple problem solved many times, but I can’t find the answer after diligently searching the forums. I believe I need to somehow combine the byte values to make a word, but? The problem is likely in the last couple of lines, but I have included the preceding code. Regards:
It works just right when storing to the internal PicAxe data locations, but that limits the amount of storage space. The read/write commands are shown below, commented out. So, now I amusing a 24LC128 EEprom with the hi2cout and hi2Cin commands. The circuitry works, because I get good data out when the variables are just byte-sized. However, I get large (65,000+/-) values when the data stored are larger than 255. This may be a very simple problem solved many times, but I can’t find the answer after diligently searching the forums. I believe I need to somehow combine the byte values to make a word, but? The problem is likely in the last couple of lines, but I have included the preceding code. Regards:
[CODE]
#PicAxe 28X2
hi2Csetup i2cmaster, %10100000, i2cfast, i2cword 'for 24LC128 EEprom.
Symbol holdvalue1 = W3
Symbol Temp_value = W5
Symbol sensorvalue = W7
Symbol counter = W8
Symbol dataAddr = W13 'holder to keep track of storage location
; ..
; .. get pressure value from sensor = sensorvalue then store in 24LC128
holdvalue1=dataAddr 'next data set number
; write dataAddr, word sensorvalue 'for saving to internal PicAxe eeprom
hi2cout dataAddr,(sensorvalue) 'save to external EEprom
dataAddr = DataAddr+2 'plus "2" for word variables
pause 5 'pause for serial EEprom, next steps take another 5 ms
; .. get temperature value from sensor = Temp_value then store in 24LC128
; write dataAddr, word holdvalue 'write word value of temperature toPicAxe
hi2cout dataAddr,(Temp_value) 'save to external EEprom
dataAddr = DataAddr+2 'plus "2" for word variables
; routine continues logging until user stops prgm
;------------------------------------------dump data to serial line-------------------------
; this portion downloads all data in EEprom to terminal when a button is pressed
Data_dump: 'Hi2cin is always a byte
sertxd("Button pressed",#dataADDr,cr,lf) 'shows location of last data
; 'dataAddr saved from above to find last data
dataAddr = dataAddr/4 'word variables use 2 locations
dataAddr = dataAddr-4 'adjust to read back correctly
holdvalue1=0 'start at first location
for counter = 0 to dataAddr 'count data sets (not locations)
; read holdvalue1, word sensorvalue
hi2cin holdvalue1, (b14,b15)
holdvalue2=holdvalue1+2
; read holdvalue1, word holdvalue1 ;for use with PicAxe internal EEprom
hi2cin holdvalue1, (b10,b11)
sertxd(#counter," Press=",#sensorvalue," Temp=",#Temp_value,cr,lf) 'send data
holdvalue1=holdvalue1+2
[SIZE=5] next[/SIZE]