Save Variable Values to the PCMM/PDMM's Internal Flash or SD card Memory
The attached sample .kas project contains a program (SaveVarsToFlash) that stores application variables into a .csv file located on the PCMM/PDMM's internal FLASH memory or removable SD card.
Steps to accomplish this wih FLASH memory are:
1. Create a text file (Example: ListOfVariablesToRead.txt) containing the names of the variables having their values stored. Store this file on the same PC containing the IDE. Example:
The variables must be defined in the project Dictionary, Global section:
2. Use the VLID function to bring the VLID created text file into the project. When the project is compiled, the compiler will read the VLID function in the program and get the variables in the file making them part of the compiled project (for download to the target).
More Information on VLID: https://kdn.kollmorgen.com/webhelp/kas/#Straton/VLID.htm?Highlight=VLID
3. Use the LogFileCSV function block to define a file name in FLASH to store the data, connect to the file defined in the VLID function, and execute a variable (to FLASH) save operation. In the example below the data is saved to a file named "MachineData".
Note: MyLog is an instance of the LogFileCSV function block
More Information on LogFileCSV: https://kdn.kollmorgen.com/webhelp/kas/#Straton/LogFileCSV.htm?Highlight=log
4. Use the F_AOPEN and F_CLOSE functions to open and close the FLASH memory file:
5. Each execution of the LogFileCSV function block will save the present values of the variables on a new line. Here is shown in the KAS WebServer the 4 variables (VAR1, VAR2, VAR3, and VAR4) saved 6 times
When project execution is stop and later restarted, subsequent saves can add lines of data to the file.
This operation can be demonstrated with the attached program and text file containing the names of the 4 variables (VAR1, VAR2, VAR3, and VAR4) to record data of. The project contains a Control Panel to execute this procedure.
- Use the "Load Var Names From File" button to execute the VLID function.
- Use "Save Data" button to save the present values of the 4 parameters.
- Use the 4 "Var x Value" fields to change the variable values (and then execute a "Save Data" to see a new line of different value stored)
The file in FLASH can then be viewed and retrieved from the web server
A similar procedure can be used to save data to the SD card. The SD cards file name will have a different path in the LogFileCSV function block.