Back to top

Save program variables to SD card memory

KAS supports storage of values from a running program into the SD card. Attached is an example project which sends 4 variable values: VAR1, VAR23, VAR3, and VAR4 to the SD card each time the Execute input is triggered. Code creation is as follows:

1. Create txt file will variables list and store on PC:

Untitled2.png

Write code to read list of variables in the file:

Untitled4.png

Write code to store variable values in SD card each time a input (Execute)  has a rising edge. Steps for this include:

1. Get the SD card ready for communications: SD_Mount

2. Opening the channel of communication: F_WOPEN

3. Use the LogFileCSV function block (MyLog)  to save variables in the SD card

4. Close the channel of communication: F_CLOSE

5. Make SD card ready to remove: SD_UNMOUNT

 

Untitled3.png

The following code was used to create new values of the 4 VARS every time there ia a rising on Execute.

Untitled5.png

The following shows 8 sets of data inside the .csv file stored in the SD card:

Untitled.png