Incrementing in EEPROM

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Incrementing in EEPROM

Post 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.
Attachments
data logging.fcf
(18.36 KiB) Downloaded 315 times

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: Incrementing in EEPROM

Post 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

nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Re: Incrementing in EEPROM

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Incrementing in EEPROM

Post 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.
Attachments
data logging.fcf
(19.04 KiB) Downloaded 324 times

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: Incrementing in EEPROM

Post by saschech@gmx.de »

Hello

Cheer up!

have a look at xxxxxxxxxxxxx modify.

Regards wolfgang
Attachments
data logging.fcf
(19.18 KiB) Downloaded 292 times

nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Re: Incrementing in EEPROM

Post 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

saschech@gmx.de
Posts: 714
Joined: Wed Jan 31, 2007 12:41 pm
Has thanked: 1 time
Been thanked: 26 times
Contact:

Re: Incrementing in EEPROM

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Incrementing in EEPROM

Post 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.
Attachments
data logging.fcf
(20.37 KiB) Downloaded 297 times

nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Re: Incrementing in EEPROM

Post 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

nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Re: Incrementing in EEPROM

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Incrementing in EEPROM

Post 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.

nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Re: Incrementing in EEPROM

Post 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.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Incrementing in EEPROM

Post 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.

nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Re: Incrementing in EEPROM

Post 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

nmindana
Posts: 82
Joined: Thu Nov 18, 2010 5:00 pm
Has thanked: 52 times
Been thanked: 5 times
Contact:

Re: Incrementing in EEPROM

Post 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
Attachments
data logging can manipulate.fcf
(30.95 KiB) Downloaded 200 times

Post Reply