Is there a way to manually write ascii to a file?

Is there a way to manually write ascii to a file?
none 0.0 0
  • HMI Model: ANy
  • EasyBuilder Pro Version:Latest

Either via CODESYS , or HMI
To a file on a USB stick

Hi @david,

What file type are you trying to write to? Will the HMI need to append data, create a new file, or both?

The file will be created and appended to with strings created as needed

Hi @david,

It should be possible to write ASCII data to a file and then copy this file to a USB using the SysFile and SysDir libraries within Codesys. Here is a link to a Codesys demo project that will write a single string to a file within the PLC and transfer it to a USB: Link. Additional information can be found within the “CODESYS Library SysFile SysDir Demo” that can be obtained via the demo projects link: Link.

What is the correct format to Address the USB
I tried Creating a directory with

worked created on the local HMI

but ‘USB:/David’ return 1 - failure
but ‘USB:/David/’ return 1 - failure

the code implied that this should work


The “SysDirCreate” function block is not used to create a directory in a USB drive. It will create a directory to the Codesys’ own memory location (called “SysFile”). Therefore, do not address the USB when using this function block.

You have to use the “SysFileCopy” function block to set the USB syntax, such as “USB:/PlcLogic/User/Data.txt”