Data logging to a second eeprom
lfreeze
Posts: 174
I have been working my way through data logging to the onboard EEPROM. I was successful with
The program below, but after splitting the program between a write and then a separate read program,
I noticed that all of the data written was being erased after I loaded the read program (F11)
After studying (again) the parallax labs I discovered the following statement
·
“(4) BEWARE: Downloading a program overwrites ALL EEPROM!· Your data logging application
Needs to have a built-in way of uploading the data after the measurements have been
taken because a separate program will overwrite all the collected data.”
·
My question is, can I install a separate EEPROM (24lc128) on a different pair of scl and sda pins?
I attempted this with a 24lc128 by simply changing the scl pin in my program and the basic_12c_driver.
It didn’t work. It appeared to write the data, but when reading it all I got was “-1”.· I compared the
Data sheets of the 24lc128 and 256, but do not see any addressing differences. I am probably
making some wrong assumptions with this. I searched the forum but was not able to find anything
that helped.
·
When working with the stamp, I used a 24lc128 that was part of a parallax package (#602-00013).
I hope Parallax will consider providing the same thing for the propeller.
·
CON
· _clkmode····· = xtal1 + pll16x
· _xinfreq····· = 5_000_000
·· i2cSCL······ = 28
·· EEPROMAddr·· = %10100000
·· EEPROM_Base· = $fa00'
VAR
· long· i2cAddress
OBJ
· i2cObject····· : "basic_i2c_driver"
· ser··········· : "FULLDUPLEXSERIAL"·
pub Start
·· ser.start(31, 30, 0, 9600)
···················
··· ' INITIALIZE EEPROM
·· i2cObject.Initialize(i2cSCL)
·· waitcnt (80_000_000 + cnt)
·· eeprom_write_read····
·
pub EEPROM_write_read | eepromDataw, eepromDatar,eepromLocation, ackbit
··· eepromLocation := EEPROM_Base·
··· eepromDataw···· := 0
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++··
··· repeat 10
···
····· 'WRITE TEST DATA TO EEPROM
······· eepromDataw+= 1 'TEST DATA STARTS AT 1 GOES TO 10
······· i2cObject.Writebyte(i2cSCL, EEPROMAddr, eepromLocation, eepromDataw)
······· ser.str(string("WRITE LOCATION ADDRESS = "))·
······· ser.dec(eepromLocation)
······· ser.str(string(" DATA="))
······· ser.dec(eepromDataw)
······· ser.tx(13)'carriage return
······· ser.tx(10)'line feed
······· eepromLocation +=1·· 'INCREMENT THE ADDRESS by one byte
······· waitcnt (80_000_000 + cnt)
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++················
·· eepromLocation := EEPROM_Base·
··· repeat 10
······ ' READ THE TEST DATA BACK FROM THE EEPROM
········· eepromDatar :=0
········· eepromDatar := i2cObject.Readbyte(i2cSCL, EEPROMAddr, eepromLocation)···············
········· ser.str(string("READ· LOCATION ADDRESS = "))·
········· ser.dec(eepromLocation)
········· ser.str(string(" DATA="))
········· ser.dec(eepromDatar)
········· ser.tx(13)'carriage return
········· ser.tx(10)'line feed
········· eepromLocation +=1·· 'INCREMENT THE ADDRESS by one byte
········· waitcnt (80_000_000 + cnt)
··· '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++·····
·
Thank you all in advance for your help and suggestions
·
Larry
The program below, but after splitting the program between a write and then a separate read program,
I noticed that all of the data written was being erased after I loaded the read program (F11)
After studying (again) the parallax labs I discovered the following statement
·
“(4) BEWARE: Downloading a program overwrites ALL EEPROM!· Your data logging application
Needs to have a built-in way of uploading the data after the measurements have been
taken because a separate program will overwrite all the collected data.”
·
My question is, can I install a separate EEPROM (24lc128) on a different pair of scl and sda pins?
I attempted this with a 24lc128 by simply changing the scl pin in my program and the basic_12c_driver.
It didn’t work. It appeared to write the data, but when reading it all I got was “-1”.· I compared the
Data sheets of the 24lc128 and 256, but do not see any addressing differences. I am probably
making some wrong assumptions with this. I searched the forum but was not able to find anything
that helped.
·
When working with the stamp, I used a 24lc128 that was part of a parallax package (#602-00013).
I hope Parallax will consider providing the same thing for the propeller.
·
CON
· _clkmode····· = xtal1 + pll16x
· _xinfreq····· = 5_000_000
·· i2cSCL······ = 28
·· EEPROMAddr·· = %10100000
·· EEPROM_Base· = $fa00'
VAR
· long· i2cAddress
OBJ
· i2cObject····· : "basic_i2c_driver"
· ser··········· : "FULLDUPLEXSERIAL"·
pub Start
·· ser.start(31, 30, 0, 9600)
···················
··· ' INITIALIZE EEPROM
·· i2cObject.Initialize(i2cSCL)
·· waitcnt (80_000_000 + cnt)
·· eeprom_write_read····
·
pub EEPROM_write_read | eepromDataw, eepromDatar,eepromLocation, ackbit
··· eepromLocation := EEPROM_Base·
··· eepromDataw···· := 0
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++··
··· repeat 10
···
····· 'WRITE TEST DATA TO EEPROM
······· eepromDataw+= 1 'TEST DATA STARTS AT 1 GOES TO 10
······· i2cObject.Writebyte(i2cSCL, EEPROMAddr, eepromLocation, eepromDataw)
······· ser.str(string("WRITE LOCATION ADDRESS = "))·
······· ser.dec(eepromLocation)
······· ser.str(string(" DATA="))
······· ser.dec(eepromDataw)
······· ser.tx(13)'carriage return
······· ser.tx(10)'line feed
······· eepromLocation +=1·· 'INCREMENT THE ADDRESS by one byte
······· waitcnt (80_000_000 + cnt)
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++················
·· eepromLocation := EEPROM_Base·
··· repeat 10
······ ' READ THE TEST DATA BACK FROM THE EEPROM
········· eepromDatar :=0
········· eepromDatar := i2cObject.Readbyte(i2cSCL, EEPROMAddr, eepromLocation)···············
········· ser.str(string("READ· LOCATION ADDRESS = "))·
········· ser.dec(eepromLocation)
········· ser.str(string(" DATA="))
········· ser.dec(eepromDatar)
········· ser.tx(13)'carriage return
········· ser.tx(10)'line feed
········· eepromLocation +=1·· 'INCREMENT THE ADDRESS by one byte
········· waitcnt (80_000_000 + cnt)
··· '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++·····
·
Thank you all in advance for your help and suggestions
·
Larry
Comments
the second eeprom to pins 28 and 29 but couldnt figure out how to address it properly.·I either
got eeprom error while loading the program, ·or I wrote to the onboard eeprom.· this is where
I thought it would be easier to connect the second eeprom to a new set of pins.
Larry
1) Downloading a new program to EEPROM does not affect any EEPROM above 32K bytes. It does erase the entire first 32K. The "labs" note is correct for 32K byte EEPROMs (24LC256) like on the Demo Board, PropStick, and some 3rd party boards. It does not apply to the Proto Board or the Hydra and does not apply to some 3rd party boards that have 64K (24LC512) or 128K (24LC1024) byte EEPROMs.
2) If you tied A1 high, the extra EEPROM should be addressable starting at $20000. Each address block is 64K (even if some is not present) and there are 8 possible blocks of 64K bytes for a total of 512K per pair of I/O pins.
3) A 24LC128 has only 16K bytes of storage and is addressed as the 1st 16K of a 64K address block.
4) As mentioned before, the 24Cxxx is generally equivalent to the 24LCxxx. Both Atmel and Microchip EEPROMs are functionally equivalent except for the 128K byte size. There you have to read the datasheet to see how addressing is handled.
Post Edited (Mike Green) : 9/22/2008 2:00:50 AM GMT
The first wrote to the eeprom, the second read from the eeprom. I loaded and ran
the write program. then loaded and ran the read program. Each time I did this I got no
results from the read program just "-1" for each item read. If I run the program with
the write and read combined (the one I posted) it works fine. I must have some dumb
mistake in my split versions. I will run them again in the AM and see if I can find the
problem. I prefer adding an additional eeprom as I am concerned about fiddling with
the onboard hardware as I have smoked so much of it in the past.
Thanks again
Larry
Is there a cheaper way? I'd kinda like to learn how to do this too.
[noparse][[/noparse]yes, I'm kidding]
Read the comments in the Basic_I2C_Driver source. The code is not complicated or long and it's all in Spin.
You should be able to figure it out.
Is that cheap enough? You'll certainly learn how to do this too.
I had success with the solutions suggested. The· EEPROM address of $20000 was the trick.
The first three bits matched the wiring on the EEPROM of having A1 high on the EEPROM.
·I substituted A 24lc256 for the 24lc128 as it appears that the one I was using was fried. The code
should work with either, but I could no prove it with the 128.
·
I have one more question about the basic_i2c_driver. Where is the constant “EEPROM = $A0”
Used,· The comment “I2C EEPROM Device Address” which followed it, confused me into
Thinking it was somehow related to the 19 bit address.
·
I thought it might be helpful to others to show the connections (attachment) and the object that worked.
Thank you for your help ……
··
·
CON
· _clkmode··· ··= xtal1 + pll16x
· _xinfreq····· = 5_000_000
·· i2cSCL······ = 28 '14
·· EEPROMAddr·· = %1010_0100
·· EEPROM_Base· = $20000 '
VAR
· long· i2cAddress
OBJ
· i2cObject····· : "basic_i2c_driver"
· ser··········· : "FULLDUPLEXSERIAL"·
pub Start
·· ser.start(31, 30, 0, 9600)
···················
··· ' INITIALIZE EEPROM
·· i2cObject.Initialize(i2cSCL)
·· waitcnt (80_000_000 + cnt)
·· eeprom_write_read····
·
pub EEPROM_write_read | eepromDataw, eepromDatar,eepromLocation, ackbit
··· eepromLocation := EEPROM_Base·
··· eepromDataw···· := 0
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++··
···· repeat 10
···· 'WRITE
······· eepromDataw ++·
······· i2cObject.Writebyte(i2cSCL, EEPROMAddr, eepromLocation, eepromDataw)
······· ser.str(string("WRITE· ADDRESS = "))·
······· ser.dec(eepromLocation)
······· ser.str(string("· "))
······· ser.bin(eepromlocation,19)
······· ser.str(string(" DATA="))
······· ser.dec(eepromDataw)
······· ser.tx(13)'carriage return
······· ser.tx(10)'line feed
······· eepromLocation +=1·· 'INCREMENT THE ADDRESS by one byte
······· waitcnt (80_000_000 + cnt)
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++················
·· eepromLocation := EEPROM_Base·
··· repeat 10
······ ' READ
········· eepromDatar :=0
········· eepromDatar := i2cObject.Readbyte(i2cSCL, EEPROMAddr, eepromLocation)···············
········· ser.str(string("READ· LOCATION ADDRESS = "))·
········· ser.dec(eepromLocation)
········· ser.str(string("· "))
········· ser.bin(eepromlocation,19)
········· ser.str(string(" DATA="))
········· ser.dec(eepromDatar)
········· ser.tx(13)'carriage return
········· ser.tx(10)'line feed
········· eepromLocation +=1·· 'INCREMENT THE ADDRESS by one byte
········· waitcnt (80_000_000 + cnt)
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++·····
I normally do SD data logging, but I have some space constrained applications that I need to ditch the SD. Not having a second EEPROM would just be gravy
Thanks.