Page 1 of 1
Incrementing in EEPROM
Posted: Thu Jan 06, 2011 10:35 am
by nmindana
Hello,
I am triying to record(time) external event using memory locations in EEPROM. My idea is to store the time of the event in a different EEPROM location each time, which can later be read. My problem is that I am unable to write it to a different address on each external event, and the previous location address is being re-written.
Please see attached and advice.
Re: Incrementing in EEPROM
Posted: Thu Jan 06, 2011 10:58 am
by saschech@gmx.de
Hello nmindana
Work in the eeprom_macro instead 0 >>>>> global int variable "adress_finger" (adressfinger = adressfinger +1 or adressfinger = 2 .........)
so you can update variable "adressfinger" on all location inside your code.
Regards Wolfgang
Re: Incrementing in EEPROM
Posted: Thu Jan 06, 2011 3:28 pm
by nmindana
Thanks very much,
I am a novice and hence struggling to understand, would you be able to explain it a little bit in more detail please.
I did create the eeprom macro, does it need a calculation / c code ?
Please enlighten !
Regards
Re: Incrementing in EEPROM
Posted: Thu Jan 06, 2011 4:04 pm
by Benj
Hello,
Here is an example that should allow multiple events to go into the EEPROM.
Edit: The decision should say
EEAddress < 127
instead of
EEAddress < 128
Which may cause an error during runtime as 127 is the last address of the EEPROM in the device you are using.
Re: Incrementing in EEPROM
Posted: Thu Jan 06, 2011 4:10 pm
by saschech@gmx.de
Hello
Cheer up!
have a look at xxxxxxxxxxxxx modify.
Regards wolfgang
Re: Incrementing in EEPROM
Posted: Thu Jan 06, 2011 6:29 pm
by nmindana
Phew!
Many thanks Its fascinating to see how flow code can easily be manipulated, to achieve the desired results.
How do I now place the (hours,minutes and seconds) of each event in a single memory location, in the modified example, only
the last digit of the seconds is being stored in EEPROM.
Please help.
At last there is hope.
Indana
Re: Incrementing in EEPROM
Posted: Thu Jan 06, 2011 7:07 pm
by saschech@gmx.de
Hello
In 1 eeprom-adresse you can only store 1 number(0to255 0x00 to 0xff) 1= 0x31 ; 2= 0x32 ; *= 0x2a....
so for 31sec you must take 2 adresses ad0= 1= 0x31 ; ad2= 3 = 0x33
for 24:30:11 you must use 6 adresses
Regards Wolfgang
Re: Incrementing in EEPROM
Posted: Fri Jan 07, 2011 9:45 am
by Benj
Hello,
Here is a quick example of how you might do the time storage across 3 EEPROM byte variables. Each read back would have to collect all 3 values making the maximum number of time stamps you can hold on this device = 128 / 3 = 42 complete entries.
Re: Incrementing in EEPROM
Posted: Fri Jan 07, 2011 10:27 am
by nmindana
Thanks for the example, but it only reads the last bit in the seconds/min/hours ?
What if I just want to use hours and minutes, that would use up 4 address. How do I write both bits in the seconds & minutes.
Sorry Its a learning curve for me.
regards
Re: Incrementing in EEPROM
Posted: Fri Jan 07, 2011 11:16 am
by nmindana
Many thanks for a quick response,
How do I move the eeprom event recording address to a new location every 24 hrs, so although there are no recorded events
for one day, if an event happens the 2nd day, it moves to a different location address until the eepprom is full.
Hope this makes sense !
regards
Re: Incrementing in EEPROM
Posted: Fri Jan 07, 2011 11:36 am
by Benj
Hello,
Thanks for the example, but it only reads the last bit in the seconds/min/hours
Are your seconds/ mins / hours being created in ASCII? The best way to do timing is to use byte variables for the second, min and hour counts that way they only consume 1 byte each. Then when you want to print out the time etc you can use the print number routines to convert to ASCII strings. Maybe I am missing the point of what you are trying to do.
How do I move the eeprom event recording address to a new location every 24 hrs, so although there are no recorded events
for one day, if an event happens the 2nd day, it moves to a different location address until the eepprom is full.
To increment the address everyday you would have to find a time to do the change. Eg at midnight when the hour variable moves from 23 to 0 you can then increment the eeprom address by 3 or by how ever many bytes are being used for a time stamp record.
You could even have a variable that is set to 1 if the time stamp is recorded that day and then check the variable before you do the daily increment so you don't increment twice in one day. Doing this you would have to remember to clear the variable again when you move to the next day.
Hope this helps.
Re: Incrementing in EEPROM
Posted: Mon Jan 10, 2011 10:48 am
by nmindana
Hi thanks for all your help.
Just wondered How do I now read all the data from the EEprom memory with a click of a button, I want the data to be processed before it is displayed on an LCD. I want to divide the recorded events time 24hr clock into three, to say
early / middle/ late , and show the recorded events as a percentage on the display. for example.
Early(first 8hrs) : 45% events occured
Middle (next 8hrs): 25%...ect of the total number of events.
Is this possible ? Can the PIC actually do these calculations using flowcode, and display the result ?
Please advice.
Re: Incrementing in EEPROM
Posted: Mon Jan 10, 2011 11:29 am
by Benj
Hello,
Yes Flowcode can do this, All you would have to do is something along the lines of the following.
1) Wait for switch press
2) Read EEPROM values into variables
3) Perform calculation
4) Use decision to detect if variables are in range
5) Output to LCD
Have a go at putting the flowchart together. If you get stuck or are unsure where to go then post up what you have so far and I will have a quick look for you.
Re: Incrementing in EEPROM
Posted: Tue Jan 11, 2011 8:26 am
by nmindana
Thanks Ben,
Din't know where to start, how do I load all the eeprom data into variables. Do I have to read each address one at a time or is
there a quick way, once having read these, assign one variable to each address ? that will be 128 variables for the eeprom data to handle ? Sorry am I thinking the right way here, please elaborate.
Regards
Indana
Re: Incrementing in EEPROM
Posted: Wed Jan 12, 2011 1:00 pm
by nmindana
Hi, please help me to read all the eeprom data on pressing the read button and then displaying the read data as a percentage.
file attached
for example 20%(of evnts) in the first 4 hrs
60% next 4hrs out of 12 hrs.
Please note the first eeprom '0'address, counts the number of events. the events are recorded from address '1'.
I am presently using seconds as hours to test.
I have tried my best with my limited knowledge to work it out but failed miserably after 2 days, any help is much appreciated.
thanks
regards