Getting Started with Trace¶
Create a project with the following program.
PLC_PRG
PROGRAM PLC_PRG
VAR
\ iVar : INT;
\ rSin : REAL;
\ rVar : REAL;
END_VAR
iVar := iVar + 1;
iVar := iVar MOD 33;
rVar := rVar + 0.1;
rSin := 30 * SIN(rVar);
In the device tree, select the application and add a new visualization by clicking
.- ⇒
The respective visualization editor opens.
Add the Visualization object to the device tree below Application.
- ⇒
An empty visualization appears.
Open
.Drag the Trace element to the visualization.
- ⇒
The element properties are displayed on the right side.
Click
in the Trace property.
- ⇒
The Trace configuration dialog box opens.
Click Add variable to add an entry to the tree view of the trace configuration and assign an IEC variable (for example,
PLC_PRG.rSin
).Select the
MainTask
in Task. The trace recording should by in the task where thePLC_PRG
program is also located.Select the Insert elements for controlling trace command in the context menu.
- ⇒
The Trace wizard dialog box opens.
By default, all three control elements are activated in the dialog. Click OK to close the dialog box.
- ⇒
The control elements are added to the visualization.
Load the application to the controller and start it.
Example
Record the sine-shaped data of the IEC variable PLC_PRG.rSin
The PLC_PRG
program is running on the PLC. When you follow the instructions for “Getting Started”, CODESYS displays the following trace diagram.
Now you can use the elements for trace control for controlling the recording.
See also