Back to top

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:

image

The variables must be defined in the project Dictionary, Global section:

image

 

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).

image

   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".

image

    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:

image

  and

image

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
 

image

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.

image

  • 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

 image    

 

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.

https://kdn.kollmorgen.com/webhelp/kas/#11.TechRefs/SD_Card_System_Conventions.htm?Highlight=SD

 

Comments

ABA's picture
ABA
HELLO CARROLL W,

I HAVE A LITTLE COMPLEX  STRUCTURE .....   AS YOU CAN SEE AT IMAGE,   AND . KAS FILE,  SO HOW CAN I WRITE TO INTERNAL FLASH IT STRUCTURE, AND THEN HOW CAN READ????,   

THE ACTUAL PROBLEM THAT I HAVE ITS MEMORY,

SO I WANT TO WRITE 10 MODELS TO FLASH MEMORY AND THEN SELECT A MODEL NUMBER  FOR RETRIEVE AND HAVE  AVAILABLE THEIR VARIABLES VALUES  TO MAKE THE PROCESS,   

APPLICATION IS PICK AND PLACE ROBOT FOR  INJECTION MOLDING MACHINE 

   


STR_IMM.kas 

image

 
cwontrop's picture
cwontrop

Saving as RETAIN variables can be an option if you can stay within the maximum size limits:
https://www.kollmorgen.com/en-us/developer-network/loading-and-saving-application-parameters-recipes-nvram-memory/

http://curvegen.kollmorgen.com/webhelp/kas/Content/12.KASComponents/NVRAM.htm

Here is a program that works with saving and retrieving from an SD card which has a similar process as the the Flash memory

https://www.kollmorgen.com/en-us/developer-network/cam-profile-creation-sd-card/

Similar to this program, pointers or indexers (example: iArrayIndex) would be needed to load and retrieve a specific recipe The file management functions including SEEK would be useful.

http://curvegen.kollmorgen.com/webhelp/kas/Content/11.TechRefs/FileMgt_Functions.htm?Highlight=seek. 











 
Eric Hoffstetter's picture
Eric Hoffstetter
Is this the correct method to use if I want to log values very quickly for a short period of time?

For example, on my PCMM, I want to log the position (angle) of 3 axes (one virtual axes, one motor, and one external encoder) and maybe a timestamp. I'd like to record as fast as possible, maybe 100 readings/sec, for about 3 seconds.
And how should I trigger the logging (ei drive the log input of LogFileCSV)?