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);
  1. In the device tree, select the application and add a new visualization by clicking Project ‣ Add object ‣ Visualization.

    The respective visualization editor opens.

  2. Add the Visualization object to the device tree below Application.

    An empty visualization appears.

  3. Open ToolBox ‣ Special control elements.

  4. Drag the Trace element to the visualization.

    The element properties are displayed on the right side.

  5. Click bfac90e59e98e904c0a8640e01d4e839_918bd000717d8157c0a8640e00a25eb5 in the Trace property.

    The Trace configuration dialog box opens.

  6. 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).

  7. Select the MainTask in Task. The trace recording should by in the task where the PLC_PRG program is also located.

  8. Select the Insert elements for controlling trace command in the context menu.

    The Trace wizard dialog box opens.

  9. 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.

  10. 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.

../_images/357e1e7f9eaffd99c0a8640e01793784

Now you can use the elements for trace control for controlling the recording.

See also