PDA

View Full Version : WRITE REAR eeprom Address ????'s



earltyso
- 17th April 2008, 22:31
Hello,
I would like to know how to put the Address (for WRITE, READ command) in a for loop such that I can write once to adress 0, and then roll into adress 1 and so on. I have tried creating am variable but an not able to do this. Basically I am reading a POT 10x a second, sampling the data once and storing that sample in my eeprom, then reading the values back out to my LCD. I would like to use all 256 bytes of space in my eeprom while data logging.

It's probably a dumb question but....?

here is the snippet of my code that does work but is obviously a space waster



loop1:
LCDOUT 254,1
for a = 0 to 20
ADCIN 0, Value
wriTE 0, Value
y = ( Value *100 ) / 51 'divided down from * 255 / 130
LCDOUT 254,Row1,"LOG SENSOR ",DEC1 (y / 100 ),".",DEC2 ( y // 100 )," VDC"
lcdout 254,Row3+2, "0......|......5"
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _Value, 2, 2, 15, 255, lines
pause 100
next a
'FIRST DATA SAMPLE

for b = 0 to 20
ADCIN 0, Value
wriTE 1, Value
y = ( Value *100 ) / 51 'divided down from * 255 / 130
LCDOUT 254,Row1,"LOG SENSOR ",DEC1 (y / 100 ),".",DEC2 ( y // 100 )," VDC"
lcdout 254,Row3+2, "0......|......5"
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _Value, 2, 2, 15, 255, lines
pause 100
next b
'SECOND DATA SAMPLE
for c = 0 to 20
ADCIN 0, Value
wriTE 2, Value
y = ( Value *100 ) / 51 'divided down from * 255 / 130
LCDOUT 254,Row1,"LOG SENSOR ",DEC1 (y / 100 ),".",DEC2 ( y // 100 )," VDC"
lcdout 254,Row3+2, "0......|......5"
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _Value, 2, 2, 15, 255, lines
pause 100
next c
'THIRD DATA SAMPLE
for d = 0 to 20
ADCIN 0, Value
wriTE 3, Value
y = ( Value *100 ) / 51 'divided down from * 255 / 130
LCDOUT 254,Row1,"LOG SENSOR ",DEC1 (y / 100 ),".",DEC2 ( y // 100 )," VDC"
lcdout 254,Row3+2, "0......|......5"
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _Value, 2, 2, 15, 255, lines
pause 100
next d

mister_e
- 17th April 2008, 22:42
The way you do it right now write 20 time on the same EEPROM adress... well your eeprom wil wear out pretty fast huh?

Anyways, several way, the first that spring to mind is..


For EEPAddr=0 to 255
for d = 0 to 20
ADCIN 0, Value
y = ( Value *100 ) / 51 'divided down from * 255 / 130
LCDOUT 254,Row1,"LOG SENSOR ",DEC1 (y / 100 ),".",DEC2 ( y // 100 )," VDC"
lcdout 254,Row3+2, "0......|......5"
; syntax- BARgraph Value, Row, Col, Width, Range, Style
@ BARgraph _Value, 2, 2, 15, 255, lines
pause 100
next

wriTE EEPAddr, Value
next

LCDOUT $FE, 1, "Thanks for shopping here",_
$FE,$C0, "Come again :o)"


HTH

earltyso
- 17th April 2008, 23:30
Good call on the Eeprom wearing out fast.
Thanks for the help Mister E I will give it a try!