TwinCAT 3 procedure

From TwinCAT 3.1 build 4012 and using the revision as below specified in the configuration, the integrated ScopeView recognizes in its variable browser that the oversampling data is an array package and activates ForceOversampling automatically. The array as a whole must be selected using AddSymbol (see description in the next section).The extended PDO name provides the basis for this. Since a specific revision of the respective terminal ScopeView is able to detect the array type of a set of variables autonomous.

Terminal

Revision

EL4732

all

EL4712

all

EL3783

EL3783-0000-0017

EL3773

EL3773-0000-0019

EL3751

all

EL3742

all

EL3702

all

EL3632

all

EL2262

all

EL1262-0050

all

EL1262

all

EP3632-0001

all

EPP3632-0001

all

Recording a PLC Variable with the TwinCAT 3 – ScopeView

By a precondition of an already created TwinCAT 3 – project and a connected PLC with an oversampling able terminal/box within the configuration it will be illustrated how an oversampling variable can be represented by the Scope (as a standard part of the TwinCAT 3 environment). This will be explained by means of several steps based on an example project “SCOPE_with_Oversampling“ as a standard PLC project.

Step 1: Adding a project „Scope YT“

The example project “SCOPE_with_Oversampling“ has to be added a TwinCAT Measurement – project “Scope YT project” (C) by right click (A) and selection (B) “Add” → “New Project..”. Then “Scope for OS” will be entered as name. The new project just appears within the solution explorer (D).

TwinCAT 3 procedure 1:
Adding a Scope project into an already existing project

Step 2a: Creation of a PLC variable within a POU

Within the TwinCAT 3 development environment an input variable as an array with respective amount than is given by the oversampling factor have to be defined at first how it’s illustrated in an example for the POU “MAIN” and an oversampling factor 10 with structured text (ST) as follows:

PROGRAM MAIN
VAR
   aU1_Samples AT%I* : ARRAY[0..9] OF INT;
END_VAR

The identification “AT%I*” stands for swapping out this array variable to link it with the process data objects (PDOs) of a terminal/box later. Notice that at least the number of elements has to be the same as the oversampling factor so that the indices can be set from 0 to 9 also. As soon as the compiling procedure was started and ended successful (in doing so no program code may be present) the array appears into the solution explorer of the TwinCAT 3 development environment within the section PLC under “..Instance”.

The following illustration shows extracts of the solution explorer on the right. As an example that linking of an array variable to a set of oversampling process data is represented herewith:

TwinCAT 3 procedure 2:
Representation of a created PLC array variable („aUI_Samples“) to link with oversampling PDOs of EL3773

Step 2b: Creation of a PLC variable via a free task

When a POU is not needed onto the particular system, a referenced variable could be applied via a free task also. If a free task is not existing still yet, it can be created by a right-click to “Task” of the project within SYSTEM with “Add New Item…”.

TwinCAT 3 procedure 3:
Insertion of a free task

The Task has to be inserted as “TwinCAT Task With Image” and also creates an “Inputs” and “Outputs” folder therefore. The properties of the new (or as the case may be already existing) task must have activated the attribute “Create symbols” to make them selectable by the “Target Browser” of the Scope later on. The task cycle time has to be changed if so. Then, with10 x Oversampling 1 ms at 100 µs base time, resulting 10 ticks will be set by the usage of the EL3751 for example:

TwinCAT 3 procedure 4:
Task property "Create symbols" must be activated

There’s a default value given for the Port number (301) that should be changed, if necessary. This number has to make acquainted for the Scope, if applicable, later on. By a right click on “Inputs” that oversampling based variable can now be appended with the fitting datatype of an array. „ARRAY [0..9] OF DINT“ referred to as „Var 1“ in this case:

TwinCAT 3 procedure 5:
Insertion of variable "Var 1" fitting to the oversampling (-factor)

Step 3: Linking an array variable with an oversampling PDO

