Page 1 of 1

eeprom

Posted: Wed Jun 10, 2020 6:13 pm
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!

Re: eeprom

Posted: Wed Jun 10, 2020 7:29 pm
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

Re: eeprom

Posted: Sat Jun 13, 2020 12:00 pm
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.

Re: eeprom

Posted: Sat Jun 13, 2020 5:14 pm
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.

Re: eeprom

Posted: Sat Jun 13, 2020 5:38 pm
by samtin
Hi Martin,
I understand better now. Thank you very much Martin. I attach a flowchart, if you want to look a little.

Re: eeprom

Posted: Sat Jun 13, 2020 6:12 pm
by samtin
Hello everybody,
It works very well, thanks to Martin alias "medelec35", thanks to Martin alias "mnf". :D :D :D :D :D

Re: eeprom

Posted: Sat Jun 13, 2020 6:47 pm
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 5253 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.

Re: eeprom

Posted: Mon Jun 15, 2020 5:59 pm
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!