Databeredning i Goteborg
How can I store variables in flash/eeprom memory so they retain the value during power off?

For example I want to use the analog input and compare it to a set value, this set value can be changed via modbus on the HMI but should be retained during power off.

I tried specifying the location as %MW0.0, this is accepted by the PLC simulator but not the compiler for the Controllino target.

Similar would be to store timer values, it works fine to hard code these as variables, but how do I set these to be saved in flash/eeprom? Also so I can change timing in the PLC from the HMI/Modbus.

Hardware is a Controllina Maxi with RS485 RTU to an HMI screen.
Reply 0 0
thiagoralves
You can’t use eeprom with OpenPLC yet 
Reply 0 0
Databeredning i Goteborg
Ok.

So on power on does the variables use the default value set in the editor?
Reply 0 0
thiagoralves
Yes
Reply 0 0
Databeredning i Goteborg
Ok, I can work around it for this test with the HMI writing the settings on a cyclic basis and storing them in the HMI memory.

Some time ago I did some work on designing a i2c memory that has a "battery backup" or uses an sram chip, for this type of use.
It would behave just as a normal i2c memory chip, but will retain its values on power off and have no write count limitations.
Maybe this would be something you would be interested in supporting for Arduino based hardware?
Reply 0 0
thiagoralves
It would be a lot easier to just support the built in EEPROM. It is just a matter of finding some free time to write the code.
Reply 0 0
Sangito
It could be more easy to give some hint to how to do it by our self.
You know for the sake of the communauty enrichissing...
Like what you did here:
https://openplc.discussion.community/post/canaduino-support-12555930?pid=1334445966
Reply 0 0
thiagoralves
@Sangito that’s a great idea, so I just took the time to write a new documentation article about how to do exactly that:  https://openplcproject.com/docs/3-3-adding-new-blocks-to-openplc-editors-library/

It is not a simple task, but everything is well explained in details
Reply 1 0
Reply