I am using controller SNAP PAC R1, I am wondering if I can store a value to flash memory.
The system need to continuous record a flow and calculate the total for months, so I need to store and extract the accumulated flow value to somewhere in case a power failure.
How should I program it? Use Datalink to store and store and retrieve data logging PC? Or I can store in the controller flash memory?
The command you seek is āSave Files To Permanent Storageā.
So save your value to the file area with a comm handle, then every few hours, issue that command to save that file to flash.
I was thinking about this. Then I look into the āHelpā content. It said this action:
āAll files in the root directory of the file system are saved to its flash memory, replacing files currently in flash memory. (Firmware files, strategy files, and point configuration data are not affected.)ā
It did not mention to save a specific data into the storage or flash memory.
No. This command will NOT save the entire project like a snapshot. It will just save the files in the root directory of the controller. To do that you need to stop all the charts from running and use PAC Manager.
Here is some pseudo code that should get you started;
// Get the date and time for the report
DateToStringMMDDYYYY(ReportDate);
TimeToString(ReportTime);
// Create the report contents
ReportData = "Report Generated on " + ReportDate + " at " + ReportTime;
// Open the file to append the new data
Report_Status = OpenOutgoingCommunication(ch_Report_File);
// Send the report
TransmitString(ReportData, ch_Report_File);
// Send a carriage return after each line
TransmitChar(10, ch_Report_File);
And the comm handle āch_Report_Fileā looks something like this;
How many values do you need to store? Could you use persistent variables? These are stored in battery backed RAM so donāt lose their values when the power is lost.
You can also use the historical logging or super trend feature of PAC Display if you have a computer running at all times.
Like 10 to 20 of them. It is a Year To Date calculated flow, so I do not think persistent variables work this way. I would like to back up the calculated value every few mins, but persistent variables changes only when engineer modifies it.
They work just like any other variable. Only difference is they remember their value after a power cycle. If you already have the variable for your flow total, just change it to persistent.
I totally agree with @philip Now that we have a better grip on what you are looking to do, it sounds perfect for persistent variable use.
(Donāt forget to use OptoTagPerserve when you do your firmware updates and you should maintain that data for many years seamlessly).
Also keep in mind that you will lose your persistent variable values if you change the name of the strategy. For instance, changing the strategy filename by adding a revision letter or number. But like Ben mentioned, if you have a download from OptoTagPreserve you will be fine. It does not care about the strategy name.