Data Recording with Trace

A Trace makes it possible to record the value history of variables on the PLC — just like 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 have the option of triggering 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.

There are two types of trace objects. If the trace object is in the device tree directly below a device, then it is a device trace. With a device trace, you can display all traces that are running on the PLC. The associated application does not have to be correct or capable to run on the PLC.

CODESYS provides two mechanisms for recording data:

  • Trace manager: the functionality of the CmpTraceMgrruntime system component
  • IEC code During the compile process, CODESYS generates code that enables data recording. This mechanism is repeated. This mechanism is used only in the rare case that the runtime system does not have access to the CmpTraceMgr component.

An entry in the device description specifies which mechanism is used in the application on the PLC.

Attention

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

Attention

Data recording with trace also continues running after logging out of the device.

Runtime system component CmpTraceMgr

The device description for a runtime system with trace manager includes the tracemanager entry in the TargetSettings section.

Example

Device description

<ts:section xmlns:ts="http://www.3s-software.com/schemas/TargetSettings-0.1.xsd" name="trace">
\ <ts:setting name="tracemanager" type="boolean" access="visible">
\ \ <!-- With this option, the new tracemanager is activated in CODESYS.
\ \ \ \ \ \ \ With this option, the CmpTraceMgr component is needed in the runtime system! -->
\ \ \ <ts:value>1</ts:value>
\ </ts:setting>
</ts:section>

CODESYS transfers only the trace configuration when downloading the application to the controller. When you start the trace, the application interprets the configuration, executes the data recording, and buffers the data sets on the controller.

The CmpTraceMgr runtime system component provides extended functionality, as opposed to data recording with IEC code.

Data recording is therefore possible as follows:

  • Parameters on the controller (for example, the temperature curve of a CPU or battery)
  • 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 box of the Variable Settings.

See also

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.

Possible file formats
File Extension File type Description
\*.trace: 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.
\*.txt Text File Contains the samples in ASCII format. You can edit the file with an external tool.
\*.trace.csv 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 \*.trace.csv file format. You can transfer the file to the controller and load it with an HMI for analysis.

.traceconfig Symbolic trace configuration Contains the trace configuration CSV format. You can create the file by clicking Export symbolic trace config. The CmpTraceMgr runtime system component can read the file.

See also

See also