Page 1 of 1

Store & Retrieve ULong using EEPROM.fcfx

Posted: Thu Jul 24, 2014 10:31 am
by medelec35
I have attached a V6 flowchart for anyone who would like to store and retrieve a ULong number (0 to 4294967295) using EEPROM

The attached Flowchart stores the number 1234567890 from the cycles variable by breaking it down into for sets of bytes.
The bytes are then stored within EEPROM.
Finally the four bytes are retreived from EEPROM then assigned back to cycles variable = 1234567890.

Martin

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Tue Aug 05, 2014 5:11 pm
by medelec35
Corrected an issue.
Store and Retrieve ULong within EEPROM V2.fcfx
Should now work within Flowcode simulator and on hardware.

Martin

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Wed Dec 16, 2015 5:45 am
by electron67
Hello Martin,
excuse my ignorance,You can help me understand how to record the ULONG numbers in the EEPROM, as I understand you recorded in the EEPROM 1, 2, 3 and 4 numbers 73, 150, 2 and 210 but if you want to record, for example 25684, 698564 , 85247, and 985746 could show me how? :?:

Thanks
Enrique

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Wed Dec 16, 2015 6:57 pm
by medelec35
Hi Enrique,
You can only store bytes (0 to 255) in EEPROM with 8bit microcontrollers.
The number I was actually storing is 1234567890 which is assigned to Cycles variable.
Numbers 73, 150, 2 and 210 is the 1234567890 broken down into bytes to store within EEPROM.

If you want to store numbers from -32768 to 32767 then you only need two bytes instead of four bytes used with Ulong.

In your case the 5684, 698564 , 85247, and 985746 just replaces the 1234567890 within the flwochart I had posted.
Since they are within int range, just remove references to TotCycle3 & TotCycle4.

Martin

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Wed Dec 16, 2015 7:13 pm
by electron67
Hi Martin,
I take one day to know that you were saving was number 1234567890, I thought it was part of the formula to save EEPROM, thanks anyway, the forum is an excellent way to learn. :oops:

Enrique

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Wed Dec 16, 2015 7:28 pm
by medelec35
Hi Enrique,
Glad you are learning from what we post!

Thanks for your feedback.
I have now edited my first post in the hope of making it all clearer.

Martin

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Wed Dec 16, 2015 11:00 pm
by electron67
Thank you Martin and Benj the whole team of matrix, including all users wish you have a happy Christmas and a good year 2016


HAPPY HOLIDAYS !
Enrique

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Fri Nov 17, 2017 7:21 pm
by rudolfsteiner
Hi Martin,
I had the curiosity to put the ULong number on a display and it works nicely, but 4294967295 does not display it, the display shows -1, I can not handle it, I do not know what to do.
Thank you in advance!

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Fri Nov 17, 2017 10:18 pm
by medelec35
Hi Rudolf,
I can't see all of your flowchart so will be difficult to say exactly.
I believe the issue is with Flowcode V5 & V6 the LCD can only display signed numbers.
I requested LCD in V7 to be able to display unsigned numbers like UInt & ULong.
So it was implemented

Martin

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Sat Nov 18, 2017 12:32 am
by electron67
Hi

And you need to use the highest value number in Ulong :?:

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Sat Nov 18, 2017 10:44 am
by rudolfsteiner
Hi Martin,
Thanks a lot for the answer, I attach a flowchart, maybe you will notice where I'm wrong.

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Sat Nov 18, 2017 12:02 pm
by rudolfsteiner
Hi Enrique,
And you need to use the highest value number in Ulong :?:
I do not need, I just noticed a possible bug in Flowcode.

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Sat Mar 07, 2020 3:38 pm
by AbhijitR
Hello! Martin
medelec35 wrote: I have now edited my first post in the hope of making it all clearer.
Martin
My doubt is regarding the Store & Retrieve of INT to EEPROM, I can do it well using one of your posts/example from V5, my doubt is little different today, I hope you will help me to solve that

Case 1
If the INT value is 2570 then the breakup of this value to store in the EEPROM is 10 and 10 and
Case 2
If the INT value is 257 then the breakup of this value to store in the EEPROM is 1 and 1

I hope I have put my doubt correctly, my problem is in case 2, is it not possible to retrieve the number as 0257 the '0' is very important for me in this case.

I am converting the entire digit (2570) in case 1 to string and then comparing the same with the present value, it works as the present value is a f digit number, but if I convert the digit (257) like in case 2 then the comparison goes wrong as the first digit '0' is missing.

May be you have some other trick.

Thank you,

Regards
Abhi

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Sat Mar 07, 2020 3:56 pm
by kersing
The obvious question would be why are you comparing strings and not numbers?

If you need to compare strings you could compare the number to see if it is < 10, add three zeros in front if the string, check < 100, add two zeros and compare < 1000 and add one zero.

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Sat Mar 07, 2020 4:58 pm
by AbhijitR
Hello! Kersing

Many thanks for the suggestion, actually the requirement for comparing the strings come from the below post from Ben

viewtopic.php?f=54&t=15948

In this example the saved password is as string of 4 digit number and then it is compared with the entered 4 digit number, on the keyboard, unfortunately I do not have a keyboard in my project but want the have a password to enter the programming mode using 3 keys (UP, DOWN and ENTER), what Ben suggested works well until the password to compare is mentioned in the calculation box as 4 digit number, I want to save the 4 digits password in EEPROM so can be changed when required.

Now when I try to retrieve the password as which is a 3 digit number then the comparison goes wrong.

What you suggested of adding a zero before the 3 digits is nice, but I do not find any post which can help me to add the zero before the number which is in NUMBER (INT) format or STRING format.

Can you help me in that.

Thank you.

Regards
Abhi

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Sat Mar 07, 2020 5:06 pm
by kersing
To modify strings you can use the string manipulations available. One of them being concatenation.

The result would be something like:

Code: Select all

newString = "000" + smallString
Where smallString would be the one you previously created from the number stored in eeprom.

Re: Store & Retrieve ULong using EEPROM.fcfx

Posted: Mon Mar 09, 2020 9:26 am
by AbhijitR
Hello! Kersing
good morning

First of all many many many thanks for that valuable input, it helped me a lot as well taught me a new lesson about String Manipulation, finally my access system/password entry using an OLED Display and 3 keys (UP, DOWN and ENTER) is working successfully, now I can change the password and also store the new one in the EEPROM.

Thanks to Ben and Martin too.

Regards
Abhi