Skip to main content

Strange behavior in the IEC application

Requirements

You are using a CODESYS runtime.

Troubleshooting

If you observe strange behavior, then you should check whether the runtime logger provides valuable hints or information. The CODESYS runtime logger has a mechanism for filtering messages by category. The Debug category is not enabled by default. Enable this category to find the cause of strange behavior or unexpected symptoms.

There are global and component-specific log filters. You can see a detailed list of all possible component-specific filters in the log file of the runtime. Use the filters as described below.

Symptoms related to

Possible component-based log filter

Licensing

CmpCodeMeter

IEC tasks / timing (higher level)

CmpIecTask

IEC tasks / timing (low level)

CmpSchedule, SysTask

IEC application (general)

CmpApp, CmpIecTask

IEC application (memory)

SysMem

Socket communication

SysSocket

Ethernet communication

SysEthernet

Files / folders

SysFile, SysDir

Tip

Do not enable all debug categories at the same time because that would make it difficult to find the actual problem. Proceed step by step and disable "irrelevant" filters to get a better view of the problem.

. Enable the Debug message category via the PLC shell (for runtime versions >= SP20).
  1. Open your CODESYS project and connect it to the controller.

  2. Open the PLC shell by double-clicking the controller in the device tree.

    _rtsl_img_plc_shell.png
  3. Enter "?" in the shell in order to see all possible commands.

  4. Use the logsetfilter, loggetfilter, and logdelfiltercommands to write, read, and delete a filter. You can either use global debug filters for the entire runtime or filters for a specific component.

    • To read the current log category globally:

      loggetfilter could return the following output: Logger.0.Filter : 0x0000000F

    • To set the current log category globally:

      logsetfilter 0xffffffff

    • To read the current log category for a specific component (for example, CmpCodeMeter):

      loggetfilter CmpCodeMeter

    • To set the current log category for a specific component (for example, CmpCodeMeter):

      logsetfilter CmpCodeMeter 0xffffffff

. Enabling the logger category via the runtime configuration file (for older runtime versions)

Example: Via an SSH connection and a text editor

  1. Stop the runtime via the Deploy Tool.

  2. Connect to your target system (for example, via putty or another SSH client).

  3. Open the user-specific configuration file of the runtime environment with a text editor (for example, nano):

    sudo nano /etc/codesyscontrol/CODESYSControl_User.cfg

  4. Find the CmpLog section and set the filter.

    Example 1. Setting a global filter

    Example: Logger.0.Filter=0xFFFFFFFFFF to enable all debug messages

    _rtsl_img_plc_shell_global.png


    Example 2. Setting a component-specific filter
    [CmpLog]
    CmpCodeMeter.Filter=0xFFFFFFFF
    SysTask.Filter=0xFFFFFFFF


  5. Save and close the file.

  6. Restart the runtime with the Deploy Tool.