By right click on “MAIN.aUI_Samples” (according to the last preceding paragraph Step 2a) or rather “Var 1” (according to the last preceding paragraph Step 2b) within the Solution Explorer a window opens to select the process data:

TwinCAT 3 procedure 6:
Set up the link of the PLC array variable (left: for the last preceding paragraph Step 2a, right: for the last preceding paragraph Step 2b)
TwinCAT 3 procedure 7:
Select the EL3773 PDO "L1 Voltage Samples" to create a link to the PLC array variable „aUI_Samples“

The selection of PDO "U1 Samples" of the EL3773 for “MAIN.aUI_Samples” based by the last preceding paragraph Step 2a as illustrated above have to be done in the same way for “Var 1” accordingly.

Step 4: Selection of the PLC array variable for the Y-axis of the scope

Now the configuration will be activated (TwinCAT 3 procedure 8:) and logged in the PLC (TwinCAT 3 procedure 9:), so the array variable will be visible for the target browser of the scope for being selected.

Thereby the drop down menu will be opened by right clicking on “Axis” (A) for selection of the scope features (B):

TwinCAT 3 procedure 10:
Selection of the oversampling variable with the target browser

By addressing the corresponding system that represents the PLC containing the array variable (“Any PC (CX2040)” in this case) navigation up to the variable “aUI_Samples“ (C) have to be done.

TwinCAT 3 procedure 11:
Appending the variable "aUI_Samples“ below “axis” within the scope project of the solution explorer
TwinCAT 3 procedure 12:

Variable don’t appears into the target browser

If „ROUTES“ don’t offer a possibility for selection of the provided variables, the corresponding port should be declared for the target browser:
TwinCAT 3 procedure 13:

Using “Add symbol” displays the variable "aUI_Samples“ below “axis” within the scope project of the solution explorer directly.

TwinCAT 3 procedure 14:

Now the program start has to be done with TwinCAT 3 procedure 15: formally although there’s no program still yet. Using “Start Recording“ TwinCAT 3 procedure 16: the process data value of the oversampling PDO “L1 Voltage Samples “ via the linked PLC array variable can be recorded time dependent now.

As an example a sine wave input measurement value (204.5 Hz) will be illustrated below:

TwinCAT 3 procedure 17:
Example of recording a sine signal with 10 x oversampling at 1 ms measurement cycle time

The X-axis view was fitted properly by using “Panning X” TwinCAT 3 procedure 18: after the recording was stoppedTwinCAT 3 procedure 19:. Following the “Chart” property “Use X-Axis SubGrid” was set to true with 10 divisions as well as the “ChannelNodeProperties” attribute “Marks” was set to “On” with the colors “Line Color” blue and “Mark Color” red. Therefore the latter indicates that 10 oversampling measurement points by the red marks.

Proceeding with / via ADS alternatively

In former TwinCAT 3 versions (or a lower revision as specified in the table above) the oversampling PDO of the respective oversampling able terminal/box can be made visible for the ScopeView by activation of the ADS server.

TwinCAT 3 procedure 20:
Activation of the ADS server of the EtherCAT device (TwinCAT 3)

The activation of the server can be carried out by selection of “Image” within the left sided solution explorer:
„I/O → Devices → Device .. (EtherCAT) → Image“.

Next the register card “ADS” have to be selected to activate each checkbox „Enable ADS Server“ and „Create symbols“ then (the port entry is done automatically).

Thereby it is possible to access process data without an embedded POU and accordingly without a linked variable:

TwinCAT 3 procedure 21:
Direct access to PDOs of the terminal by ScopeView
TwinCAT 3 procedure 22:

Data type not valid

It may happen that the target browser is unable to determine the data type after insertion of the oversampling PDO (according to an array variable usually). In this case it can be changed by the channel properties:
TwinCAT 3 procedure 23:

TwinCAT 3 procedure 24:

TwinCAT 3: Activate the ADS Server of an EtherCAT device

Also see Beckhoff Information System:
TwinCAT 3 procedure 25: