Store & Retrieve ULong using EEPROM.fcfx

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8609
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2477 times
Been thanked: 3559 times
Contact:

Store & Retrieve ULong using EEPROM.fcfx

Postby medelec35 » Thu Jul 24, 2014 10:31 am

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
Attachments
Store and Retrieve ULong within EEPROM V2.fcfx
(7.6 KiB) Downloaded 578 times
These users thanked the author medelec35 for the post (total 8):
Benj (Thu Jul 24, 2014 10:32 am) • jgu1 (Thu Jul 24, 2014 1:38 pm) • dazz (Thu Jul 24, 2014 2:56 pm) • Kenrix2 (Wed Aug 06, 2014 7:30 am) • Rudi (Thu Aug 28, 2014 11:29 pm) • ionize (Wed Oct 22, 2014 11:28 pm) • leoo (Tue Mar 28, 2017 8:43 am) • rudolfsteiner (Fri Nov 17, 2017 7:16 pm)
Rating: 40%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8609
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2477 times
Been thanked: 3559 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby medelec35 » Tue Aug 05, 2014 5:11 pm

Corrected an issue.
Store and Retrieve ULong within EEPROM V2.fcfx
Should now work within Flowcode simulator and on hardware.

Martin
These users thanked the author medelec35 for the post:
Benj (Tue Aug 05, 2014 5:19 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

electron67
Posts: 289
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 103 times
Been thanked: 45 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby electron67 » Wed Dec 16, 2015 5:45 am

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8609
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2477 times
Been thanked: 3559 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby medelec35 » Wed Dec 16, 2015 6:57 pm

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
These users thanked the author medelec35 for the post:
electron67 (Wed Dec 16, 2015 7:14 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

electron67
Posts: 289
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 103 times
Been thanked: 45 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby electron67 » Wed Dec 16, 2015 7:13 pm

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
These users thanked the author electron67 for the post:
medelec35 (Wed Dec 16, 2015 7:28 pm)
Rating: 5%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8609
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2477 times
Been thanked: 3559 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby medelec35 » Wed Dec 16, 2015 7:28 pm

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
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

electron67
Posts: 289
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 103 times
Been thanked: 45 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby electron67 » Wed Dec 16, 2015 11:00 pm

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
These users thanked the author electron67 for the post (total 2):
medelec35 (Wed Dec 16, 2015 11:06 pm) • Benj (Tue Dec 22, 2015 6:26 pm)
Rating: 10%
 

rudolfsteiner
Posts: 5
Joined: Fri Feb 06, 2015 5:54 pm
Has thanked: 1 time
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby rudolfsteiner » Fri Nov 17, 2017 7:21 pm

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!
Attachments
4294967295.png
4294967295.png (18.16 KiB) Viewed 5015 times
1234567890.png
1234567890.png (18.09 KiB) Viewed 5015 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8609
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2477 times
Been thanked: 3559 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby medelec35 » Fri Nov 17, 2017 10:18 pm

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
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

electron67
Posts: 289
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 103 times
Been thanked: 45 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby electron67 » Sat Nov 18, 2017 12:32 am

Hi

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

rudolfsteiner
Posts: 5
Joined: Fri Feb 06, 2015 5:54 pm
Has thanked: 1 time
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby rudolfsteiner » Sat Nov 18, 2017 10:44 am

Hi Martin,
Thanks a lot for the answer, I attach a flowchart, maybe you will notice where I'm wrong.
Attachments
Store and Retrieve ULong within EEPROM V3.fcf
(11 KiB) Downloaded 68 times

rudolfsteiner
Posts: 5
Joined: Fri Feb 06, 2015 5:54 pm
Has thanked: 1 time
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby rudolfsteiner » Sat Nov 18, 2017 12:02 pm

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.

User avatar
AbhijitR
Posts: 105
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 158 times
Been thanked: 33 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby AbhijitR » Sat Mar 07, 2020 3:38 pm

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

kersing
Valued Contributor
Valued Contributor
Posts: 1907
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 552 times
Been thanked: 1064 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby kersing » Sat Mar 07, 2020 3:56 pm

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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
AbhijitR
Posts: 105
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 158 times
Been thanked: 33 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby AbhijitR » Sat Mar 07, 2020 4:58 pm

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

kersing
Valued Contributor
Valued Contributor
Posts: 1907
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 552 times
Been thanked: 1064 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby kersing » Sat Mar 07, 2020 5:06 pm

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.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
AbhijitR
Posts: 105
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 158 times
Been thanked: 33 times
Contact:

Re: Store & Retrieve ULong using EEPROM.fcfx

Postby AbhijitR » Mon Mar 09, 2020 9:26 am

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