Hi,
I am looking for a way to store vital variable values in AXCx152 PLCs.
These are typical hour counters or kWh-counters and so forth. They are accumulated during the life of the product, and should in no circumstances be lost or corrupted.
Below are a few options I have considered, with their pros and cons:
Retain memory. Pros : One checkbox-implementation. Cons : I do not trust retain memory in PLCnext Technology devices. Too easily wiped with no warning, and will sometimes be corrupted (e.g. random values) when downloading new program. (Retain would be the most obvious choice in other PLCs, but due to the „less than ideal“ retain handling in PLCnext, this is not a solution I can trust. Refer to my rant in this thread: https://www.plcnext-community.net/forum/#/discussion/3633
1. )
2. Database. Pros : Easily configurable in PLCnext engineer with no coding. Cons : somewhat overkill for simply storing values which are not timeseries or events. I have simple values which change over time, but I am only interested in the latest value - not the hour counter value of yesterday. Also, the database is not easily accessible by the PLC program, and operators would have to extract the sqlite db file and interpret it in a database browser to get values from it.
3. File writing. Pros : More reliable than the retain handling. Cons : File writing is messy. Would have to write at set intervals, and read the file upon reboot. Must create backup files and a method to delete older files etc.
* Are there other methods which are reliable for storing values?
My current method is a mix of 1 and 3:
Store value in volatile memory
* Each hour, copy value to retain memory
* Each midnight, store value to new file
* Each day, delete files older than 5 days (which means I have 4 backup files at any given time)
* Upon reboot, load the largest and newest backup file and compare values with retain memory to check for data loss.
* If data loss is detected (i.e. an hour counter suddenly has a lower value), import values from file and put them into retain memory. Also create an alarm for the operator as this may have created some data loss as file backups are only done daily.
This is 400 lines of code and I hate it.