24lc256 eeprom

abrell68

New Member
Hello

I am working on a picaxe project using a 20x2 uc. I am writing a five digit variable number to a 24lc256 i2c eeprom. For example if the variable number is 23456, then I write number 2 in location 0,number 3 in location 1, and so on. That seems to be the easy part. The difficult part is retreiving this five digit number and writing it back to a word variable in the picaxe. I can do it using a lot of math and using up a lot of variables, But does anyone know of an easier way to write a word variable to the picaxe. thanks for any help
 

eclectic

Moderator
Hello

I am working on a picaxe project using a 20x2 uc. I am writing a five digit variable number to a 24lc256 i2c eeprom. For example if the variable number is 23456, then I write number 2 in location 0,number 3 in location 1, and so on. That seems to be the easy part. The difficult part is retreiving this five digit number and writing it back to a word variable in the picaxe. I can do it using a lot of math and using up a lot of variables, But does anyone know of an easier way to write a word variable to the picaxe. thanks for any help
Welcome to the Forum.
I don't have the knowledge to answer your question fully,
but please read
http://www.rev-ed.co.uk/docs/axe110_i2c.pdf

especially page 5.

The experts will give you serious answers soon. :)

e
 

MartinM57

Moderator
Reconstructing the number from EEPROM is just the reverse of the deconstructing that you must have done to get the individual digits to put into each location ;)

wordvar = loc0 * 10000
wordvar = loc1 * 1000 + wordvar
wordvar = loc2 * 100 + wordvar
wordvar = loc3 * 10 + wordvar
wordvar = loc4 + wordvar

(Hippy will come along with the better one-liner that he knows)

How big can the number be? Is it always positive? If it was conveniently 0-65535 (the size of a word variable) then you could store it in two EEPROM locations (using the WORD qualifier in the command) and everything would be trivial. If it's 0-99999 then you have problems (=impossible) holding greater than 65535 in a word variable anyway.

Why do you want to store the number in five EEPROM locations?
 
Last edited:

westaust55

Moderator
If your 5-digit variable is in say word variable w5, that equates to byte variables b11:b10

So write those two byte variables to the external EEPROM
Hi2cout locn (b11,b10)
When you want to retrieve the value from the EEPROM use
Hi2cin locn (b11,b10)
And the value is put back into word variable w5
No math needed
 

MartinM57

Moderator
Hmmm...by the WORD qualifier I meant as part of the WRITE command...but I got it a bit screwy as OP is talking about external EEPROM, whereas WRITE is for internal EEPROM.

So another question is why an external EEPROM and not the PICAXE EEPROM?

All dependant on how big the 5 digit numbers are as well - if they're >65535 then there is an inherent problem in storing them in a word variable anyway.
 

abrell68

New Member
eeprom

Hi I used the dig command to get digits from word. But I cant use the dig command to change a word variable. The highest number I will use is 64000. Thanks for your reply


Reconstructing the number from EEPROM is just the reverse of the deconstructing that you must have done to get the individual digits to put into each location ;)

wordvar = loc0 * 10000
wordvar = loc1 * 1000 + wordvar
wordvar = loc2 * 100 + wordvar
wordvar = loc3 * 10 + wordvar
wordvar = loc4 + wordvar

(Hippy will come along with the better one-liner that he knows)

How big can the number be? Is it always positive? If it was conveniently 0-65535 (the size of a word variable) then you could store it in two EEPROM locations (using the WORD qualifier in the command) and everything would be trivial. If it's 0-99999 then you have problems (=impossible) holding greater than 65535 in a word variable anyway.

Why do you want to store the number in five EEPROM locations?
 

abrell68

New Member
eeprom

Hi I am aware of the maximum 65535. My maximum number will be 64000. I will check the count of the word variable at the end of my rpm data logger and I will store that word in the 24lc512 which can store 64000 bytes. The next playback of the data logger I will call up the stored word variable and playback until I reach the stored number. I am going to try to get the resolution as fine as possible thats why I need lots of memory. Thanks for your reply



Hmmm...by the WORD qualifier I meant as part of the WRITE command...but I got it a bit screwy as OP is talking about external EEPROM, whereas WRITE is for internal EEPROM.

So another question is why an external EEPROM and not the PICAXE EEPROM?

All dependant on how big the 5 digit numbers are as well - if they're >65535 then there is an inherent problem in storing them in a word variable anyway.
 

abrell68

New Member
eeprom

thanks very much for your reply. I will try what you suggested


If your 5-digit variable is in say word variable w5, that equates to byte variables b11:b10

So write those two byte variables to the external EEPROM
Hi2cout locn (b11,b10)
When you want to retrieve the value from the EEPROM use
Hi2cin locn (b11,b10)
And the value is put back into word variable w5
No math needed
 

abrell68

New Member
eeprom

Thanks I think I was trying to make it more complicated than it actually is. Apperciate your help.


If your 5-digit variable is in say word variable w5, that equates to byte variables b11:b10

So write those two byte variables to the external EEPROM
Hi2cout locn (b11,b10)
When you want to retrieve the value from the EEPROM use
Hi2cin locn (b11,b10)
And the value is put back into word variable w5
No math needed
 

MartinM57

Moderator
Simple is good ;)

Don't forget about:
- the page writing aspects of the 24LC512
- EEPROM write endurance
- EEPROM write time - it's not instantaneous.

You might also like to Google RAMTRON FRAM for a alternative with virtually no limit on write endurance, single byte writing and clock speed write times (i.e. no measurable delay at all)
 
Top