File Management

File Management functions provide the ability to do the following:

  • Read machine recipes or other machine operational data into the .kas program from the SD card or a remote drive
  • Read cam tables into the program from the SD card or a remote drive.
  • Store machine operational data in internal PxMM flash memory (retrievable through the web server), the SD card, or a remote drive
    Please note that a remote drive connection is setup through the web server.

    • If needed, functions to parse out information from a file using a string format can be found in String operations.
    • If the file is in .CSV format, the following functions can be used: LogFileCSV, ApplyRecipeColumn
    • You can create, store, and retrieve recipes and other data using:
      • the AKI Terminals. For more information see the KVB manual.
      • through an external bus connection to the PxMM with a supported fieldbus, such as UDP or HTTP.

The following functions enable sequential read / write operations in disk files:

Name Use
F_AOPEN Create or open a file in append mode
F_CLOSE Close an open file
F_COPY Copy a file
F_DELETE Remove a file
F_EOF Test if the end of the file is reached in a file that is open for reading
F_EXIST Test if a file exists
F_GETSIZE Get the size of a file
F_RENAME Rename a file
F_ROPEN Open a file for reading
F_SEEK Set the current position of a file
F_WOPEN Create or reset a file and open it for writing
FA_READ Read a DINT integer from a binary file
FA_WRITE Write a DINT integer to a binary file
FB_READ Read binary data from a file
FB_WRITE Write binary data to a file
FM_READ Read a string value from a text file
FM_WRITE Write a string value to a text file
SD_ISREADY Check that the SD card is ready for read/write
SD_MOUNT Mount an SD card
SD_UNMOUNT Unmount an SD card

Each file is identified in the application by a unique handle manipulated as a DINT value. The file handles are allocated by the target system. Handles are returned by the Open functions and used in all other calls for identifying the file.

Related function blocks:

LogFileCSV  log values of variables to a CSV file


    • These functions can have a serious impact on CPU load and the life expectancy of a flash drive. It is highly recommended that these be used on an event basis, and not at every PLC cycle.
    • Files are opened and closed directly by the Operating System of the target. Opening some files can be dangerous for system safety and integrity. The number of open files (from F_AOPEN, F_ROPEN, and F_WOPEN) is limited by the resources available on the target system.
    • Ensure that each file successfully opened using F_AOPEN, F_ROPEN, and F_WOPEN has a corresponding F_CLOSE to close the file. Closing the file will release the file ID, making it available for operations on other files.