You can use a “Trace” to follow the value history of variables on the controller in a similar way as a digital sampling oscilloscope. When the application is in runtime mode with trace, all statements are executed first within the task cycle. Then, data recording starts with value storage including time stamps. These time stamps are relative and refer to the start time of the data recording. The data yields a discrete time signal and CODESYS displays its course in the trace editor.
A sample (data record) is composed of the value and the time stamp. The runtime system writes the samples to a buffer with a definable size. CODESYS requests the data, saves it in the trace editor buffer, and displays it in the trace diagram as a function of time. You can monitor the value history of the configured variables continually because CODESYS displays the latest data.
You can trigger the data recording. When this happens, the application saves the data from the time of the trigger and CODESYS displays the data at the time of the trigger.
The configuration and the display of a trace are possible in the CODESYS project by means of trace objects in the trace editor. There are the following two object types:
-
“Trace”: Inserted below the IEC application in the device tree. This kind of object always contains a purely application-specific trace configuration. You can download this trace configuration to the controller and run it with the application.
-
“DeviceTrace”: Inserted below the device object in the device tree. If the PLC supports a trace manager, then you can use one or more “DeviceTrace” objects to access one or more traces that are running on the controller. These can be both application-specific or controller-specific traces. For example, a controller can support traces for recording the processor load. Menu commands allow for access from the CODESYS project to the trace manager in the device.
Access to the trace manager from IEC code is possible by means of the functions from
the library CmpTraceMgr.library
. For more information, refer to the library documentation.




NOTICE

A running data recording with trace can lead to a significant increase in the cycle time of the IEC task.




NOTICE

Data recording with trace also continues running after logging out of the device.
Runtime system component CmpTraceMgr
, "Trace manager"
The device description of a runtime system with trace manager includes the tracemanager
entry in the TargetSettings
section.
In this case, CODESYS transfers only the trace configuration when downloading the application to the PLC. When you start the trace, the application interprets the configuration on the RTS by means of the trace manager, executes the data recording, and buffers the data sets on the PLC.
The CmpTraceMgr
runtime system component provides extended functionality, as compared to data recording
with IEC code.
Data recording is therefore possible as follows:
-
Parameters on the PLC (for example, the processor load (cpuload, plcload), or the temperature curve of a CPU or a battery). The measurement of the processor load per CPU core (cpuload) is interesting for multicore controllers.
-
Device signals (for example, the current path of a drive)
-
System variables of another runtime system component
You can configure parameters like IEC variables in the “Trace Configuration” dialog of the “Variable Settings”.
The display of traces that run on the controller is possible in the trace editor of a DeviceTrace object.
Data recording after triggering
To monitor data that depends on an event or a condition, you can free the data recording that depends on a trigger. At runtime, the application checks whether the event has occurred or the the condition is fulfilled, and then it buffers the data accordingly.
The trace configuration enables triggering by:
-
a trigger variable that maps the event
-
a condition as expression
-
a combination of trigger variable and condition
Saving samples to a file
You can save samples from the development system to a file. The file can also include the trace configuration.
File Extension |
File type |
Description |
---|---|---|
|
“Trace file” |
Contains the samples and the trace configuration in XML format. You can execute the “Load Trace” command to load the file to the trace editor when offline and analyze the samples without a controller. |
|
“Text File” |
Contains the samples in ASCII format. You can edit the file with an external tool. |
|
“Trace dump” |
File in CSV format includes the trace configuration and optional samples. You can create the file by clicking “Export Symbolic Trace Config”. You can transfer the file to the controller and load it to the application. Then you can execute the “Load Trace” command in CODESYS to display this in the trace editor. You can also click “Trace Save Trace” and select the |
|
“Symbolic trace configuration” |
Contains the trace configuration CSV format. You can create the file by clicking “Export Symbolic Trace Config”. The |