Import variable values from txt file

Is it possible to import values from a text file, that get written to corresponding GDS variables? So that when i want to update a remote PLC, i can tell the client to copy a text file to the plc?
EG a file with :
{
„kp“: 0.80,
„ki“: 0.02,
„kd“: 0.12
}
That will fill the GDS ports kp, ki and kd with the values from the text file

Hello Tim,
Yes, it’s possible to read values from a text file (like JSON) and map them to GDS variables, but it requires some setup.
If you’re aiming for a solution where the client simply copies a file to the PLC and the values are automatically updated, you can:

  1. Use the JSON_Library from the PLCnext Store to parse the file.
  2. Create a function block that reads the file (e.g. from /opt/plcnext/user/) and extracts the values.
  3. Map the parsed values to GDS variables via in/out ports in your program.

This way, the client only needs to update the JSON file, and your PLC logic handles the rest. You can also use the file operations from the PLCnext Base library if you prefer working with plain text or CSV formats. Or just basic included file operations in the PLCnext engineer.
I’m happy to help where I can here on the forum, but for more detailed support or implementation help, it’s best to contact Phoenix Contact NL directly.

Hi Tim,
it is even besser to let the PLC request these settings from a server. In this way you can manage the settings in a center data space.