eeprom

Moderator: Benj

Post Reply
samtin
Posts: 10
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

eeprom

Post by samtin »

Hello everybody,
I have a counter to count the number of turns. For this I need to memorize the number of turns and exceed the number 255. How can I memorize the number 300 or 1000?
Thank you in advance!

mnf
Valued Contributor
Valued Contributor
Posts: 1188
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: eeprom

Post by mnf »

Hi Samtim,

You just need to save a 16 bit number - so first byte as

Code: Select all

Value/256
(or Value >> 8 )and second byte as

Code: Select all

Value % 256
(Note for the second byte you can just use

Code: Select all

Value
as it will be 'truncated' to 8 bits or

Code: Select all

Value & 0xff
both of which are quicker than the modulus calculation..

Martin

samtin
Posts: 10
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: eeprom

Post by samtin »

Hello everybody,
A flowchart with an example would help me. I tried something, but I don't know if it's okay. Thanks Martin for the answer. Attach a flowchart.
Attachments
16 bit.fcf
(9.5 KiB) Downloaded 174 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: eeprom

Post by medelec35 »

Hi samtin,
Following this post
Attached is how I would achieve what you are after.

Note:
As EEPROM has 1,000,000 erase/write cycles, it best to write to it as infrequent as possible.
Attachments
16 bit v2.fcf
(13.5 KiB) Downloaded 177 times
Martin

samtin
Posts: 10
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: eeprom

Post by samtin »

Hi Martin,
I understand better now. Thank you very much Martin. I attach a flowchart, if you want to look a little.
Attachments
16 bit v3.fcf
(10 KiB) Downloaded 181 times

samtin
Posts: 10
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: eeprom

Post by samtin »

Hello everybody,
It works very well, thanks to Martin alias "medelec35", thanks to Martin alias "mnf". :D :D :D :D :D

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: eeprom

Post by medelec35 »

Hi samtin,
Your welcome.
Glad us martin's has helped.

Calculation box can be deleted.
I was going to use it but changed my mind.
Was in a rush for dinner so deleting it slipped my mind.
The Calculation box with

Code: Select all

value = 1234
can also be deleted as was for testing only.
Although I would strongly recommend either use the calculation box to assign an initial value.
Alternatively, delete the

Code: Select all

value = 1234
as suggested.
Edit value variable, then assign an initial value:
Edit_Variable_Name.png
Edit_Variable_Name.png (57.72 KiB) Viewed 4515 times
Reason for this is in Flowcode simulator, variables start of with an initial value of 0.
On your hardware, it will be some random value.
General rule of thumb:
If a variable is read first then it must have an initial value assigned.
If a variable is wrote first then an initial value is not required.
Martin

samtin
Posts: 10
Joined: Fri Jun 24, 2016 8:14 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: eeprom

Post by samtin »

Hi Mr. Martin,
Thank you very much, Mr. Martin. Any answer from you on the forum is for me a lesson and a book page for what Flowcode means.

All the best!

Post Reply