TwinCAT PLC - e
TwinCAT PLC - e
TwinCAT PLC - e
Beckhoff TwinCAT
Total Windows Control and Automation Technology
TwinCAT PLC
Programming Manual
TwinCAT version: 2.6
Last change: 16.11.1998
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Contents 2
Contents
1. A Brief Introduction to TwinCAT PLC Control 4
What is TwinCAT PLC Control? 4
Overview of TwinCAT PLC Control 4
Functions 4
2. What is What in TwinCAT PLC Control 6
Project Components 6
Languages 12
Debugging, Online Functions 25
The Standard 26
3. We Write a Little Program 27
Controlling a Traffic Signal Unit 27
4. The Individual Components 38
The Main Window 38
Options 40
Managing Projects 48
Creating and Deleting Objects, etc. 60
General Editing Functions 67
General Online Functions 71
Window set up 76
Help when you need it 77
5. Editors in TwinCAT PLC Control 79
The Declaration Editor 79
The Text Editors 85
The Instruction List Editor 89
The Editor for Structured Text 89
The Graphic Editors 90
The Function Block Diagram Editor 91
The Ladder Editor 97
The Sequential Function Chart Editor 102
6. The Resources 111
Overview of the Resources 111
Global Variables 111
PLC Configuration 113
Task Configuration 114
Sampling Trace 116
Watch and Receipt Manager 120
7. Library Manager 124
8. Appendix 126
Using the Keyboard 126
Data types 128
IEC Operators 131
Standard Library Elements 139
Operands in TwinCAT PLC Control 148
Build Error 152
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
3 Contents
9. Index 159
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The Object Organizer contains a list of all the objects in your project.
How do I set up my project? You can create the POUs needed to solve your problem.
Now you can program the POUs you need in the desired languages.
Once the programming is complete, you can compile the project and remo-
ve errors should there be any.
How can I test my project? Once all errors have been removed, log in to the PLC and "load" your pro-
ject in the PLC. Now TwinCAT PLC Control is in Online mode.
Test your project for correct sequence. To do this, enter input variables
manually and observe whether outputs are as expected. You can also ob-
serve the value sequence of the local variables in the POUs. In the Watch
and Receipt Manager you can configure data records whose values you
wish to examine.
Debugging with TwinCAT In case of a programming error you can set breakpoints. If the process
PLC Control stops at such a breakpoint, you can examine the values of all project varia-
bles at this point in time. By working through sequentially (single step) you
can check the logical correctness of your program.
Additional Online Functions An additional TwinCAT PLC Control debugging function: You can set pro-
gram variables and inputs and outputs at certain values. You can use the
flow control to check which program lines have been run. The Sampling
Trace allows you to trace and display the actual course of variables over an
extended period of time.
Additional TwinCAT PLC The entire project can be documented or exported to a text file at any time.
Control Features
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Project Components
Project Components A project contains all of the objects in a PLC program. A project is saved in
a file named after the project. The following objects are included in a pro-
ject:
TwinCAT PLC Control supports all IEC standard POUs. If you want to use
these POUs in your project, you must include the library standard.lib in your
project.
POUs can call up other POUs. However, recursions are not allowed.
Function A function is a POU, which yields exactly one data element (which can con-
sist of several elements, such as fields or structures) when it is processed,
and whose call in textual languages can occur as an operator in expressi-
ons.
When declaring a function do not forget that the function must receive a
type. This means, after the function name, you must enter a colon followed
by a type.
A function declaration begins with the keyword FUNCTION and ends with
END_FUNCTION.
Example in IL of a function that takes three input variables and returns the
product of the first two divided by the third:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Function
in IL:
LD 7
Fct 2,4
ST Result
in ST:
Result := Fct(7, 2, 4);
in FBD:
Result
In SFC a function call can only take place within a step or a transition.
If you define a function in your project with the name CheckBounds, you
can use it to check for range overflows in your project! The name of the
Note function is defined and may have only this identifier. An example of how this
function is implemented is shown below:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The following typical program for testing the CheckBounds function goes
beyond the boundaries of a defined array. The CheckBounds functions
makes sure that the value TRUE is not assigned to the position A[10], but
rather to the upper area boundary A[7] which is still valid. Therefore, the
CheckBounds function can be used to correct extensions beyond array
boundaries.
Function block A function block is a POU which provides one or more values during the
procedure. As opposed to a function, a function block provides no return
value.
Example in IL of a function block with two input variables and two output
variables. One output is the product of the two inputs, the other a compari-
son for equality:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Function block
Function Block Instances Reproductions or instances (copies) of a function block can be created.
Each instance possesses its own identifier (the Instance name), and a data
structure which contains its inputs, outputs, and internal variables. Instan-
ces are declared locally or globally as variables, whereas the name of the
function block is indicated as the type of an identifier.
Function blocks are always called through the instances described above.
Only the input and output parameters can be accessed from outside of an
function block instance. This means the internal variables of the function
blocks remain invisible to the user of the function block.
PROGRAM prog
VAR
inst1:fb;
END_VAR
LD 17
ST inst1.in1
CAL inst1
END_PROGRAM
The declaration parts of function blocks and programs can contain instance
declarations. Instance declarations are not permitted in functions.
Access to a function block instance is limited to the POU in which it was
declared unless it was declared globally.
The instance name of a function block instance can be used as the input
for a function or a function block.
All values are retained after processing a function block until the next it is
processed. Therefore, function block calls with the same arguments do not
Note always return the same output values!
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Calling a function block You can use the variables of the function block by entering the instance
name, a point, and then the variable name.
If you would like to set the input parameters when you open the function
block, you can do this in the text languages IL and ST by assigning values
to the parameters after the instance name of the function block in paren-
theses (this assignment takes place using ":=" just as with the initialization
of variables at the declaration position).
Examples for calling function block FUB described above. The multiplicati-
on result is saved in the variable ERG, and the result of the comparison is
saved in QUAD. An instance of FUB with the name INSTANCE is declared:
In IL the function block is implemented as follows:
In the example below the call is shown in ST. The declaration part is the
same as with IL:
In FBD it would look as follows (declaration part the same as with IL):
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Program A program is a POU which returns several values during operation. Pro-
grams are recognized globally throughout the project. All values are re-
tained from the last time the program was run until the next.
Program Example
If a POU calls a program, and if thereby values of the program are chan-
ged, then these changes are retained the next time the program is called,
even if the program has been called from within another POU.
This is different from calling a function block. There only the values in the
given instance of a function block are changed.
These changes therefore play a role only when the same instance is called.
A program declaration begins with the keyword PROGRAM and ends with
END_PROGRAM.
In IL:
CAL PRGExample
LD PRGexample.PAR
ST ERG
in ST:
PRGExample;
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Erg := PRGexample.PAR;
In FBD:
Resources You need the resources for configuring and organizing your project and for
tracing variable values:
• Global Variables which can be used throughout the project
• PLC Configuration for configuring your hardware
• Task Configuration for guiding your program through tasks
• Sampling Trace for graphic display of variable values
• Watch and Receipt Manager for displaying variable values and setting
default variable values
Libraries You can include in your project a series of libraries whose POUs, data ty-
pes, and global variables you can use just like user-defined variables. The
library "standard.lib" is a standard part of the program and is always at your
disposal.
Data types Along with the standard data types the user can define his own data types.
Structures, enumeration types and references can be created.
See "Standard" and "Defined data types" in the appendix.
Languages
Instruction List (IL) An instruction list (IL) consists of a series of instructions. Each instruction
begins in a new line and contains an operator and, depending on the type
of operation, one or more operands separated by commas.
Example:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
LD 17
ST lint (* comment *)
GE 5
JMPC next
LD idword
EQ istruct.sdword
STN test
next:
Modifiers and operators in In the IL language the following operators and modifiers can be used.
IL Modifiers:
• C with JMP, CAL, RET: The instruction is only then executed if the
result of the preceding expression is TRUE.
• N with JMPC, CALC, RETC: The instruction is only then executed if
the result of the preceding expression is FALSE.
• N otherwise: Negation of the operand (not of the accumulator)
Below you find a table of all operators in IL with their possible modifiers and
the relevant meaning:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
For example:
LD 2
MUL 2
ADD 3
ST ERG
Here the resulting value for Erg is 10, then the operation MUL is only then
evaluated if you come to ")"; as operand for MUL 5 is then calculated.
Structured Text (ST) The structured text consists of a series of instructions which, as determined
in high level languages, ("IF..THEN..ELSE") or in loops (WHILE..DO) can
be executed.
Example:
IF value < 7 THEN
WHILE value < 8 DO
value := value + 1;
END_WHILE;
END_IF;
Valuation of expressions The evaluation of expression takes place by means of processing the ope-
rators according to certain binding rules. The operator with the strongest
binding is processed first, then the operator with the next strongest binding,
etc., until all operators have been processed.
Operators with equal binding strength are processed from left to right.
Below you find a table of the ST operators in the order of their binding
strength:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Exponentiation **
Negate -
Building of complements NOT
Multiply *
Divide /
Modulo MOD
Add +
Subtract -
Compare <,>,<=,>=
Equal to =
Not equal to <>
Boolean AND AND
Boolean XOR XOR
Boolean OR OR Weakest binding
There are the following instructions in ST, arranged in a table together with
example:
FOR J:=101;
FOR I:=1 TO 100 BY 2 DO
IF ARR[I] = 70 THEN
J:=I;
EXIT;
END_IF;
END_FOR;
WHILE J:=1;
WHILE J<= 100 AND ARR[J] <> 70 DO
J:=J+2;
END_WHILE;
REPEAT J:=-1;
REPEAT
J:=J+2;
UNTIL J= 101 OR ARR[J] = 70
END_REPEAT;
EXIT EXIT;
Empty instruction ;
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Instruction in structured text The name already indicates, the structured text is designed for structure
programming, i.e. ST offers predetermined structures for certain often used
constructs such as loops for programming.
This offers the advantages of low error probability and increased clarity of
the program.
LD Var1
MUL 2
ST Var1
LD Counter
SUB 1
ST Counter
JMP Loop
End:
LD Var1
ST ERG
Erg:=Var1;
You can see, the loop in ST is not only faster to program, but is also signifi-
cantly easier to read, especially in view of the convoluted loops in larger
constructs.
Assignment operator On the left side of an assignment there is an operand (variable, address) to
which is assigned the value of the expression on the right side with the
assignment operator :=
Example:
Var1 := Var2 * 10;
After completion of this line Var1 has the tenfold value of Var2.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Calling function blocks in A function block is called in ST by writing the name of the instance of the
ST function block and then assigning the values of the parameters in paren-
theses. In the following example a timer is called with assignments for the
parameters IN and PT. Then the result variable Q is assigned to the varia-
ble A.
The result variable, as in IL, is addressed with the name of the function
block, a following point, and the name of the variable:
RETURN instruction The RETURN instruction can be used for ending a function, depending
upon a condition.
IF instruction With the IF instruction you can check a condition and, depending upon this
condition, execute instructions.
Syntax:
IF <Boolean_printout1> THEN
<IF_instructions>
{ELSIF <Boolean_printout2> THEN
<ELSIF_instructions1>
.
.
ELSIF <Boolean_printout n> THEN
<ELSIF_instructions n-1>
ELSE
<ELSE_instructions>}
END_IF;
If none of the Boolean expressions produce TRUE, then only the <EL-
SE_instructions> are evaluated.
Example:
IF temp<17
THEN heating_on := TRUE;
ELSE heating_on := FALSE;
END_IF;
Here the heating is turned on when the temperature sinks below 17 de-
grees. Otherwise it remains off.
CASE instruction With the CASE instructions one can combine several conditioned instructi-
ons with the same condition variable in one construct.
Syntax:
CASE <Var1> OF
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Example:
CASE INT1 OF
1, 5: BOOL1 := TRUE;
BOOL3 := FALSE;
2: BOOL2 := FALSE;
BOOL3 := TRUE;
ELSE
BOOL1 := NOT BOOL1;
BOOL2 := BOOL1 OR BOOL2;
END_CASE;
FOR loop With the FOR loop one can program repeated processes.
Syntax:
INT_Var :INT;
Example:
FOR Counter:=1 TO 5 BY 1 DO
Var1:=Var1*2;
END_FOR;
Erg:=Var1;
Let us assume that the default setting for Var1 is the value 1. Then it will
have the value 32 after the FOR loop.
WHILE loop The WHILE loop can be used like the FOR loop with the difference that the
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
break-off condition can be any Boolean expression. This means you indi-
cate a condition which, when it is fulfilled, the loop will be executed.
Syntax:
WHILE <Boolean expression>
<Instructions>
END_WHILE;
The programmer must make sure that no endless loop is caused. He does
this by changing the condition in the instruction part of the loop, for examp-
Note le, by counting up or down one counter.
Example:
WHILE counter<>0 DO
Var1 := Var1*2;
Counter := Counter-1;
END_WHILE
The WHILE and REPEAT loops are, in a certain sense, more powerful than
the FOR loop since one doesn’t need to know the number of cycles before
executing the loop. In some cases one will, therefore, only be able to work
with these two loop types. If, however, the number of the loop cycles is
clear, then a FOR loop is preferable since it allows no endless loops.
REPEAT loop The REPEAT loop is different from the WHILE loop because the break-off
condition is checked only after the loop has been executed. This means
that the loop will run through at least once, regardless of the wording of the
break-off condition.
Syntax:
REPEAT
<Instructions>
UNTIL <Boolean expression>
END_REPEAT;
The <Instructions> are carried out until the <Boolean expression> returns
TRUE.
The programmer must make sure that no endless loop is caused. He does
this by changing the condition in the instruction part of the loop, for example
Note by counting up or down one counter.
Example:
REPEAT
Var1 := Var1*2;
Counter := Counter-1;
UNTIL
Counter=0
END_REPEAT;
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
EXIT instruction If the EXIT instruction appears in a FOR, WHILE, or REPEAT loop, then
the innermost loop is ended, regardless of the break-off condition.
Sequential Function Chart The sequential function chart a graphically oriented language which makes
(SFC) it possible to describe the chronological order of different actions within a
program.
Actions of IEC steps hang in the Object Organizer directly under their SFC-
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
POU and are loaded with a doubleclick or by pressing <Enter> in their edi-
tor. New actions can be created with "Project" "Add Action"..
Entry or exit action You can add an entry action and an exit action to a step. An entry action is
executed only once, right after the step has become active. An exit action is
executed only once before the step is deactivated.
A step with entry action is indicated by an "E" in the lower left corner, the
exit action by an "X" in the lower right corner.
The entry and exit action can be implemented in any language. In order to
edit an entry or exit action, doubleclick in the corresponding corner in the
step with the mouse.
An entry and exit action can only be defined to a simplified step, but not to
an IEC step.
Active step After calling the SFC POU, the action (surrounded by a double border)
belonging to the initial step is executed first. A step, whose action is beeng
executed, is called active. If the step is active, then the appropriate action is
executed once per cycle. In Online mode active steps are shown in blue.
To each step belongs a flag which saves the condition of the step. The step
flag (active or inactive condition of the step) is shown by the logical value of
a Boolean structure element <StepName>.x. This Boolean variable has the
value TRUE if the appropriate step is active and FALSE if it is inactive. This
variable is implicitly declared and can be used in any action and transition
of the SFC POU.
In a control cycle all actions are executed which belong to active steps.
Thereafter the respective following steps of the active steps become active
if the transition conditions of the following steps are TRUE. The currently
active steps will be executed in the next cycle.
IEC step Along with the simplified steps the standard IEC steps in SFC are available.
Any number of actions can be assigned to an IEC step. The actions of IEC
steps lie separated from the steps and can be used repeatedly within their
POU. For this they must be associated to the single steps with the com-
mand "Extras" "Associate action".
The actions associated with an IEC step are shown at the right of the step
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
in a two-part box. The left field contains the qualifier, possibly with time
constant, and the right field contains the action name.
An example for an IEC step with two actions:
In order to make it easier to follow the processes, all active actions in online
mode are shown in blue like the active steps. After each cycle a check is
made to see which actions are active.
Whether a newly inserted step is an IEC step depends upon whether the
menu command "Extras" "Use IEC-Steps" has been chosen.
In the Object Organizer the actions hang directly underneath their respecti-
ve SFC POUs. New actions can be created with "Project" "Add Action".
In order to use IEC steps you must include in your project the special SFC
library lecsfc.lib .
Qualifier In order to associate the actions with IEC steps the following qualifiers are
available:
SD Stored and time The action is activated after a certain time and
Delayed remains active until a Reset
DS Delayed and The action is activated after a certain time as long
Stored as the step is still active and remains active up to
a Reset
SL Stored and time The is action is activated for a certain time
limited
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Alternative branch Two or more branches in SFC can be defined as alternative branches.
Each alternative branch must begin and end with a transition. Alternative
branches can contain parallel branches and other alternative branches. An
alternative branch begins at a horizontal line (alternative beginning) and
ends at a horizontal line (alternative end) or with a jump.
If the step which precedes the alternative beginning line is active, then the
first transition of each alternative branch is evaluated from left to right. The
first transition from the left whose transition condition has the value TRUE
is opened and the following steps are activated (see active step).
Parallel branch Two or more branches in SFC can be defined as parallel branches. Each
parallel branch must begin and end with a step. Parallel branches can
contain alternative branches or other parallel branches. A parallel branch
begins with a double line (parallel beginning) and ends with a double line
(parallel end) or with a jump.
If the parallel beginning line of the previous step is active and the transition
condition after this step has the value TRUE, then the first steps of all par-
allel branches become active (see active step). These branches are now
processed parallel to one another. The step after the parallel end line be-
comes active when all previous steps are active and the transition condition
before this step produces the value TRUE.
Jump A jump is a connection to the step whose name is indicated under the jump
symbol. Jumps are required because it is not allowed to create connections
which lead upward or cross each other.
Function Block Diagram The function block diagram is a graphically oriented programming langua-
(FBD) ge. It works with a list of networks whereby each network contains a struc-
ture which represents either a logical or arithmetic expression, the call of a
function block, a jump, or a return instruction.
Ladder diagram (LD) The ladder diagram is also a graphics oriented programming language
which approaches the structure of an electric circuit.
On the one hand, the ladder diagram is suitable for constructing logical
switches, on the other hand one can also create networks as in FBD. The-
refore the LD is very useful for controlling the call of other POUs. More
about this later.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
lean values TRUE and FALSE. To each contact belongs a Boolean varia-
ble. If this variable is TRUE, then the condition is passed from left to right
along the connecting line. Otherwise the right connection receives the value
OFF.
Example of a typical network in the ladder diagram as it could appear in
TwinCAT PLC Control :
Contact Each network in LD consists on the left side of a network of contacts (con-
tacts are represented by two parallel lines: | |) which from left to right show
the condition "On" or "Off".
Coil On the right side of a network in LD there can be any number of so-called
coils which are represented by parentheses:( ). They can only be in parallel.
A coil transmits the value of the connections from left to right and copies it
in an appropriate Boolean variable. At the entry line the value ON (corre-
sponds to the Boolean variable TRUE) or the value OFF (corresponding to
FALSE) can be present.
Contacts and coils can also be negated (in the example the contact
SWITCH1 and the coil %QX3.0 is negated). If a coil is negated (reco-
gnizable by the slash in the coil symbol: (/)), then it copies the negated va-
lue in the appropriate Boolean variable. If a contact is negated, then it con-
nects through only if the appropriate Boolean value is FALSE.
Function blocks in the Along with contacts and coils you can also enter function blocks and pro-
ladder diagram grams. In the network they must have an input and an output with Boolean
values and can be used at the same places as contacts, that is on the left
side of the LD network
Set/Reset coils Coils can also be defined as set or reset coils. One can recognize a set coil
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
by the "S" in the coil symbol: (S)) It never writes over the value TRUE in the
appropriate Boolean variable. That is, if the variable was once set at TRUE,
then it remains so.
One can recognize a reset coil by the "R" in the coil symbol: (R)) It never
writes over the value FALSE in the appropriate Boolean variable: If the
variable has been once set on FALSE, then it remains so.
LD as FBD When working with LD it is very possible that you will want to use the result
of the contact switch for controlling other POUs. On the one hand you can
use the coils to put the result in a global variable which can then be used in
another place. You can, however, also insert the possible call directly into
your LD network. For this you introduce a POU with EN input.
Starting from such an EN POU, you can create networks similar to FBD.
Debugging The debugging functions of TwinCAT PLC Control make it easier for you
to find errors.
Breakpoints can be set in all editors. In the text editors breakpoints are set
at line numbers, in FBD and LD at network numbers, and in SFC at steps.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
• In IL: Execute the program until the next CAL, LD or JMP command.
• In ST: Execute the next instruction.
• In FBD, LD: Execute the next network.
• In SFC: Continue the action until the next step.
By proceeding step by step you can check the logical correctness of your
program.
Single Cycle If Single cycle has been chosen, then the execution is stopped after each
cycle.
Change values online During operations variables can be set once at a certain value (write value)
or also described again with a certain value after each cycle (forcing).
Monitoring In addition to the variable declarations visible on the screen, the current
values from the PLC are continuously read and displayed.
In Online mode TwinCAT PLC Control monitors all variables visible on the
screen. At the same time variables can be put together in the watch and
receipt manager whose data you would like to see all in one place.
Simulation During the simulation the created PLC program is not processed in the
PLC, but rather in the calculator on which TwinCAT PLC Control is run-
ning. All online functions are available. Simulation mode is only available for
the Buscontroller (BCxx00). If you use TwinCAT on the PC (Code generati-
on i386) you can simulate the program direct in the runtime system without
having physical I/O.
The Standard
The standard IEC 1131-3 is an international standard for programming
languages of Programmable Logic Controllers.
The processing of a TwinCAT PLC Control program begins with the special
POU PLC_PRG1. The POU PLC_PRG can call other POUs.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In this example you will see how time dependent programs can be shown
with the language resources of the IEC1131-3 standard, how one can edit
the different languages of the standard with the help of TwinCAT PLC
Control, and how one can easily connect them while becoming familiar
with the simulation of TwinCAT PLC Control.
Create POU The beginning is always easy: First start TwinCAT PLC Control and choo-
se "File" "New".
In the dialog box which appears, the first POU should have the name
PLC_PRG. The type of POU should definitely be a program. In this case we
choose as the language of this POU the sequential function chart (SFC).
Now create two more objects with the command "Project" "Object Add"
with the menu bar or with the context menu (press right mouse button in the
Object Organizer). A function block in the language Function Block Dia-
gram (FBD) by the names of TRAFFICSIGNAL, along with a POU WAIT,
also of the type function block, which we want to program as an instruction
list (IL).
What does In the POU TRAFFICSIGNAL we will assign the individual trafficsignal pha-
TRAFFICSIGNAL do? ses to the lights, i.e. we will make sure that the red light is lit red in the red
phase and in the yellow/red phase, the yellow light in the yellow and yel-
low/red phases, etc.
What does WAIT do? In WAIT we will program a simple timer which as input will receive the
length of the phase in milliseconds, and as output will produce TRUE as
soon as the time period is finished.
What does PLC_PRG do? PLC_PRG will combine everything at the end so that the right light lights up
at the right time for the desired time period.
"TRAFFICSIGNAL" Let us now turn to the POU TRAFFICSIGNAL. In the declaration editor you
declaration declare as input variable (between the keywords VAR_INPUT and
END_VAR) a variable named STATUS of the type INT. STATUS will have
five possible conditions, that is one for the TRAFFICSIGNAL phases green,
yellow, yellow/red, red, and off.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"TRAFFICSIGNAL" body Now it is time to determine from the input STATUS of the POU the values
of the output variables. For this go into the body of the POU. Click on the
field to the left beside the first network (the gray field with the number 1).
You have now selected the first network. Now choose the menu item
"Insert" "Operator".
In the first network a box is inserted with the operator AND and two inputs:
Click on the text AND with the mouse pointer and change the text into EQ.
Select the three question marks from the upper of the two inputs and enter
the variable STATUS. Then select the lower of the three question marks
and put a 1 underneath it. You get the following network:
Click now on a place behind the EQ Box. Now the output of the EQ opera-
tion is selected. Choose "Insert" "Assignment". Change the three questi-
on marks ??? to GREEN. You now have created a network with the follo-
wing structure:
For the other TRAFFICSIGNAL colors or for OFF we need three more net-
works. You create them with the command "Insert" "Network (after)".
These networks should be set up as in the example. The finished POU now
is as follows:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Now our first POU has been finished. TRAFFICSIGNAL, according to the
input of the value STATUS, controls whichever light color we wish.
Connecting the standard.lib For the timer in the POU WAIT we need a POU from the standard library.
Therefore, open the library manager with "Window" "Library Manager".
Choose "Insert" "Additional library". The dialog box appears for opening
files. From the list of the libraries choose standard.lib.
"WAIT" declaration Now let us turn to the POU WAIT. This POU is supposed to become a ti-
mer with which we can determine the length of the time period of each
TRAFFICSIGNAL phase. Our POU receives as input variable a variable
TIME of the type TIME, and as output it produces a Boolean value which
we want to call OK and which should be TRUE when the desired time pe-
riod is finished. We set this value with FALSE by inserting at the end of the
declaration (before the semicolon, however) " := FALSE ".
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
For our purposes we need the POU TP, a clock generator. This has two
inputs (IN, PT) and two outputs (Q, ET). TP does the following:
In order to use the POU TP in the POU WAIT we must create a local in-
stance from TP. For this we declare a local variable ZAB (for elapsed time)
of the type TP (between the keywords VAR, END_VAR).
The declaration part of WAIT thus looks like this:
"WAIT" body In order to create the desired timer, the body of the POU must be pro-
grammed as follows:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
At first the question is posed whether Q has already been set at TRUE (as
though the counting had already been executed), in this case we change
nothing with the occupation of ZAB, but rather we call the function block
ZAB without input (in order to check whether the time period is already
over).
The timer is finished at this point. Now it is time to combine our two function
blocks WAIT and TRAFFICSIGNAL in the main program PLC_PRG.
"PLC_PRG" first expansion First we declare the variables we need. They are two instances of the func-
level tion block TRAFFICSIGNAL (TRAFFICSIGNAL1, TRAFFICSIGNAL2) and
one of the type WAIT (DELAY as delay). PLC_PRG now appears as fol-
lows:
TWIN&$7
Chapter 3 We Write a Little Program 32
Program PLC_PRG,
First Expansion Level,
Declaration Part
Create a SFC diagram The beginning diagram of a POU in SFC always consists of an action "Init"
of a following transition "Trans0" and a jump back to Init. We should ex-
pand that somewhat.
First let us determine the structure of the diagrams before we program the
individual action and transitions. First we need for each TRAFFICSIGNAL
phase a step.. Insert it by marking Trans0 and choosing "Insert" "Step
transition (behind)". Repeat this procedure three more times.
If you click directly on the name of a transition or a step, then this is marked
and you can change it. Name the first transition after Init "TRUE", and all
other transitions "DELAY.OK".
The first transition always switches through, and all others switch through
when DELAY in OK produces TRUE, i.e. when the set time period is finis-
hed.
The steps (from top to bottom) receive the names Switch1, Green2,
Switch2, Green1, whereby Init of course keeps its Name. "Switch" should
mean each time a yellow phase, at Green1 TRAFFICSIGNAL1 at Green2
TRAFFICSIGNAL2 will be green. Finally change the return address of Init
after Switch1. If you have done everything right, then the diagram should be
as follows:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Actions and transition In the action of the step Init the variables are initialized, the STATUS of
conditions TRAFFICSIGNAL1 should be 1 (green). The state of TRAFFICSIGNAL2
should be 3 (red). The action Init then is as follows:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Action Init
Action Switch1
Action Green2
Action Switch2
Action Green1
The first expansion phase of our program is completed. Now you can com-
pile it and also test the simulation.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
PLC_PRG second expansi- In order to ensure that our diagram has at least one alternative branch, and
on level so that we can turn off our traffic light unit at night, we now include in our
program a counter which, after a certain number of TRAFFICSIGNAL cy-
cles, turns the unit off.
At first we need a new variable COUNTER of the type INT. Declare this as
usual in the declaration part of PLC_PRG, and initialize it in Init with 0.
Now select the transition after Switch1 and insert a step and then a transiti-
on. Select the resulting transition and insert an alternative branch to its left.
After the left transition insert a step and a transition. After the resulting new
transition insert a jump after Switch1.
Name the new parts as follows: the upper of the two new steps should be
called "Count" and the lower "Off". The transitions are called (from top to
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
bottom and from left to right) EXIT, TRUE and DELAY.OK. The new part
should therefore look like the part with the black border:
Now two new actions and a new transition condition are to be implemented.
At the step Count, the only thing that happens is that COUNTER is increa-
sed by one:
Action Count
The EXIT transition checks whether the counter is greater than a certain
number, let us say 7:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Transition EXIT
At Off the state of both lights is set at (OFF), the COUNTER is reset to 0,
and a time delay of 10 seconds is set:
Action Off
The result In our hypothetical situation, night falls after seven TRAFFICSIGNAL cy-
cles, for ten seconds the TRAFFICSIGNAL turns itself off, then we have
daylight again, the traffic light unit turns itself on again, and the whole
process starts again from the beginning.
TRAFFICSIGNAL Now test your program. For this you must compile it ("Project" "Rebuild
simulation all") login ("Online" "Login" and then load it "Online" "Download"). If you
now select "Online" "Run", the chronological order of the individual steps
of your main program can be followed. The window of the POU PLC_PRG
has now changed to the monitor window. Click twice on the plus sign in the
declaration editor, the variable display drops down, and you can see the
values of the individual variables.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The Main Window The following elements are found in the main window of TwinCAT PLC
Control (from top to bottom):
• The menu bar
• The tool bar (optional); with buttons for faster selection of menu com-
mands.
• The Object Organizer with register cards for POUs, Data types, and
Resources
• A vertical screen divider between the Object Organizer and the Work
space of TwinCAT PLC Control
• The Work space in which the editor windows are located
• The message window (optional)
• The Status bar (optional); with information about the current status of
the project
Menu bar The menu bar is located at the upper edge of the main window. It contains
all menu commands.
Tool bar By clicking with the mouse on a symbol you can select a menu command
more quickly. The choice of the available symbols automatically adapts
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The command is only carried out when the mouse button is pressed on the
symbol and then released.
If you hold the mouse pointer for a short time on a symbol in the tool bar,
then the name of the symbol is shown in a Tooltip.
In order to see a description of each symbol on the tool bar, select in Help
the editor about which you want information and click on the tool bar sym-
bol in which you are interested.
The display of the tool bar is optional (see "Project" "Options" category
Desktop).
Object Organizer The Object Organizer is always located on the left side of TwinCAT PLC
Control. At the bottom there are four register cards with symbols for the four
types of objects POUs, Data types, and Resources. In
order to change between the respective object types click with the mouse
on the corresponding register card or use the left or right arrow key.
You will learn in chapter Creating and Deleting Objects, etc.how to work
with the objects in the Object Organizer.
Screen divider The screen divider is the border between two non-overlapping windows. In
TwinCAT PLC Control there are screen dividers between the Object Or-
ganizer and the Work space of the main window, between the interface
(declaration part) and the implementation (instruction part) of POUs and
between the Work space and the message window.
You can move the screen divider with the mouse pointer. You do this by
moving the mouse with the left mouse button pressed.
Make sure the the screen divider always remains at its absolute position,
even when the window size has been changed. If it seems that the screen
divider is no longer present, then simply enlarge your window.
Work space The Work space is located on the right side of the main window in Twin-
CAT PLC Control. All editors for objects and the library manager are ope-
ned in this area.
You find the description of the editors in the chapter Editors in TwinCAT
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Under the menu item "Window" you find all commands for window mana-
gement.
Message window The message window is separated by a screen divider underneath the work
space in the main window.
Status bar The status bar at the bottom of the window frame of the main window in
TwinCAT PLC Control gives you information about the current project and
about menu commands.
If an item is relevant, then the concept appears on the right side of the sta-
tus bar in black script, otherwise in gray script.
When you are working in online mode, the concept Online appears in black
script. If you are working in the offline mode it appears in gray script.
In Online mode you can see from the status bar whether you are in the
simulation (SIM), the program is being processed (RUNS), a breakpoint is
set (BP), or variables are being forced (FORCE).
With text editor the line and column number of the current cursor position is
indicated (e.g. Line:5, Col.:11).
If you have chosen a menu command but haven’t yet confirmed it, then a
short description appears in the status bar.
The display of the statusbar is optional (see "Project" "Options" category
Desktop).
Instead of using the menu bar for executing a command, you can use the
right mouse button. The menu which then appears contains the most fre-
quently used commands for a selected object or for the active editor. The
choice of the available commands adapts itself automatically to the active
window. The choice of the available commands adapts itself automatically
to the active window.
Options
About TwinCAT PLC Control there can be of course only one viewpoint. In
TwinCAT PLC Control, however, you can configure the view of the main
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
window (and have more than one viewpoint). In addition you can make
other settings. For this you have the command "Project" Options" at your
disposal. The settings you make thereby are, unless determined otherwise,
saved in the file "TwinCAT PLC Control.ini" and restored at the next Twin-
CAT PLC Control startup.
"Project" "Options" With this command the dialog box for setting options is opened. The opti-
ons are divided into different categories. Choose the desired category on
the left side of the dialog box by means of a mouse click or using the arrow
keys and change the options on the right side.
Load & Save If you choose this category , then you get the following dialog box:
If you choose the option Auto Save, then while you work your project is
constantly saved to a temporary file with the extension ".asd" according to a
set time interval (Auto Save Interval). This file is erased at a normal exit
from the program. If for any reason TwinCAT PLC Control is not shut
down "normally" (e.g. due to a power failure), then the file is not erased.
When you open the file again the following message appears:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
You can now decide whether you want to open the original file or the auto
save file.
If you request the option Ask for project info, then when saving a new
project, or saving a project under a new name, the project info is automati-
cally called. You can visualize the project info with the command "Project"
"Project info" and also process it.
If you choose the option Auto Load, then at the next start of TwinCAT PLC
Control the last open project is automatically loaded. The loading of a pro-
ject at the start of TwinCAT PLC Control can also take place by entering
the project in the command line.
User information If you choose this category , then you get the following dialog box:
To User information belong the Name of the user, his Initials and the
Company for which he works. Each of the entries can be modified and is
saved with the project.
Editor If you choose this category , then you get the following dialog box:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Autodeclaration If you have chosen the Autodeclaration, then (following the input of a not-
yet-declared variable) a dialog box will appear in all editors with which this
variable can be declared.
Autoformat If the option Autoformat in the category Editor of the options dialog box
has been chosen, then TwinCAT PLC Control executes automatic format-
ting in the IL editor and in the declaration editor. When you finish with a line,
the following formatting is made:
• Operators written in small letters are shown in capitals;
• Tabs are inserted to that the columns are uniformly divided.
Declarations as table If the option Declarations as tables in the Editor category in the Options
dialog box is selected, then you can edit variables in a table instead of
using the usual declaration editor (see chapter 0). This table is arranged as
a card-index box in which there are register cards for input, output, local,
and input/output variables. For each variable you have available the fields
Name, Address, Type, Initial, and Comment.
Tab-Width In the field Tab-Width in the category Editor of the Options dialog box you
can determine the width of a tab as shown in the editors. The default set-
ting is four characters, whereby the character width depends upon the font
which is chosen.
Font By clicking on the button Font in the category Editor of the Options dialog
box you can choose the font in all TwinCAT PLC Control editors. The font
size is the basic unit for all drawing operations. The choice of a larger font
size thus enlarges the printout, even with each editor of TwinCAT PLC
Control.
After you have entered the command, the font dialog box opens for choo-
sing the font, style and font size.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Selecting When choosing Mark in the Editor category in the Options dialog box you
can choose whether the current selection in your graphic editors should be
represented by a dotted rectangle (Dotted), a rectangle with continuous
lines (Line) or by a filled-in rectangle (Filled). In the last case the selection
is shown inverted.
Bitvalues When choosing Bitvalues in the category Editor of the Options dialog box
you can choose whether binary data (type BYTE, WORD, DWORD) during
monitoring should be shown Decimal, Hexadecimal, or Binary.
The selection is activated in front of which a (•) point appears.
If you choose this category , then you get the following dialog box:
If the option Toolbar has been chosen, then the tool bar with the buttons
for faster selection of menu commands becomes visible underneath the
menu bar.
If the option Statusbar has been chosen, then the status bar at the lower
edge of the TwinCAT PLC Control main window becomes visible.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If the option Online in Security mode has been chosen, then in Online
mode with the commands "Run", "Stop", "Reset", "Toggle Breakpoint",
"Single cycle", "Write values", "Force values" and "Release force", a
dialog box appears with the confirmation request whether the command
should really be executed. This option is saved with the project.
Colors If you choose this category , then you get the following dialog box:
You can edit the default color setting of TwinCAT PLC Control. You can
choose whether you want to change the color settings for Line numbers
(default setting: light gray), for Breakpoint positions (dark gray), for a Set
breakpoint (light blue), for the Current position (red), for the Reached
Positions (green) or for the Monitoring of Boolean values (blue).
If you have chosen one of the indicated buttons, the dialog box for the input
of colors opens.
Directories If you choose this category , then you get the following dialog box:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In the input fields Libraries and Compilation Files you can indicate direc-
tories from which TwinCAT PLC Control should extract the libraries or
compilation files. If you activate the button (...) behind a field, then the dia-
log box for selecting a directory open.
Build If you choose this category , then you get the following dialog box:
If the option Debugging has been chosen, then the code can significantly
increase in size. Choosing this option makes it possible to generate addi-
tional debugging codes. This is necessary in order to use the TwinCAT
PLC Control debugging functions. If you deactivate this option, then you
make possible faster processing and a smaller code. This option is saved
with the project.
If the option Online Changes has been chosen, then your your project can
be changed in the Online mode. With this new compilation only the chan-
ged POUs are loaded into the PLC. (See "Project" "Build")
If the option Save before compile, then your project will be saved every
time before compilation.
If the option Replace constants has been chosen, then during code gene-
ration the constants are replaced by their initialized values. The advantage
of this lies in faster access to the value than by access through a storage
position. To make sure, the constants can then not be changed in the on-
line mode "Force values" and "Write values").
With the indication of the Number of the data segments you can determi-
ne how much space is reserved in the PLC for the data of your project. If
during Build you get the message: "The global variables need too much
memory", then increase the number of segments in "Project" "Build" ",
which increases the number of the data segments.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Passwords If you choose this category , then you get the following dialog box:
Enter the desired password in the field Password. For each typed charac-
ter an asterisk (*) appears in the field. You must repeat the same word in
the field Confirm Password. Close the dialog box with OK. If you get the
message:
then you made a typing error during one of the two entries. In this case
repeat both entries until the dialog box closes without a message.
If you now save the file and then reopen it, then you get a dialog box in
which you are requested to enter the password. The project can then only
be opened if you enter the correct password. Otherwise TwinCAT PLC
Control reports:
Along with the opening of the file, you can also use a password to protect
against the file being changed. For this you must enter a password in the
field Write Protection Password and confirm this entry in the field under-
neath.
In order to create differentiated access rights you can define user groups
("Project" "Object access rights" and "Passwords for user groups").
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Here you can define the size of your memory for input, output and located
memory. If you want to read/write variables with symbolic names (with the
ADS OCX or the ADS Dll) you need symbols in the PLC runtime system.
Symbols need memory in the PLC so you can choose how much symbols
you need. You can choose between local and global variables. And with
Main and Sub you can choose wether you want symbols for all components
of all arrays and structures (Sub) or not (Main). If you choose main only the
main array- or structure names are available.
Sample:
abc : ARRAY[1..2] OF BOOL;
If you select only Main you get symbols only for ’abc’. If you select Sub you
get also symbols for the components ’abc[1]’ and ’abc[2]’.
Managing Projects
The commands which refer to entire project are found under the menu
items "File" and "Project". Some of the commands under "Project" deal
with objects and are therefore described in the chapter Creating and Dele-
ting Objects, etc. Creating and Deleting Objects.
"File" "New"
Symbol:
With this command you create an empty project with the name "Untitled".
This name must be changed when saving.
"File" "Open"
Symbol:
With this command you open an already existing project. If a project has
already been opened and changed, then TwinCAT PLC Control asks
whether this project should be saved or not.
The dialog box for opening a file appears, and a project file with the exten-
sion "*.pro" or a library file with the extension "*.lib" must be chosen. This
file must already exist. It is not possible to create a project with the com-
mand "Open".
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The most recently opened files are listed under the command "File" "Exit".
If you choose one of them, then this project is opened.
If Passwords or User groups have been defined for the project, then a
dialog box appears for entering the password.
"File" "Close" With this command you close the currently-open project. If the project has
been changed, then TwinCAT PLC Control asks if these changes are to
be saved or not.
If the project to be saved carries the name "Untitled", then a name must be
given to it (see "File" "Save as").
"File" "Save"
Symbol: Shortcut: <Ctrl>+<S>
With this command you save any changes in the project.
If the project to be saved is called "Untitled", then you must give it a name
(see "File" "Save as").
"File" "Save as" With this command the current project can be saved in another file or as a
library. This does not change the original project file.
After the command has been chosen the Save dialog box appears. Choose
either an existing File name or enter a new file name and choose the desi-
red file type.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If the project is to be saved under a new name, then choose the file type
TwinCAT PLC Control Project (*.pro).
If you choose the file type Project Version 2.4.2 (*.pro), then the current
project is saved as if it were created with the version 2.4.2. Specific data of
the version 2.6 can thereby be lost! However, the project can be executed
with the version 2.4.2.
You can also save the current project as a library in order to use it in other
projects. Choose the file type Internal library (*.lib) if you have program-
med your POUs in TwinCAT PLC Control.
Choose the file type External library (*.lib) if you want to integrate the
POUs which have been implemented in other languages (e.g. C). This me-
ans that another file is also saved which receives the file name of the libra-
ry, but with the extension "*.h". This file is constructed as a C header file
with the declarations of all POUs, data types, and global variables.
Then click OK. The current project is saved in the indicated file. If the new
file name already exists, then you are asked if you want to overwrite this
file.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In the Print dialog box you can choose the print range with the Document
project (either All or a range of explicitly indicated pages). When printing
an object, this is printed in full. You can determine the number of the co-
pies and print the version to a file.
With the button Properties you open the dialog box to set up the printer.
You can determine the layout of your printout with the command "File"
"Document settings".
During printing the dialog box shows you the number of pages already
printed. When you close this dialog box, then the printing stops after the
next page.
If you want to create a document frame for your project, then open a global
variables list and use the command "Extras" "Make Docuframe file".
"File" "Printer setup" With this command you can determine the layout of the printed pages. The
following dialog box is now opened:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In the field File you can enter the name of the file with the extension ".dfr" in
which the page layout should be saved. The default destination for the set-
tings is the file DEFAULT.DFR.
If you would like to change an existing layout, then browse through the di-
rectory tree to find the desired file with the button Browse.
You can also choose whether to begin a new page for each object and
for each subobject. Use the Printer Setup button to open the printer con-
figuration.
If you click on the Edit button, then the frame for setting up the page layout
appears. Here you can determine the page numbers, date, filename and
POU name, and also place graphics on the page and the text area in which
the documentation should be printed.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In addition, with "Insert" "Bitmap" you can insert a bitmap graphic (e.g. a
company logo) in the page. After selecting the graphic, a rectangle should
also be drawn here on the layout using the mouse.
If the template was changed, then TwinCAT PLC Control asks when the
window is closed if these changes should be saved or not.
"Project" "Check all" With this command you can check the the static correctness of your pro-
gram. If an error crops up, then it is announced in the message window, as
with the building of the program.
"Project" "Build" With this command all changed POUs are built. When loading the program,
only the modified POUs are sent to the PLC. The rest of the program re-
mains unchanged in the PLC.
If you select "Build" two times in a row without sending the program to the
PLC in the interim, then the error message appears: "Modifications not
compatible with each other".
Warning Follwing this the program must be rebuilt ("Rebuild all") and sent in full to
the PLC!
"Project" "Rebuild all" With this command you rebuild all POUs. The message window is opened
which shows the progress of the building process and any errors which may
be be discovered.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
With the command "Online" "Login" the command "Rebuild all" is automati-
cally executed if the project has been modified since the last compilation.
If the option Save before compile in the options dialog box in the category
Build has been chosen, then the project is backed up before compilation.
The cross references are created during compilation and are not saved in
the project! In order to use the commands "Show call tree“, "Show cross
Note reference list", and "Show unused variables" the project must be rebuilt
after loading and after a modification.
"Project" "Document" This command lets you print the documentation of your entire project. The
elements of a complete documentation are:
• The POUs,
• the contents of the documentation,
• the data types,
• the resources (global variables, the sampling trace, the PLC configurati-
on, the task configuration, the watch and receipt manager)
• the call trees of POUs and data types, as well as
• the cross reference list.
For the last two items the project must have been built without errors.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Only those areas in the dialog box are printed which are highlighted in blue.
If you want to select the entire project, then select the name of your project
in the first line.
If, on the other hand, you only want to select a single object, then click on
the corresponding object or move the dotted rectangle onto the desired
object with the arrow key. Objects which have a plus sign in front of their
symbols are organization objects which contain other objects. With a click
on a plus sign organization object is expanded, and with a click on the re-
sulting minus sign it can be closed up again. When you select an organiza-
tion object, then all relevant objets are also selected. By pressing the
<Shift> key you can select a group of objects, and by pressing the <Ctrl>
key you can select several individual objects.
Once you have made your selection, then click on OK. The Print dialog box
appears. You can determine the layout of the pages to be printed with
"File" "Printer setup".
"Project" "Export" With TwinCAT PLC Control projects can be exported or imported. That
allows you to exchange programs between different IEC programming sy-
stems.
There is a standardized exchange format for POUs in IL, ST, and SFC (the
Common Elements format of IEC 1131-3). For the POUs in LD and FBD
and the other objects TwinCAT PLC Control has its own filing format since
there is no text format for this in IEC 1131-3. The selected objects are
written to an ASCII file.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Once you have made your selection in the dialog box window (the same
way as with "Project" "Document" ), then click on OK. The dialog box for
saving files appears. Enter a file name with the expansion ".exp".
"Project" "Import" In the resulting dialog box for opening files select the desired export file.
The data is imported into the current project. If an object with the same
name already exists in the same project, then a dialog box appears with the
question "Do you want to replace it?": If you answer Yes, then the object in
the project is replaced by the object from the import file. If you answer No,
then the name of the new objects receives as a supplement an underline
and a digit ("_0", "_1", ..). With Yes, all or No, all this is carried out for all
objects.
"Project" "Compare" With this command you can compare the open project with another. For
example, if you prepare to save and want to know where you have made
changes in the current project, then you can compare the open project with
the last saved version of it.
After you have given this command, then the dialog box for opening files
appears. Choose the project with which you want to compare the current
project. If you press OK, then you will see the result of the comparison in
the message window. All of the objects of the chosen project are listed and
the changes in the object are shown afterward in parentheses. There are
five possible messages:
• "Unchanged": The object was not changed.
• "Deleted": The object is no longer present in the current project.
• "Implementation changed": The instruction part of the POU has been
changed.
• "Interface changed": The declaration part of the object has been chan-
ged.
• "Interface and implementation changed": Both the instruction part and
the declaration part of the POU have been changed.
"Project" "Merge" With this command you can merge objects (POUs, data types, and resour-
ces) from other projects into your project.
When the command has been given, then at first the standard dialog box
for opening files appears. When you have chosen a file there, then a dialog
box appears in which you can choose the desired object. The selection
takes place as described with "Project" "Document" .
If an object with the same name already exists in the project, then the name
of the new object receives the addition of an underline and a digit ("_1",
"_2" ...).
"Project" "Project info" Under this menu item the information about your project can be saved.
When the command has been given, then the following dialog box opens:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
This information is optional. When you press the button Statistics you re-
ceive statistical information about the project.
It contains information such as the number of the POUs, data types, and
the local and global variables as they were traced at the last compilation.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If you choose the option Ask for project info in the category Load & Save
in the options dialog box, then while saving a new project, or while saving a
project under a new name, the project info is called automatically.
"Project" "Global Search" With this command you can search for the location of a text in POUs, data
types, or in the objects of the global variables.
When the command is entered, a dialog box opens in which you can choo-
se the desired object. The selection is made as in the "Project" "Docu-
ment" description.
When you have confirmed the selection with OK, then the search dialog
box appears. If a text in an object has been found, then the object is loaded
into the appropriate editor, and its location is shown.
"Project" "Global replace" With this command you can search for the location of a text in POUs, data
types, or the objects of the global variables and replace this text by
another. This is executed in the same way as with "Project" "Global Se-
arch" or "Edit" "Replace".
Copy your project, make your changes, and test your changes. Select the
command "Project" "Compare" in order to compare the two projects. With
the command "Register changes" all differences between the current
project and the comparison are traced. Then, with the command "Build"
the modified POUs can be compiled. When downloading the program only
the modified POUs are sent to the PLC. The rest of the program remains
unchanged in the PLC.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
User groups In TwinCAT PLC Control up to eight user groups with different access
rights to the POUs, data types, and resources can be set up. Access rights
for single objects or all of them can be established. Only a member of a
certain user group can open a project. A member of such a user group
must identify himself by means of a password.
The user groups are numbered from 0 to 7, whereby the Group 0 has the
administrator rights, i.e. only members of group 0 may determine pass-
words and access rights for all groups and/or objects.
When a new project is launched, then all passwords are initially empty.
Until a password has been set for the 0 group, one enters the project auto-
matically as a member of the 0 group.
If a password for the user group 0 is existing while the project is loaded,
then a password will be demanded for all groups when the project is ope-
ned. For this the following dialog box appears:
In the combobox User group on the left side of the dialog box, enter the
group to which you belong and enter on the right side the relevant pass-
word. Press OK. If the password does not agree with the saved password,
then the message appears:
Only when you have entered the correct password can the project be ope-
ned.
With the command "Passwords for user group" you can assign the
passwords, and with "Object" "Access rights" you can define the rights
for single objects or for all of them.
"Project""Passwords for With this command you open the dialog box for password assignment for
user groups“ user groups. This command can only be executed by members of group 0.
When the command has been given, then the following dialog box appears:
In the left combobox User group you can select the group. Enter the desi-
red password for the group in the field Password. For each typed character
an asterisk (*) appears in the field. You must repeat the same password in
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
the field Confirm password. Close the dialog box after each password
entry with OK. If you get the message:
then you made a typing error during one of the two entries. In this case
repeat both entries until the dialog box closes without a message.
Then, if necessary, assign a password for the next group by calling the
command again.
Object POUs, data types, and the resources (global variables, the sampling trace,
the PLC configuration, the task configuration, and the Watch and Receipt
Manager) are all defined as "objects". The folders inserted for structuring
the project are partially involved. All objects of a project are in the Object
Organizer.
If you hold the mouse pointer for a short time on a POU in the Object Orga-
nizer, then the type of the POU (Program, Function or Function block) is
shown in a Tooltip.
Folder In order to keep track of larger projects you should group your POUs, data
types and global variables systematically in folders.
You can set up as many levels of folders as you want. If a plus sign is in
front of a closed folder symbol, then this folder contains objects
and/or additional folders. With a click on the plus sign the folder is opened
and the subordinated objects appear. With a click on the minus (which has
replaced the plus sign) the folder can be closed again. In the context menu
you find the commands "Expand nodes" and "Collapse nodes" with the
same functions.
With Drag&Drop you can move the objects as well as the folders within
their object type. For this select the object and drag it with pressed left
mouse button to the desired position.
Folders have no influence on the program, but rather serve only to structure
Note your project clearly.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"New Folder" With this command a new folder is inserted as a structural object. If a folder
has been selected, then the new one is created underneath it. Otherwise it
is created on the same level.
The context menu of the Object Organizer which contains this command
appears when an object or the object type has been selected and you have
pressed the right mouse button or <Shift>+<F10>.
"Expand nodes" "Collapse With the command Expand the objects are visibly unfolded which are loca-
nodes" ted in the selected object. With Collapse the subordinated objects are no
longer shown.
With folders you can open or close them with a double mouse click or by
pressing <Enter>.
The context menu of the Object Organizer which contains this command
appears when an object or the object type has been selected and you have
pressed the right mouse button or <Shift>+<F10>.
With this command the currently selected object (a POU, a data type or
global variables), or a folder with the subordinated objects is removed from
the Object Organizer and is thus deleted from the project.
For safety you are asked once more for confirmation.
If the editor window of the object was open, then it is automatically closed.
If you delete with the command "Edit" "Cut", then the object is parked on
the clipboard.
With this command you create a new object. The type of the object (POU,
data type or global variables) depends upon the selected register card in
the Object Organizer. Enter the name of the new object in the dialog box
which appears. Remember that the name of the object may not have alrea-
dy been used.
If you are dealing with a POU, then you must also choose the type of the
POU (Program, Function, or Function block)) and the language in which it
is to be programmed.
After confirmation of the entry, then the suitable entry window for the object
appears.
Dialog box for creating a
new POU
If, on the other hand, you use the command "Edit" "Paste", then the object
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
With this command you give a new name to the currently-selected object or
folder. Remember that the name of the object may not have already been
used.
If the editing window of the object is open, then its title is changed automa-
tically when the name is changed.
"Project" "Object Convert" This command can only be used with POUs. You can convert POUs from
the languages SFC, ST, FBD, LD, and IL into one of the three languages
IL, FBD, and LD.
For this the project must be compiled. Choose the language into which you
want to convert and give the POU a new name. Remember that the name
of the POU may not have already been used. Then press OK, and the new
POU is added to your POU list.
"Project" "Object Copy" With this command a selected object is copied and saved under a new
name. Enter the name of the new object in the resulting dialog box. Re-
member that the name of the object may not have already been used.
If, on the other hand, you used the command "Edit" "Copy", then the ob-
ject is parked on the clipboard, and no dialog box appears.
Dialog box for copying a
POU
With the command you load a selected object within the Object Organizer
into the respective editor. If a window with this object is already open, then
it gets a focus, is moved into the foreground and can now be edited.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
• type in the Object Organizer the first letter of the object name. Then a
dialog box opens in which all objects of the available object types with
this initial letter are shown. Select the desired object and click on the
button Open in order to load the object in its edit window. This option is
supported with the object type Resources only for global variables.
"Project" "Object Access With this command you open the dialog box for assigning access rights to
rights" the different user groups. The following dialog box appears:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Members of the user group 0 can now assign individual access rights for
each user group. There are three possible settings:
• No Access: the object may not be opened by a member of the user
group.
• Read Access: the object can be opened for reading by a member of the
user group but not changed.
• Full Access: the object may be opened and changed by a member of
the user group.
The settings refer either to the currently-selected object in the Object Orga-
nizer or, if the option Apply to all is chosen, to all POUs, data types and
resources of the project.
The assignment to a user group takes place when opening the project
through a password request if a password was assigned to the user group
0.
"Project" "View instance" With this command you can open and show single instances of function
blocks. The function block whose instance should be open must first be
selected in the Object Organizer before you can execute this command. In
the resulting dialog box you can choose the desired instance of this function
block.
Instances can be opened only after logging in! (Project was correctly com-
Note piled and sent with "Online" "Login" to the PLC).
"Project" "Show call tree" With this command you open a window which shows the call tree of the
object chosen in the Object Organizer. For this the project must be compi-
led (see "Rebuild all"). The call tree contains both calls for POUs and
references to data types.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Project" "Show cross refe- With this command you open a dialog box which makes possible the output
rence list" of all application points for a variable, address, or a POU. For this the pro-
ject must be compiled (see "Rebuild all").
Choose first the category Variable, Address, or POU and then enter the
name of the desired element. By clicking on the button Get References
you get the list of all application points. Along with the POU and the line or
network number, it is shown whether this point has read only access or full
access and whether it is a local or global variable.
When you select a line of the cross reference list and press the button Go
To or doubleclick on the line, then the POU is shown in its editor at the
corresponding point. In this way you can jump to all application points wi-
thout a time-consuming search.
In order to make processing easier, you can use the Send to message
window button to bring the current cross reference list into the message
window and from there change to the respective POU.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Project" "Show unused With this command a list of variables is shown which, to be sure, have be-
variables" en declared in the project but are not being used anywhere. For this the
project must be compiled (see "Rebuild all").
Unused variables of a
project
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Extras" With this command you can restore the current object to the last saved
Previous version state. The restored state is either that of the most recent manual save
("File" "Save") or that which was kept after the automatic save, depending
upon which version is most recent.
This command undoes the action which was most recently executed in the
currently-open editor window or in the Object Organizer.
With "Edit" "Redo" you can restore an action which you have undone.
The commands "Undo" and "Redo" apply to the current window. Each
window carries its own action list. If you want to undo actions in several
Note windows, then you must activate the corresponding window. When undoing
or redoing in the Object Organizer the focus must lie here.
The commands "Undo" and "Redo" apply to the current window. Each
Note window carries its own action list. If you want to undo actions in several
windows, then you must activate the corresponding window. When undoing
or redoing in the Object Manager must lie there.
"Edit" "Cut"
Symbol:
Shortcut: <Ctrl>+<X> or <Shift>+<Delete>
This command transfers the current selection from the editor to the clip-
board. The selection is removed from the editor.
In the Object Organizer this similarly applies to the selected object, whereby
not all objects can be deleted, e.g. the PLC configuration.
Remember that not all editors support the cut command, and that its use
can be limited in some editors.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In the FBD and LD editors the choice is a number of networks which are
indicated by a dotted rectangle in the network number field or a box with all
preceding lines, boxes, and operands.
In order to paste the content of the clipboard you use the command "Edit"
"Paste". In the SFC editor you can also use the commands "Extras"
"Insert parallel branch (right)" or "Extras" "Paste after".
In order to copy a selection onto the clipboard without deleting it, use the
command "Edit" "Copy".
In order to remove a selected area without changing the clipboard, use the
command "Edit" "Delete".
"Edit" "Copy"
Symbol: Shortcut: <Ctrl>+<C>
This command copies the current selection from the editor to the clipboard.
This does not change the contents of the editor window.
With the Object Organizer this similarly applies to the selected object,
whereby not all objects can be copied, e.g. the PLC configuration.
Remember that not all editors support copying and that it can be limited
with some editors.
For the type of selection the same rules apply as with "Edit" "Cut".
In the text editors (IL, ST, and declarations) the selection is a list of cha-
racters.
In the FBD and LD editors the choice is a number of networks which are
indicated by a dotted rectangle in the network number field or a box with all
preceding lines, boxes, and operands.
In the SFC editor you can also use the commands "Extras" "Insert paral-
lel branch (right)" or "Extras" "Paste after".
"Edit" "Paste"
Symbol: Shortcut: <Ctrl>+<V>
Pastes the content of the clipboard onto the current position in the editor
window. In the graphic editors the command can only be executed when a
correct structure results from the insertion.
With the Object Organizer the object is pasted from the clipboard.
Remember that pasting is not supported by all editors and that its use can
be limited in some editors.
The current position can be defined differently according to the type of edi-
tor:
With the text editors (IL, ST, Declarations) the current position is that of the
blinking cursor (a vertical line) which you place by clicking with the mouse).
In the FBD and LD editors the current position is the first network with a
dotted rectangle in the network number area. The contents of the clipboard
are inserted in front of this network. If a partial structure has been copied,
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In the SFC editor the current position is determined the selection which is
surrounded by a dotted rectangle. Depending upon the selection and the
contents of the clipboard, these contents are inserted either in front of the
selection or into a new branch (parallel or alternative) to the left of the se-
lection.
Deletes the selected area from the editor window. This does not change the
contents of the clipboard.
In the Object Organizer this applies likewise to the selected object, whereby
not all objects can be deleted, e.g. the PLC configuration.
For the type of selection the same rules apply as with "Edit" "Cut".
In the library manager the selection is the currently selected library name.
"Edit" "Find"
Symbol:
With this command you search for a certain text passage in the current
editor window. The Find dialog box opens. It remains opens until the button
Cancel is pressed.
In the field Find what you can enter the series of characters you are loo-
king for.
In addition, you can decide whether the text you are looking for Match
whole word only or not, or also whether Match case is to be considered,
and whether the search should proceed Up or Down starting from the cur-
rent cursor position.
The button Find next starts the search which begins at the selected positi-
on and continues in the chosen search direction. If the text passages is
found, then it is highlighted. If the passage is not found, then a message
announces this. The search can be repeated several times in succession
until the beginning or the end of the contents of the editor window has been
reached.
Remember that the found text can be covered up by the Find dialog box.
Find dialog box
With this command you execute a search with the same parameters as
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Edit" "Replace" With this command you search for a certain passage just as with the com-
mand "Edit" "Find", and replace it with another. After you have chosen the
command the dialog box for find and replace appears. This dialog box re-
mains open until the button Cancel or Close is pressed.
The button Replace replaces the current selection with the text in the field
Replace with.
The button Replace all replaces every occurrence of the text in the field
Find next after the current position with the text in the field Replace with.
This command provides a dialog box for choosing possible inputs at the
current cursor position in the editor window. In the left column choose the
desired input category, select the desired entry in the right column, and
confirm your choice with OK. This inserts your choice at this position.
The categories offered depend upon the current cursor position in the editor
window, i.e. upon that which can be entered at this point (e.g. variables,
operators, POUs, conversions, ...).
In some positions (e.g. in the watch list) multilevel variable names are ne-
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
cessary. At first the Input Assistant dialog box contains a list of all POUs
along with a single point for the global variables. After each POU name
there is a point. Doubleclicking with the mouse or pressing <Enter> opens a
list of the variables for a selected POU. Instances and data types can, when
appropriate, be opened again. By pressing OK you accept the selected
variable.
Some entries (e.g. global variables) are only brought up to date in the Input
Note Assistant after a compilation run.
After the incorrect compilation of a project this command can show the next
error. The corresponding editor window is activated and the incorrect place
is selected. At the same time in the message window the corresponding
error message is shown.
After the incorrect compilation of a project this command shows the pre-
vious error. The corresponding editor window is activated and the incorrect
place is selected. At the same time in the message window the correspon-
ding error message is shown.
"Online" "Login"
Symbol:
This command combines the programming system with the PLC (or starts
the simulation program) and changes into the online mode.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If the current project has not been compiled since opening or since the last
modification, then it is compiled now (as with "Project" "Rebuild all"). If
errors occur during compilation, then TwinCAT PLC Control does not
change into Online mode.
After a successful login all online functions are available. The current va-
lues are monitored for all visible variable declarations.
Use the "Online" "Logout" command to change from online back to off-
line mode.
You should especially verify that the interface number is correct. (If you
have set it to COM1, the cable should also be physically plugged into
COM1.) Furthermore, verify that the baud rates in the PLC and the Pro-
gram System agree with each other.
Error:
"The program has been modified! Should the new program be loaded?"
The project which is open in the editor is incompatible with the program
currently found in the PLC. Monitoring and debugging is therefore not pos-
sible. You can either choose "No," logout, and open the right project, or use
"Yes" to load the current project in the PLC.
"Online" "Logout"
Symbol:
"Online" "Download" This command loads the compiled project in the PLC.
"Online" "Run"
Symbol: Shortcut: <F5>
"Online" "Stop"
Symbol:
Stops the execution of the program in the PLC or in Simulation Mode bet-
ween two cycles.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Online" "Reset" If you have initialized the variables with a specific value, then this command
will reset the variables to the initialized value. All other variables are set at a
standard initialization (for example, integers at 0). As a precautionary mea-
sure, TwinCAT PLC Control asks you to confirm your decision before all
of the variables are overwritten.
Use the "Online" "Run" command to restart the program.
"Online"
"Toggle Breakpoint" Symbol: Shortcut: <F9>
This command sets a breakpoint in the present position in the active win-
dow. If a breakpoint has already been set in the present position, that bre-
akpoint will be removed.
In the Text Editors (IL, ST), the breakpoint is set at the line where the cur-
sor is located, if this line is a breakpoint position (recognizable by the dark-
gray color of the line number field). You can also click on the line number
field to set or remove a breakpoint in the text editors.
In FBD and LD, the breakpoint is set at the currently selected network. In
order to set or remove a breakpoint in the FBD or LD Editor, you can also
click on the network number field.
In SFC, the breakpoint is set at the currently selected step. In SFC you can
also use <Shift> with a doubleclick to set or remove a breakpoint.
If a breakpoint has been set, then the line number field or the network
number field or the step will be displayed with a light-blue background color.
If a breakpoint is reached while the program is running, the program will
stop, and the corresponding field will be displayed in a red background
color. In order to continue the program, use the "Online" "Run", "Online"
"Step in", or "Online" "Step Over" commands.
Online "Breakpoint Dialog This command opens a dialog box to edit breakpoints throughout the entire
Box" project. The dialog box also displays all breakpoints presently set.
In order to set a breakpoint, choose a POU in the POU combobox and the
line or the network in the Location combobox where you would like to set
the breakpoint; then press the Add button. The breakpoint will be added to
the list.
The Delete All button can be used to delete all the breakpoints.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If the last instruction has been reached, then the program will go on to the
next instruction in the POU.
A single step is executed. The program is stopped before the first instruc-
tion of a called POU.
This command executes a single PLC Cycle and stops after this cycle.
This command can be repeated continuously in order to proceed in single
cycles.
The Single Cycle ends when the "Online" "Run" command is executed.
Several variables can be set to specific values and afterwards written all at
once (cycle consistently) in the PLC.
With "Write Values", the values are written just once and can immediately
be written over again.
With "Force Values", the values continue to be written after each cycle
until this procedure is stopped with "Release Force".
This command ends the forcing of variables in the PLC. All forced variables
once again change their values normally.
"Online""Show Call Stack" You can run this command when the PLC stops at a breakpoint. You will be
given a dialog box with a list of the POUs currently in the Call Stack.
Example of a Call Stack
After you have selected a POU and have pressed the Go to button, the
selected POU is loaded in its editor, and it will display the line or network
being processed.
"Online" "Flow Control" If you have selected the flow control, then a check(á) will appear in front
of the menu item. Following this, every line or every network will be marked
which was executed in the last PLC Cycle.
The line number field or the network number field of the lines or networks
which just run will be displayed in green. An additional field is added in the
IL-Editor in which the present contents of the accumulator are displayed. In
the graphic editors for the Function Block Diagram and Ladder Diagram, an
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
additional field will be inserted in all connecting lines not transporting any
Boolean values. When these Out- and Inputs are verified, then the value
that is transported over the connecting line will be shown in this field. Con-
necting lines that transport only Boolean values will be shaded blue when
they transport TRUE. This enables constant monitoring of the information
flow.
"Online" "Simulation" Simulation Mode is only accessibly for Buscontroller BC and not for Twin-
CAT PC.
If Simulation Mode is chosen, then a check(á) will appear in front of the
menu item.
In the simulation mode, the user program runs on the same PC under Win-
dows. This mode is used to test the project. The communication between
the PC and Simulation Mode uses the Windows Message mechanism.
If the program is not in simulation mode, then the program will run on the
PLC. The status of this flag is stored with the project.
"Online" "Communication The parameters for transferring through the serial interface can be entered
Parameters" in a dialog box. It is important that these parameters agree with those ente-
red in the PLC .
Window set up
Under the "Window" menu item you will find all commands for managing
the windows. There are commands both for the automatic set up of your
window as well as for opening the library manager and for changing bet-
ween open windows. At the end of the menu you will find a list of all open
windows in the sequence they were opened. You can switch to the desired
window by clicking the mouse on the relevant entry. A check (á) will appear
in front of the active window.
"Window" "Tile Horizontal" With this command you can arrange all the windows horizontally in the work
area so that they do not overlap and will fill the entire work area.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Window" "Tile Vertical" With this command you can arrange all the windows vertically in the work
area so that they do not overlap and will fill the entire work area.
"Window" "Cascade" With this command you can arrange all the windows in the work area in a
cascading fashion, one behind another.
"Window" "Arrange Sym- With this command you can arrange all of the minimized windows in the
bols" work area in a row at the lower end of the work area.
"Window" "Close All" With this command you can close all open windows in the work area.
With this command you can open or close the message window with the
messages from the last compiling, verifying, or comparing procedure.
If the messages window is open, then a check (á) will appear in front of the
command.
"Help" "Contents and Index" With this command you can open the help topics window.
Under the Contents register card you will find the directory. The books can
be opened and closed using a doubleclick or the corresponding button.
Doubleclicking or activating the Show button on a highlighted topic will
display the topic in the main window of help or in the index window.
Click on the Index register card to look for a specific word, and click on the
Search register card to select a full-text search. Follow the instructions in
the register cards.
Main Help Window In the main help window topics are displayed with index entries listed below
them.
The following buttons available:
• Help topics opens the help topics window
• Back shows the help entry that was previously displayed
• Print opens the dialog box for printing
• << shows the help entry that comes prior in sequence to the present
entry
• >> shows the help entry that is next in sequence
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Index Window The index window contains explanations about the menu commands,
terms, or sequences.
The index window will always remain on the surface by default, unless the
help option is placed in the background in the main window of help.
The following buttons are available:
Index Window
You can use the <F1> key in an active window, in a dialog box, or above a
menu command. When you perform a command from the menu, the help
for the command called up at that time is displayed.
You can also highlight a text (for example, a key word or a standard func-
tion) and have the help displayed for that item.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The most important commands are found in the context menu (right mouse
button or <Ctrl>+<F10>).
DeclarationPart All variables to be used only in this POU are declared in the declaration part
of the POU. These can include: input variables, output variables , in-
put/output variables, local variables, retain variables, and constants. The
declaration syntax is based on the IEC1131-3 standard. An example of a
correct declaration of variables in TwinCAT PLC Control-Editor:
Declaration Editor
Input Variable Between the key words VAR_INPUT and END_VAR, all variables are de-
clared that serve as input variables for a POU. That means that at the call
position, the value of the variables can be given along with a call.
Example:
VAR_INPUT
in1:INT (* 1. Inputvariable*)
END_VAR
Output Variable Between the key words VAR_OUTPUT and END_VAR, all variables are
declared that serve as output variables of a POU. That means that these
values are carried back to the POU making the call. There they can be
answered and used further.
Example:
VAR_OUTPUT
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
out1:INT; (* 1. Outputvariable*)
END_VAR
Input and Output Variables Between the key words VAR_IN_OUT and END_VAR, all variables are
declared that serve as input and output variables for a POU.
Attention: With this variable, the value of the transferred variable is chan-
ged ("transferred as a pointer"). That means that the input value for such
variables cannot be a constant.
Example:
VAR_IN_OUT
inout1:INT; (* 1. Inputoutputvariable *)
END_VAR
Local Variables Between the keywords VAR and END_VAR, all of the local variables of a
POU are declared. These have no external connection; in other words, they
can not be manipulated from the outside.
Example:
VAR
loc1:INT; (* 1. Local Variable*)
END_VAR
Retain Variables Retain variables are identified by the key word RETAIN. These variables
maintain their value, even after a power failure. When the program is run
again, the stored values will be processed further. A practical example
would be an operations timer that recommences timing after a power failu-
re.
All other variables are newly initialized, either with their initialized values or
with the standard initializations.
Example:
VAR RETAIN
rem1:INT; (* 1. Retain variable*)
END_VAR
Constants Constants are identified by the key word CONSTANT. They can be decla-
red locally or globally.
Syntax:
VAR CONSTANT
<Identifier>:<Type> := <initialization>;
END_VAR
Example:
VAR CONSTANT
con1:INT:=12; (* 1. Constant*)
END_VAR
Keywords In all editors, all keywords are written in capital letters. Keywords may not
be used as variables.
Variables declaration A variables declaration has the following syntax:
<Identifier> {AT <Address>}:<Type> {:=<initialization>};
The variable identifier may not contain any blank spaces or special cha-
racters, may not be declared more than once and cannot be the same as
any of the keywords. Capitalization is not recognized which means that
VAR1, Var1, and var1 are all the same variable. The underscore character
is recognized in identifiers (e.g., "A_BCD" and "AB_CD" are considered two
different identifiers). An identifier may not have more than one underscore
character in a row. The first 32 characters are significant.
All declarations of variables and data type elements can include initializati-
on. They are brought about by the ":=" operator. For variables of elementary
types, these initializations are constants. The default-initialization is 0 for all
declarations.
Example:
var1:INT:=12; (* Integer variable with initial value of 12*)
If you wish to link a variable directly to a definite address, then you must
declare the variable with the keyword AT.
AT Declaration If you wish to link a variable directly to a definite address, then you must
declare the variable with the keyword AT. The advantage of such a proce-
dure is that you can assign a meaningful name to an address, and that any
necessary changes of an incoming or outgoing signal will only have to be
made in one place (e.g., in the declaration).
Examples:
counter_heat7 AT %QX0.0: BOOL;
lightcabinetimpulse AT %IX7.2: BOOL;
download AT %MX2.2: BOOL;
"Insert" You can use this command to open a list of all the keywords that can be
"Declarations keywords" used in the declaration part of a POU. After a keyword has been chosen
and the choice has been confirmed, the word will be inserted at the present
cursor position.
You also receive the list, when you open the Input Assistant and choose the
Declarations category.
"Insert" "Type" With this command you will receive a selection of the possible types for a
declaration of variables. You also receive the list when you access the Input
Assistant.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Syntax Coloring In the text editors and in the declaration editor, you receive visual support in
the implementation and declaration of variables. Errors are avoided, or
discovered more quickly, because the text is displayed in color.
Blue Keywords
Green Comments
Pink Boolean values (TRUE/FALSE)
Red Input error (for example, invalid time constant, keyword, written in
lower case,...)
Black Variables, constants, assignment operators, ...
Shortcut Mode The declaration editor for TwinCAT PLC Control allows you to use the
shortcut mode. This mode is activated when you end a line with
<Ctrl><Enter>
• If no type has been established through these rules, then the type is
BOOL and the last identifier will not be used as a type (Example 1.).
• Every constant, depending on the type of declaration, will turn into an
initialization or a string (Examples 2. and 3.).
• An address (as in %MD12) is extended around the AT... attribu-
te(Example 4.).
• A text after a semicolon (;) becomes a comment (Example 4.).
• All other characters in the line are ignored (e.g., the exclamation point in
Example 5.).
Examples:
Shortcut Declaration
A A: BOOL;
ABI2 A, B: INT := 2;
ST S 2; A string ST:STRING(2); (* A string *)
X %MD12 R 5 Real Number X AT %MD12: REAL := 5.0;(* Real Number *)
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
B! B: BOOL;
Autodeclaration If the Autodeclaration of the options dialog box , then a dialog box will
appear in all editors after the input of a variable that has not yet been decla-
red. With the help of this dialog box, the variable can now be declared.
With the help of the Class combobox, select whether you are dealing with a
local variable (VAR), input variable( (VAR_INPUT), output variable
(VAR_OUTPUT), input/output variable (VAR_INOUT), or a global variable
(VAR_GLOBAL).
With the CONSTANT and RETAIN options, you can define whether you are
dealing with a constant or a retain variable.
The variable name you entered in the editor has been entered in the Name
field, BOOL has been placed in the Type field. The ... button opens the
Input Assistent dialog which allows you to select from all possible types.
In the Initial Value field you can assign a value to the variable; otherwise
the standard initial value will be used.
In the Address field you can link a variable to the address (AT declaration)
If necessary, insert a Comment.
Line Numbers in the In offline mode, a simple click on a special line number will mark the entire
Declaration Editor text line.
In the online mode, a single click on a specific line number will open up or
close the variable in this line, in case a structural variable is involved.
Declarations as a Table If the Declarations as a table option is set in the options dialog box in the
Editor category, the declaration editor looks like a table. As in a card-index
box, you can select the register cards of the respective variable types and
edit the variables.
For each variable you are given the following entry fields.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Both of the display types of the declaration editor can be changed without
causing any problems. In the online mode, there are no differences for the
display.
Declaration Editor as a
Table
"Insert" "New Declaration" With this command you bring a new variable into the declaration table of
the declaration editor. If the present cursor position is located in an field of
the table, then the new variable will be pasted in the preceding line; other-
wise, the new variable is pasted at the end of the table. Moreover, you can
paste a new declaration at the end of the table by using the right arrow key
or the tab key in the last field of the table.
You will receive a variable that has "Name" located in the Name field, and
"Bool" located in the Type field, as its default setting. You should change
these values to the desired values. Name and type are all that is necessary
for a complete declaration of variables.
Declaration Editors in On- In online mode , the declaration editor changes into a monitor window. In
line Mode each line there is a variable followed by the equal sign (=) and the value of
the variable. If the variable at this point is undefined, three question marks
(???) will appear.
When a variable is open, all of its components are listed after it. A minus
sign appears in front of the variable. If you doubleclick again or press
<Enter>, the variable will be closed, and the plus sign will reappear.
The new value will turn red and will remain unchanged. If the "Online"
"Write values" command is given, then all variables are placed in the se-
lected list and are once again displayed in black.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If the "Online" "Force values" command is given, then all variables will be
set to the selected values, until the "Release force" command is given.
Comment User comments must be enclosed in the special character string "*" and "*".
Comments are allowed in all text editors at any preferred location. These
include all declarations, the IL and ST languages, and user-defined data
types.
In SFC you can enter comments for the step in the dialog box for editing
step attributes.
In Online mode, if you place the mouse pointer briefly above a variable,
then the type and, if necessary, comments about the variable will be dis-
played in a Tooltip.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The most important commands are found in the context menu (right mouse
button or <Ctrl>+<F10>).
The text editors use the following menu commands in special ways:
"Insert" "Operator" With this command all of the operators available in the current language
are displayed in a dialog box.
If one of the operators is selected and the list is closed with OK, then the
highlighted operator will be inserted at the present cursor position.
"Insert" "Operand" With this command all variables in a dialog box are displayed. You can
select whether you would like to display a list of the global, the local, or the
system variables.
If one of the operands is chosen, and the dialog box is closed with OK, then
the highlighted operand will be inserted at the present cursor position.
"Insert" "Function" With this command all functions will be displayed in a dialog box. You can
choose whether to have a list displaying user-defined or standard functions.
If one of the functions is selected and the dialog box is closed with OK,
then the highlighted function will be inserted at the current cursor position.If
the With arguments option was selected in the dialog box, then the neces-
sary input and output variables will also be inserted.
"Insert" "Function Block" With this command all function blocks are displayed in a dialog box. You
can choose whether to have a list displaying user-defined or standard func-
tion blocks.
If one of the function blocks is selected and the dialog box is closed with
OK, then the highlighted function block will be inserted at the current cursor
position. If the With arguments option was selected in the dialog box, then
the necessary input and output variables of the function block will also be
inserted.
The text editors in Online The online functions in the editors are set breakpoint and single step
mode processing (steps). Together with the monitoring, the user thus has the
debugging capability of a modern Windows standard language debugger.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In Online mode, the text editor window is vertically divided in halves. On the
left side of the window you will then find the normal program text; on the
right side you will see a display of the variables whose values were chan-
ged in the respective lines.
The display is the same as in the declaration part. That means that when
the PLC is running, the present values of the respective variables will be
displayed. Structured values (arrays, structures, or instances of function
blocks) are marked by a plus sign in front of the identifier.
By clicking the plus sign with the mouse or by pressing <Enter>, the varia-
ble is opened up or closed.
If you place the mouse pointer briefly above a variable, then the type and
the comment about the variable will be displayed in a Tooltip.
"Extras" With this command you can configure your monitoring window. In the text
"Monitoring Options" editors, the window is divided into two halves during monitoring. The pro-
gram is located in the left half. In the right half, all variables that are located
in the corresponding program line are monitored.
You can specify the Monitor Window Width and which Distance two vari-
ables should have in a line. An distance declaration of 1 corresponds, in
this case, to a line height in the selected font.
Breakpoint Positions Breakpoint PositionsSince in TwinCAT PLC Control several IL lines are
internally combined into a single C-code line, breakpoints can not be set in
every line. Breakpoint positions include all positions in a program at which
values of variables can change or where the program flow branches off.
(Exception: function calls. If necessary, a breakpoint in the function must be
set here.) At the positions lying inbetween, a breakpoint would not even
make sense, since nothing has been able to change in the data since the
preceding breakpoint position.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Breakpoint positions are marked by the display of the line number field in a
darker gray.
How do you set a In order to set a breakpoint, click the line number field of the line where you
breakpoint? want to set a breakpoint. If the selected field is a breakpoint position, then
the color of the line numbers field will change from dark gray to light blue,
and the breakpoint will be activated in the PLC.
Deleting Breakpoints Correspondingly, in order to delete a breakpoint, click on the line number
field of the line with the breakpoint to be deleted.
Setting and deleting of breakpoints can also be selected via the menu
("Online" "Toggle Breakpoint"), via the function key <F9>, or via the sym-
bol in the tool bar.
What happens at a break- If a breakpoint is reached in the PLC, then the screen will display the break
point? with the corresponding line. The line number field of the line where the PLC
is positioned will appear in red. The user program is stopped in the PLC.
In addition, with "Online" "Step over" or "Step in" you can cause the pro-
gram to run to the next breakpoint position. If the instruction where you are
located is a CAL command, or, if there is a function call in the lines up to
the next breakpoint position, then you can use "Step over" to bypass the
function call. With "Step in", you will branch to the open POU.
Line Number of the Text The line numbers of the text editor give the number of each text line of an
Editor implementation of a POU.
In Off-line mode, a simple click on a special line number will mark the entire
text line.
In Online mode, the background color of the line number indicates the bre-
akpoint status of every line:
• dark gray: This line is a possible position for a breakpoint.
• light blue: a breakpoint has been set in this line.
• red: The program has reached this point.
In Online mode, simply clicking the mouse will change the breakpoint status
of this line.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
IL Editor
All editors for POUs consist of a declaration part and a body. These are
separated by a screen divider.
The instruction list editor is a text editor with the usual capabilities of Win-
dows text editors. The most important commands are found in the context
menu (right mouse button or <Ctrl>+<F10>).
For information about the IL editor in Online mode, see Text Editors in On-
line Mode......,,,
For information about the language, see the instruction lists.
Flow Control With the "Online" "Flow control" command, an additional field in which
the accumulator contents is displayed is inserted in the IL editor on the left
side of every line.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
All editors for POUs consist of a declaration part and a body. These are
separated by a screen divider.
The editor for structured text is a text editor with the usual capabilities of
Windows text editors. The most important commands are found in the
context menu (right mouse button or <Ctrl>+<F10>).
For information about the ST editor in Online mode, read Text Editors in
Online Mode.
For information about the language, read the chapter Structured Text(ST).
Label Each network has a label that can optionally be left empty. This label is
edited by clicking the first line of the network, directly next to the network
number. Now you can enter a label, followed by a colon.
Network Comments Every network can be supplied with a multi-lined comment. In "Extras"
"Options", you can enter the maximum number of lines to be made availa-
ble for a network comment. This entry is made in the maximum comment
size array. (The default value here is 4.) You can also enter the number of
lines that generally should be reserved for comments (minimum comment
size). If, for example, the number 2 is entered, then, at the start of each
network there will be two empty lines after the label line. The default value
here is 0, which has the advantage of allowing more networks to fit in the
screen area.
The network editors in the In the FBD and the LD editors you can only set breakpoints for networks.
online mode The network number field of a network for which a breakpoint has been set,
is displayed in blue. The processing then stops in front of the network, whe-
re the breakpoint is located. In this case, the network number field is dis-
played in red. With single step processing (steps), you can jump from net-
work to network.
All values are monitored upon entering and exiting network POUs (Program
Organization Units).
The flow control is run with the "Online" "Flow control" command. Using
the flow control, you can view the present values that are being carried in
the networks over the connecting lines. If the connecting lines do not carry
Boolean values, then the value will be displayed in a specially inserted field.
If the lines carry Boolean values, then they will be shaded blue, in the event
that they carry TRUE. Therefore, you can accompany the flow of informati-
on while the PLC is running.
If you place the mouse pointer briefly above a variable, then the type and
the comment about the variable will be displayed in a Tooltip.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The function block diagram editor is a graphic editor. It works with a list of
networks, in which every network contains a structure that displays, re-
spectively, a logical or an arithmetical expression, the calling up of a func-
tion block, a jump, or a return instruction.
The most important commands are found in the context menu (right mouse
button or <Ctrl>+<F10>).
Cursor positions in FBD Every text is a possible cursor position. The selected text is on a blue
background and can now be changed.
You can also recognize the present cursor position by a dotted rectangle.
The following is a list of all possible cursor positions with an example:
2) Every input:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
6) Behind the outermost object on the right of every network ("last cursor
position," the same cursor position that was used to select a network):
How to set the cursor The cursor can be set at a certain position by clicking the mouse, or with
the help of the keyboard.
Using the arrow keys, you can jump to the nearest cursor position in the
selected direction at any time. All cursor positions, including the text fields,
can be accessed this way. If the last cursor position is selected, then the
<up> or <down> arrow keys can be used to select the last cursor position of
the previous or subsequent network.
"Insert" "Assignment"
Symbol: Shortcut: <Ctrl>+<A>
"Insert" "Jump"
Symbol: Shortcut: <Ctrl>+<L>
This command inserts a jump.
"Insert" "Return"
Symbol: Shortcut: <Ctrl>+<R>
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
(Cursor Position 4), directly before the selected line cross (Cursor Position
5), or at the end of the network (Cursor Position 6).
"Insert" "Operator"
Symbol: Shortcut: <Ctrl>+<O>
If the last cursor position of a network is selected (Cursor Position 6), then
the operator will be inserted following the last element. The first input of the
operator is linked to the branch to the left of the selected position.
All operator inputs that could not be linked will receive the text "???". This
text must be clicked and changed into the desired constant or variable.
"Insert" "Function" or
"Insert" "Function Block" Symbol: Shortcut: <Ctrl>+<F (Function)
The insertion then takes place analogous to the "Insert" "Operator" com-
mand. The assignment of inputs and outputs is also analogous. If there is a
branch to the right of an inserted function block, then the branch will be
assigned to the first output. Otherwise the outputs will remain unallocated.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Insert" "Input"
Symbol: Shortcut: <Ctrl>+<U>
This command inserts an operator input. With many operators, the number
of inputs may vary. (For example, ADD can have 2 or more inputs.)
In order to extend such an operator by an input, you need to select the input
in front of which you wish to insert an additional input (Cursor Position 1); or
you must select the operator itself (Cursor Position 3), if a lowest input is to
be inserted.
The inserted input is allocated with the text "???". This text must be clicked
and changed into the desired constant or variable. For this you can also
use the Input Assistant.
"Insert" "Output"
Symbol:
This command inserts an additional assignment into an existing as-
signment. This capability serves the placement of so-called assignment
combs; i.e., the assignment of the value presently located at the line to
several variables.
If you select the lined cross above an assignment (Cursor Position 5) or the
output directly in front of it (Cursor Position 4), then there will be another
assignment inserted after the ones already there.
The inserted output is allocated with the text "???". This text must be clik-
ked and changed into the desired variable. For this you can also use the
Input Assistant.
"Extras" "Negation"
Symbol: Shortcut: <Ctrl>+<N>
With this command you can negate the inputs, outputs, jumps, or RETURN
instructions. The symbol for the negation is a small circle at a connection.
If an input is selected (Cursor Position 2), then this input will be negated.
If an output is selected (Cursor Position 4), then this output will be negated.
If a jump or a return is marked, then the input of this jump or return will be
negated.
"Extras" "Set/Reset"
Symbol:
With this command you can define outputs as Set or Reset Outputs. A grid
with Set Output is displayed with [S], and a grid with Reset Output is dis-
played with [R].
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
An Output Set is set to TRUE, if the grid belonging to it returns TRUE. The
output now maintains this value, even if the grid jumps back to FALSE.
The output maintains its value, even if the grid jumps back to FALSE.
With multiple executions of the command, the output will alternate between
set, reset, and normal output.
With this command a selected POU is loaded into its editor (Cursor Positi-
on 3).
If you are dealing with a POU from a library, then the library manager is
called up, and the corresponding POU is displayed.
Cutting, Copying, Pasting, The commands used to "Cut", "Copy", "Paste", and "Delete" are found
and Deleting in FBD under the "Edit" menu item.
If a line cross is selected (Cursor Position 5), then the assignments, jumps,
or RETURNS located below the crossed line will be cut, deleted, or copied.
Otherwise, the entire branch located in front of the cursor position will be
cut, deleted, or copied.
After copying or cutting, the deleted or copied part is located on the clip-
board and can now be pasted, as desired.
In order to do so, you must first select the pasting point. Valid pasting points
include inputs and outputs.
Otherwise, the entire branch located in front of the pasting point will be
replaced by the contents of the clipboard.
In each case, the last element pasted is connected to the branch located in
front of the pasting point.
The following problem is solved by cutting and pasting: A new operator is
pasted in the middle of a network. The branch located on the right of the
Note operator is now connected with the first input, but must be connected with
the second input. You can now select the first input and perform the com-
mand "Edit" "Cut". Following this, you can select the second input and
perform the command "Edit" "Paste". This way, the branch is dependent
on the second input.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The Function Block In the Function Block Diagram, breakpoints can only be set to networks. If a
Diagram in the Online breakpoint has been set to a network, then the network numbers field will
Mode be displayed in blue. The processing then stops in front of the network whe-
re the breakpoint is located. In this case, the network numbers field will
become red. Using stepping (single step), you can jump from network to
network.
The present value is displayed for every variable that is tied to a network
element (function, program, function block instance, or operator) as input.
The flow control is run with the "Online" "Flow control" command. Using
the flow control, you can view the present values that are being carried in
the networks over the connecting lines. If the connecting lines do not carry
Boolean values, then the value will be displayed in a specially inserted field.
If the lines carry Boolean values, then they will be shaded blue in the event
that they carry TRUE. By this means, you can accompany the flow of infor-
mation while the PLC is running.
If you place the mouse pointer briefly above a variable, then the type and
the comment about the variable will be displayed in a Tooltip.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
All editors for POUs consist of a declaration part and a body. These are
separated by a screen divider.
The LD editor is a graphic editor. The most important commands are found
in the context menu (right mouse button or <Ctrl>+<F10>).
Cursor Positions in the LD The following locations can be cursor positions, in which the function block
Editors and program accessing can be handled as contacts. POUs with EN inputs
and other POUs connected to them are treated the same way as in the
Function Block Diagram. Information about editing this network part can be
found in Chapter 0 on the FBD Editor.
3. Every Coil
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The Ladder Diagram uses the following menu commands in a special way:
"Insert" "Contact"
Symbol: Shortcut: <Ctrl>+<O>
Use this command in the LD editor in order to insert a contact in front of the
marked location in the network.
If the marked location is a coil (Cursor Position 3) or the connecting line
between the contacts and the coils (Cursor Position 4), then the new con-
tact will be connected serially to the previous contact connection.
The contact is preset with the text "???". You can click on this text and
change it to the desired variable or the desired constant. For this you can
also use the Input Assistant.
"Insert" "Coil"
Symbol: Shortcut: <Ctrl>+<L>
You can use this command in the LD editor to insert a coil in parallel to the
previous coils.
If the marked position is a connection between the contacts and the coils
(Cursor Position 4), then the new coil will be inserted as the last. If the mar-
ked position is a coil (Cursor Position 3), then the new coil will be inserted
directly above it.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The coil is given the text "???" as a default setting. You can click on this
text and change it to the desired variable. For this you can also use the
Input Assistant.
POUs with EN Inputs If you want to use your LD network as a PLC for calling up other POUs ,
then you must merge a POU with an EN input. Such a POU is connected in
parallel to the coils. Beyond such a POU you can develop the network
further, as in the Function Block Diagram. You can find the commands for
insertion at an EN POU under the menu item "Insert" "Insert at Blocks".
If a POU has been created once already with EN input, then this POU can
be used to create a network. This means that data from usual operators,
functions, and function blocks can flow in an EN POU and an EN POU can
carry data to such usual POUs.
"Insert" "Operator with EN" Use this command to insert an operator with EN input into a LD network.
The marked position must be the connection between the contacts and the
coils (Cursor Position 4) or a coil (Cursor Position 3). The new operator is
inserted in parallel to the coils and underneath them; it contains initially the
designation AND. If you wish, you can change this designation to another
one. For this you can also use the Input Assistant.
"Insert" "Function Block With this command you can insert a Function Block with EN input into a LD
with EN" network.
The position marked must be the connection between the contacts and the
coils (Cursor Position 4) or a coil (Cursor Position 3). The new function
block is inserted in parallel to the coils, below them. From the Input Assi-
stant dialog box that appears, you can select whether to insert a user-
defined, or a standard (default) function block.
"Insert" "Function with EN" With this command you can insert a function with EN input into an LD net-
work.
The position marked must be the connection between the contacts and the
coils (Cursor Position 4) or a coil (Cursor Position 3). The new function is
inserted in parallel to the coils, below them. From the Input Assistant dialog
box that appears, you can select whether to insert a user-defined, or a
standard function block.
"Insert" "Insert at Blocks" With this command you can insert additional elements into a POU that has
already been inserted (also a POU with EN input). The commands below
this menu item can be executed at the same cursor positions as the corre-
sponding commands in the Function Block Diagram (See Chapter 5.7).
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
With Operator you can add a new operator to the POU, whose output is
deposited onto the selected input.
With Assignment you can add an assignment to the selected input or out-
put.
With Function Block you can add a function block to the selected input.
"Insert" "Jump" With this command you can insert a parallel jump in the selected LD editor,
in parallel, at the end of the previous coils. If the incoming line delivers the
value "On", then the jump will be executed to the indicated label.
The marked position must be the connection between the contacts and the
coils (Cursor Position 4) or a coil (Cursor Position 3).
The jump is present with the text "???". You can click on this text and make
a change in the desired label.
"Insert" "Return" In the LD editor, you can use this command to insert a Return instruction in
parallel at the end of the previous coils. If the incoming line delivers the
value "On," then the processing of the POU in this network is broken off.
The marked position must be the connection between the contacts and the
coils (Cursor Position 4) or a coil (Cursor Position 3).
"Extras" "Paste after" Use this command in the LD editor to insert the contents of the clipboard as
a serial contact after the marked position. This command is only possible if
the contents of the clipboard and the marked position are networks compri-
sed of contacts.
Use this command in the LD editor to insert the contents of the clipboard as
parallel contact below the marked position. This command is only possible
if the contents of the clipboard and the marked position are networks com-
prised of contacts.
"Extras" "Paste above" Use this command in the LD editor to insert the contents of the clipboard as
parallel contact above the marked position. This command is only possible
if the contents of the clipboard and the marked position are networks com-
prised of contacts.
"Extras" "Negate"
Symbol: Shortcut: <Ctrl>+<N>
Between the parentheses of the coil or between the straight lines of the
contact, a slash will appear ((/) or |/|). If there are jumps, returns, or inputs
or outputs of EN POUs , a small circle will appear at the connection, just as
in the FBD editor.
The coil now writes the negated value of the input connection in the re-
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If a jump or a return is marked, then the input of this jump or return will be
negated.
"Extras" "Set/Reset" If you execute this command on a coil, then you will receive a Set Coil.
Such a coil never overwrites the value TRUE in the respective Boolean
variable. This means that once you have set the value of this variable to
TRUE, it will always remain at TRUE. A Set Coil is designated with an "S" in
the coil symbol.
If you execute this command once again, then you will be given a Reset
Coil. Such a coil never overwrites the value FALSE in the respective Boole-
an variable. This means that once you have set the value of this variable to
FALSE, it will always remain at FALSE. A Reset Coil is designated with an
"R" in the coil symbol.
If you execute this command repeatedly, the coil will alternate between set,
reset and normal coil.
The Ladder Diagram in the In Online mode, the contacts and coils in the Ladder Diagram that are in
Online Mode the "On" state are colored blue. Likewise, all lines over which the "On" is
carried are also colored blue. At the inputs and outputs of function blocks,
the values of the corresponding variables are indicated.
Breakpoints can only be set on networks; by using stepping, you can jump
from network to network.
If you place the mouse pointer briefly above a variable, then the type and
the comment about the variable will be displayed in a Tooltip.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Sequential Function Chart All editors for POUs consist of a declaration part and a body. These are
Editor with an opened separated by a screen divider.
Action
The sequential function chart editor is a graphic editor. The most important
commands are found in the context menu (right mouse button or
<Ctrl>+<F10>).
For information about the sequential function chart, see Sequential Func-
tion Chart.
The editor for the sequential function chart must agree with the particulars
of the SFC. In reference to these, the following menu items will be of ser-
vice.
Marking Blocks in the SFC A marked block is a bunch of SFC elements that are enclosed in a dotted
rectangle. (In the example somewhat above, the step is marked Shift1.)
Observe that all commands can only be executed, if they do not contradict
the conventions of the language.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
This command inserts an alternative branch in the SFC editor as the left
branch of the marked block. For this the marked block must both begin and
end with a transition. The new branch is then made up of one transition.
"Insert" "Jump"
Symbol: Shortcut: <Ctrl>+<U>
This command inserts a jump in the SFC editor at the end of the branch, to
which the marked block belongs. For this the branch must be an alternative
branch.
"Insert" "Transition-Jump"
Symbol:
"Insert" "Add Entry-Action" With this command you can add an entry-action to a step. An entry-action
is only executed once, right after the step has become active. The entry-
action can be implemented in a language of your choice.
A step with an entry-action is designated by an "E" in the bottom left corner.
An entry-action cannot be defined to an IEC step.
"Insert" "Add Exit-Action" With this command you can add an exit-action to a step. An exit-action is
only executed once, before the step is deactivated. The exit-action can be
implemented in a language of your choice.
"Extras" "Paste Parallel This command pastes the contents of the clipboard as a right parallel
Branch (right)" branch of the marked block. For this the marked block must both begin and
end with a step. The contents of the clipboard must, likewise, be an SFC
block that both begins and ends with a step.
"Extras" "Paste After" This command pastes the SFC block on the clipboard after the first step or
the first transition of the marked block. (Normal copying pastes it in front of
the marked block.) This will now be executed, if the resulting SFC structure
is correct, according to the language norms.
"Extras" With this command you can delete the actions of the first step of the mar-
"Clear Action/Transition" ked block or of the transitions body of the first transition.
If, during a step, you implement either only the action, the entry-action, or
the exit-action, then the same will be deleted by the command. Otherwise a
dialog box appears, and you can select which action or actions are to be
deleted.
If the cursor is located in the action of an IEC step, then only this associati-
on will be deleted. If an IEC step with an associated action is selected, then
this association will be deleted. During an IEC step with several actions, a
selection dialog box will appear.
"Extras" "Step Attributes" With this command you can open a dialog box in which you can edit the
attributes for the marked step.
You can take advantage of three different entries in the step attribute dialog
box. Under Minimum Time, you enter the minimum length of time that the
processing of this step should take. Under the Maximum Time, you enter
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
the maximum length of time that the processing of this step should take.
Note that the entries are of the TIME type. The manner of writing described
in Appendix C will be valid.
Under Comment you can insert a comment to the step. With "Extras"
"Options" you can then adjust whether, in the SFC editor, the comments
or the time setting for the steps should be displayed. On the right, next to
the step, either the comment or the time setting will appear.
If the maximum time is exceed, SFC flags are set for the user to make
inquiries.
The example shows a step whose execution should last at least two, and at
the most, ten seconds. In Online mode, there is, in addition to these two
times, a display of how long the step has already been active.
SFC Flags In the SFC, if a step is active longer than set out in its attributes, then a few
special flags are set. Beyond that there are other variables which you can
define in order to control the sequence in the sequential function chart. In
order to use the flags, you must declare them somewhere that can be glo-
bal or local as input or output variables.
SFCInit: This variable is likewise of the BOOL type. If this variable is TRUE,
then the sequential function chart will be set back to the Init-step. The Init-
step will remain active, as long as the variable is TRUE. Only when SFCInit
is again set to FALSE will the POU once again be processed normally.
SFCPause: This variable is of type BOOL. When it is TRUE, the SFC-POU
paused in the last performed step. This step stays active as long as this
variable is TRUE.
If a timing fault has already occurred, and the SFCError variable has not
been reset again, no further timing fault will be registered.
"Extras""Time Overview" With this command you can open a window in which you can edit the time
settings of your SFC steps:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In the time boundaries overview, all steps of your SFC POU are displayed.
If you have entered a time boundary for a step, then the time boundary is
displayed to the right of the step (first, the lower limit, then the upper limit).
You can also edit the time boundaries. To do so, click on the desired step
in the overview. The name of the step is then shown below in the window.
Go to the Minimum Time or Maximum Time field, and enter the desired
time boundary there. If you close the window with OK, then all of the chan-
ges will be stored.
In the example, steps 2 and 6 have a time boundary. Shift1 lasts at least
two, and at most, ten seconds. Shift2 lasts at least seven, and at most,
eight seconds.
"Extras" "SFC-Overview" With this command you are given a reduced display of the active SFC
POU. A check appears before the menu item. For better orientation you
can display the names of the steps, transitions, and jumps in tooltips by
placing the mouse pointer on an element.
In order to change to the normal SFC display, set a marking and then either
press <Enter> or select the command once again, and the change will take
place.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
SFC Overview
"Extras" "Options" With this command you open a dialog box in which you can set different
options for your SFC POU.
In the SFC Options dialog box you can undertake five entries. Under Step
Height, you can enter how many lines high an SFC step can be in your
SFC editor. 4 is the standard setting here. Under Step Width, you can
enter how many columns wide a step should be. 6 is the standard setting
here. You can also preset the Display at Step. With this, you have three
possibilities: You can either have Nothing displayed, or the Comment, or
the Time Limits. The last two are shown the way you entered them in "Ex-
tras" "Step Attributes".
"Extras" "Associate Action" With this command actions and Boolean variables can be associated with
IEC steps.
To the right of, and next to the IEC step, an additional divided box is atta-
ched, for the association of an action. It is preset in the left field with the
qualifier "N" and the name "Action." Both presets can be changed. For this
you can use the Input Assistant.
New actions for IEC steps are created in the Object Organizer for an SFC
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Project" "Add Action" With this command you can generate an action for the selected SFC POU
in the Object Organizer. This action can be utilized with the IEC steps of
this POU. In the dialog box that appears, choose the name of the action
and the language in which the action is to be implemented.
The new action is attached under its SFC POU. A plus sign now appears in
front of the SFC POU. By simply clicking on the plus sign, you will see the
action object appear, along with a minus sign in front of the POU. By clik-
king on the minus sign again, you will see a plus sign reappear, and the
actions will no longer be displayed. This can also be accessed with the
"Expand Node" and "Collapse Node" commands in the context menu.
If you doubleclick the action or press <Enter>, an action for editing will be
loaded into its editor.
The Sequential Function With the sequential function chart editor in Online mode, the currently-
Chart in the Online Mode active steps will be displayed as blue steps (black in the example). If you
have set it under "Extras" "Options", then the time management is de-
picted next to the steps. Under the lower and upper bounds that you have
set, a third time indicator will appear from which you can read how long the
step has already been active.
In the picture above the step depicted has already been active 8 seconds
and 410 milliseconds. The step must, however, be active for at least 7 mi-
nutes before the step will be left.
If several steps are active in a parallel branch, then the active step whose
action will be processed next is displayed in red.
If IEC steps have been used, then all active actions in Online mode will be
displayed in blue.
SFC also includes support for stepping a step at a time ("Step Over" "On-
line"). With this stepping, the program will always proceed to the next step
whose action is to be executed.
With "Online" "Step in" you can step into actions or transitions. Within the
transitions or actions, all debugging capabilities of the corresponding editor
are at the user’s disposal.
If you place the mouse pointer briefly above a variable, then the type and
the comment about the variable will be displayed in a Tooltip.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The Resources
Overview of the Resources
In the Resources register card of the Object Organizer, there are objects
for configuring and organizing your project and for keeping track of the
values of the variables:
• Global Variables that can be utilized in the entire project
• PLC Configuration for configuring your hardware
• Task Configuration for controlling your program control via tasks
• Sampling Trace for graphic logging of variable values
• Watch and Receipt Manager for indicating and presetting variable va-
lues
Resources
Global Variables
Editing Global Variables In the Object Organizer, you will find three objects in the Resources regi-
ster card in the Global Variables folder (default names of the objects in
parentheses).
• Global Variables List (Global Variables)
All variables defined in these objects are recognized throughout the project.
If the global variables folder is not opened up (plus sign in front of the fol-
der), you can open it with a doubleclick <Enter> in the line.
Several Variables Lists If you have declared a large number of global variables, and you would like
to structure your global variables list better, then you can create further
variables lists.
In the Object Organizer, select the Global Variables folder or one of the
existing objects with global variables. Then execute the "Project"
"Object Add" command. Give the object that appears in the dialog box a
corresponding name. With this name an additional object will be created
with the key word VAR_GLOBAL.
Global Variables Normal global variables are defined in an object between the key words
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The editor for global variables functions like the declaration editor.
Syntax:
VAR_GLOBAL
(*Declaration of Variables *)
END_VAR
Global retain variables additionally receive the key word RETAIN.
Syntax:
VAR_GLOBAL RETAIN
(*Declaration of Variables *)
END_VAR
Global constants additionally receive the key word CONSTANT.
Syntax:
VAR_GLOBAL CONSTANT
(*Declaration of Variables *)
END_VAR
Document Frame If a project is to receive multiple documentations, perhaps with German and
English comments, or if you want to document several similar projects that
use the same variable names, then you can save yourself a lot of work by
creating a docuframe with the "Extras" "Make Docuframe File" com-
mand.
The created file can be loaded into a desired text editor and can be edited.
The file begins with the DOCUFILE line. Then a listing of the project varia-
bles follows in an arrangement that assigns three lines to each variable: a
VAR line that shows when a new variable comes; next, a line with the name
of the variable; and, finally, an empty line. You can now replace this line by
using a comment to the variable. You can simply delete any variables that
you are unable to document. If you want, you can create several document
frames for your project.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
In order to use a document frame, give the "Extras" "Link Docu Frame"
command. Now if you document the entire project, or print parts of your
project, then in the program text, there will be an insertion of the comment
produced in the docuframe into all of the variables. This comment only
appears in the printout!
"Extras" "Make Docuframe Use this command to create a document frame. The command is at your
File" disposal, whenever you select an object from the global variables.
A dialog box will open for saving files under a new name. In the field for the
name file, the *.txt extension has already been entered. Select a desired
name. Now a text file has been created in which all the variables of your
project are listed.
"Extras" "Link Docu File" With this command you can select a document frame.
The dialog box for opening files is opened. Choose the desired document
frame and press OK. Now if you document the entire project, or print parts
of your project, then in the program text there will be an insertion of the
comment produced in the docuframe into all of the variables. This comment
only appears in the printout!
PLC Configuration
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If you want to run the plc program on a BCxx00 you can choose wether you
want load the program
½ via AMS (fieldbus) (only BC3100) or
½ via serial interface (BC8010 or BC3100).
Task Configuration
The task configuration is found as an object in the Resources register
card in the Object Organizer. The task editor contains a series of tasks.
The task declaration consists of the name of the task, an entry for the prio-
rity the task is to have, and an entry for the condition under which the task
is to be executed. This requirement must be a time interval, according to
which the task is to be executed.
For each task you can now specify one program that will be started by the
task. If the task is executed in the present cycle, then this program will be
processed.
Which task is being proces- • At the heading of the task configuration are the words "Task Configurati-
sed? on."If a plus sign is located before the words, then the sequence list is
closed. By doubleclicking on the list or pressing <Enter>, you can open
the list. A minus sign now appears.By doubleclicking once more, you can
close the list again.
• For every task, there is a list of program call-ups attached. Likewise, you
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Working in the task configu- With this command you can insert a new task into the task configuration.
ration
If a task is selected, then the "Insert Task" command will be at your dispo-
sal. The new task will be inserted in front of the cursor. If the words Task
Configuration are selected, then the "Append Task" is available, and the
new task will be appended to the end of the existing list.
The dialog box will open for you to set the task attributes.
Dialog Box for Setting Task In the dialog box you can enter the desired attributes: the Name; the Priori-
Attributes ty (a number between 0 and 3, with the following validities: 0 has the hig-
hest, and, 3, the lowest priority); the Interval after which the task should be
started again. With the Select... button, you can open the Input Assistant to
select from the declared variables.
With these commands you will open the dialog box for entering a program
call to a task in the task configuration.
With Insert Program Call", the new program call is inserted in front of the
cursor, and with "Append Program Call", the program call is appended to
the end of the existing list.
Depending on the element selected, you can use this command in the task
configuration to open either the dialog box for setting the task attributes
(see "Insert Task") or the dialog box for entering the program call (see
"Insert Program Call).
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
If the cursor is located at the task entry, and there is no list of program calls
appended to the task entry, then you open the dialog for setting the attrib-
utes by doubleclicking on the entry or by pressing <Enter>.
If the cursor is located on an entry for a program call, then you can also
open the dialog box for editing the program entry by doubleclicking on the
entry.
"Extras" "Edit Entry" With this command a debugging task can be set in Online mode in the task
configuration. The text [DEBUG] will appear after the set task.
The debugging capabilities apply, then, only to this task.In other words, the
program only stops at a breakpoint if the program is gone through by the
set task.
Since the size of the trace buffer in the PLC has a fixed value, in the event
of very many or very wide variables (DWORD), fewer values can be traced.
With this command you will be given the dialog box for entering the varia-
bles to be traced, as well as diverse trace parameters for the Sampling
Trace.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Extras"
"Trace Configuration"
A variable is deleted from the list when you select the variable and then
press the Delete button.
With the Time per Scan field, you can specify the time between two scans
in milliseconds. The default setting "0" means one scanning procedure per
cycle.
In the Trigger Variable field, you can enter Boolean variables. The Input
Assistant can also be used here. The variable describes the break requi-
rement of the trace. If Trigger on Rising Edge was selected in the trace
definition (as in the above example), then the trigger event will enter after a
rising edge in the trigger variables; otherwise, after a falling edge.
After the trigger event, a certain number of values will be traced, and then
the trace will break off. This number can be entered as a percentage in the
Percentage of Values recorded after the Trigger field.
If the Trigger Variable array is empty, then the sampling trace must be
broken explicitly ("Extras" "Stop Trace").
Symbol:
With this command the created trace configuration is loaded into the PLC.
It is kept there until the registered break requirement of the trace has been
fulfilled, or until the trace has been stopped ("Extras" "Stop Trace").
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
With this command you can start the sampling trace in the PLC.
With this command the present trace buffer is read from the PLC, and the
values of the selected variables are displayed.
"Extra" "Read Trace" With this command the present trace buffer is read automatically from the
PLC, and the values are continuously displayed.If the trace buffer is auto-
matically read, then a check (á) is located before the menu item.
This command stops the Sampling Trace in the PLC. Before a new trace,
the trace definition must be loaded, and the trace must be run again.
"Extra" "Stop Trace" The comboboxes to the right, next to the window for displaying curves trace
variables defined in the trace configuration. If a variable is selected from the
list, then after the trace buffer has been read the variable will be displayed
in the corresponding color (Var 0 green, etc.). Variables can also be selec-
ted if curves are already displayed.A maximum of up to eight variables can
be observed simultaneously in the trace window.
Display of the
Sampling Trace If a trace buffer is loaded, then the values of all variables to be displayed
will be read out and displayed. If no scan frequency has been set, then the
Sampling Trace of Eight X axis will be inscribed with the continuous number of the traced value. The
Different Variables without status indicator of the trace window (first line) indicates whether the trace
a Trigger buffer is full and when the trace is completed.
If a value for the scan frequency was specified, then the x axis will specify
the time of the value. The time is assigned to the "oldest" traced value. In
the example, e.g., the values for the last 25 seconds are indicated.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The Y axis is inscribed with integer values. The scaling is laid out in a way
that allows the lowest and the highest value to fit in the viewing area. In the
example, Var5 has taken on the lowest value of 6, and the highest value of
11: hence the setting of the scale at the left edge.
A memory that has been read will be preserved until you change the project
or leave the system.
With this command a vertical line will appear in the sampling trace. You can
use the mouse or the arrow key to move this line to the right or left. By
pressing <Ctrl>+<left> or <Ctrl>+<right>, you can increase the speed of the
movement.
Above the graphic window you can read the present x position of the cur-
sor. In addition Var0,.Var1, ... ,VarN, the value of the respective variable is
displayed.
If the mouse pointer is located in the graphics window and the left mouse
button is pressed, then the cursor will likewise be displayed.
"Extras" "Cursor Mode" With this command you can alternate between single-channel and multi-
channel display of the sampling trace. In the event of a multi-channel dis-
play, there is a check (á) in front of the menu item.
The multi-channel display has been preset. Here the display window is
divided into as many as eight display curves. For each curve the maximum
and the minimum value are displayed at the edge.
In a single-channel display, all curves are displayed with the same scaling
factor and are superimposed. This can be useful when displaying curve
abnormalities.
"Extras" "Multi Channel" With this command you can change the preset Y scaling of a curve in the
trace display.
In the dialog box specify the number of the desired curve (Channel) and
the new maximum (maximum y scale) and the new minimum value (mi-
nimum y scale) on the y axis.
By doubleclicking on a curve you will also be given the dialog box. The
channel and the former value are preset.
Symbol:
"Extras" "Stretch"
With this command the values shown for the sampling trace are com-
pressed; i.e., after this command you can view the progression of the trace
variables within a larger time frame. A multiple execution of the command
is possible.
With this command you can save a sampling trace. The dialog box for sa-
"Extras" "Compress" ving a file is opened. The file name receives the extension "*.trc".
The saved sampling trace can be loaded again with "Extras" "Load Tra-
ce".
"Extras" "Save Trace" With this command a saved sampling trace can be reloaded. The dialog
box is opened for opening a file. Select the desired file with the "*.trc" ex-
tension.
"Extras" "Load Trace" With this command you can save a sampling trace in an ASCII-file. The
dialog box is opened for saving a file. The file name receives the extension
"*.txt". The values are deposited in the file according to the following sche-
me:
The appertaining variable names are displayed next to one another in the
third line, according to the sequence (PLC_PRG.COUNTER,
PLC_PRG.LIGHT1).
With the help of the Watch and Receipt Manager you can view the values
of selected variables. The Watch and Receipt Manager also makes it pos-
sible to preset the variables with definite values and transfer them as a
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
group to the PLC ("Write Receipt"). In the same way, current PLC values
can be read into and stored in the Watch and Receipt Manager ("Read
Receipt"). These functions are helpful, for example, for setting and ente-
ring of control parameters.
All watch lists created ("Insert" "New Watch List") are indicated in the left
column of the Watch and Receipt Manager.These lists can be selected with
a mouse click or an arrow key. In the right area of the Watch and Receipt
Manager the variables applicable at any given time are indicated.
In order to work with the Watch and Receipt Manager, open the object for
the Watch and Receipt Manager in the Resources register card in the
Object Organizer.
Watch and Receipt In Offline Mode, you can create several watch lists in the Watch and Re-
Manager ceipt Manager using the "Insert" "New Watch List".
For inputting the variables to be watched, you can call up a list of all varia-
bles with the Input Assistant, or you can enter the variables with the key-
board, according to the following notation:
<POUName>.<Variable Name>
With global variables, the POU Name is left out. You begin with a point.
The variable name can, once again, contain multiple levels. Addresses can
be entered directly.
The variables in the watch list can be preset with constant values. That
means that in Online mode you can use the "Extras" "Write Receipt" com-
mand to write these values into the variables. To do to do must use := to
assign the constant value of the variable:
Example:
PLC_PRG.TIMER:=50
In the example, the PLC_PRG.COUNTER variable is preset with the value
6
With this command a new watch list can be inserted into the Watch and
Receipt Manager. Enter the desired name for the watch list in the dialog
box that appears.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Insert" "New Watch List" With this command you can change the name of a watch list in the Watch
and Receipt Manager.
In the dialog box that appears, enter the new name of the watch list.
"Extras" "Rename Watch With this command you can save a watch list. The dialog box for saving a
List" file is opened. The file name is preset with the name of the watch list and is
given the extension "*.wtc".
The saved watch list can be loaded again with "Extras" "Load Watch
List".
"Extras" "Save Watch List" With this command you can reload a saved watch list. The dialog box is
opened for opening a file. Select the desired file with the "*.wtc" extension.
In the dialog box that appears, you can give the watch list a new name. The
file name is preset without an extension.
With "Extras" "Save Watch List", you can save a watch list
"Extras" "Load Watch List" In Online mode, the values of the entered variables are indicated.
Structured values (arrays, structures, or instances of function blocks) are
marked by a plus sign in front of the identifier. By clicking the plus sign with
the mouse or by pressing <Enter>, the variable is opened up or closed.
In order to input new variables, you can turn off the display by using the
"Extra" "Active Monitoring" command. After the variables have been
entered, you can use the same command again to activate the display of
the values.
In the Offline Mode you can preset variables with constant values
(through inputting := <value> after the variable). In the Online Mode, these
values can now be written into the variables, using the "Extras" "Write Re-
ceipt" command.
With the "Extras" "Read Receipt" command you can replace the presetting
of the variable with the present value of the variable.
Only those values the watch list are loaded which was selected in the
Watch and Receipt Manager!
With this command at the Watch and Receipt Manager in the Online mode,
the display is turned on or off. If the display is active, a check (á) will ap-
Note pear in front of the menu item.
In order to enter new variables or to preset a value (see Offline Mode), the
display must be turned off through the command. After the variables have
been entered, you can use the same command again to activate the display
of the values.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Extra" "Monitoring Active" With this command in the Online Mode of the Watch and Receipt Manager,
you can write the preset values (see Offline Mode) into the variables.
"Extras" "Write Receipt" With the command, in the Online Mode of the Watch and Receipt Manager,
you can replace the presetting of the variables (see Offline Mode) with the
present value of the variables.
Example:
PLC_PRG.Counter [:= <present value>] = <present value>
"Extras" "Read Receipt" In the Watch and Receipt Manager, you can also "Force values" and
"Write values". If you click on the respective variable value, then a dialog
box opens, in which you can enter the new value of the variable. Changed
variables appear in red in the Watch and Receipt Manager.
Force values
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Library Manager
Library Manager The library manager shows all libraries that are connected with the present
project. The POUs, data types, and global variables of the libraries can be
used the same way as user-defined POUs, data types, and global varia-
bles.
Library Manager
Using the Library Manager The window of the library manager is divided into three or four areas by
screen dividers. The libraries attached to the project are listed in the upper
left area.
In the area below that, depending on which register card has been selec-
ted, there is a listing of the POUs , Data types, or Global variables of the
library selected in the upper area.
If a POU is selected by clicking the mouse or selecting with the arrow keys
then the declaration of the POU will appear in the upper right area of the
library manager; and in the lower right is the graphic display in the form of a
black box with inputs and outputs.
With data types and global variables, the declaration is displayed in the
right area of the library manager.
Standard Library The library with "standard.lib" is always available. It contains all functions
and function blocks that are required by the IEC1131-3 as standard POUs
for an IEC programming system. The difference between a standard func-
tion and an operator is that the operator is implicitly recognized by the pro-
gramming system, while the standard POUs must be tied to the project
(standard.lib).
User-defined Libraries If a project is to be compiled in its entity and without errors, then it can be
saved in a library with the "Save as" command in the "File" menu. The
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
project itself will remain unchanged. Subsequently, you can gain access to
the project under the entered name, just as with the standard library.
"Insert" "Additional Library" With this command you can attach an additional library to your project.
In the dialog box for opening a file, choose the desired library with the "*.lib"
extension. The library is now listed in the library manager, and you can use
the objects in the library as user-defined objects.
Remove Library With the "Edit" "Delete" command you can remove a library from a project
and from the library manager.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Appendix
Using the Keyboard
Use If you would like to run TwinCAT PLC Control using only the keyboard, you
will find it necessary to use a few commands that are not found in the me-
nu.
• The function key <F6> allows you to toggle back and forth within the
open POU between the Declaration and the Instruction parts.
• <Alt>+<F6> allows you to move from an open object to the Object Orga-
nizer and from there to the Message window if it is open. If a Search box
is open, <Alt>+<F6> allows you to switch from Object Organizer to the
Search box and from the there back to the object.
• Press <Tab> to move through the input fields and buttons in the dialog
boxes.
• The arrow keys allow you to move through the register cards and objects
within the Object Organizer and Library Manager.
All other actions can be performed using the menu commands or with the
shortcuts listed after the menu commands. <Shift>+<F10> opens the con-
text menu which contains the commands most frequently used for the se-
lected object or for the active editor.
Key Combinations The following is an overview of all key combinations and function keys:
General Functions
Move between the declaration part and the instruc- <F6>
tion part of a POU
Move between the Object Organizer, the object and <Alt>+<F6>
the Message window
Context Menu <Shift>+<F10>
Shortcut mode for declarations <Ctrl>+<Enter>
Move from a message in the Message window back <Enter>
to the original position in the editor
Open and close multi-layered variables <Enter>
Open and close folders <Enter>
Switch register cards in the Object Organizer and the <Arrow keys>
Library Manager
Move to the next field within a dialog box <Tab>
Context sensitive Help <F1>
General Commands
"File" "Save" <Ctrl>+<S>
"File" "Print" <Ctrl>+<P>
"File" "Exit" <Alt>+<F4>
"Project" "Delete Object" <Del>
"Project" "Add Object" <Ins>
"Project" "Rename Object" <Spacebar>
"Project" "Edit Object" <Enter>
"Edit" "Undo" <Ctrl>+<Z>
"Edit" "Redo" <Ctrl>+<Y>
"Edit" "Cut" <Ctrl>+<X> or
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
<Shift>+<Del>
"Edit" "Copy" <Ctrl>+<C>
"Edit" "Paste" <Ctrl>+<V>
"Edit" "Delete" <Del>
"Edit" "Find next" <F3>
"Edit" "Input Assistant" <F2>
"Edit" "Next Error" <F4>
"Edit" "Previous Error" <Shift>+<F4>
"Online" "Run" <F5>
"Online" "Toggle Breakpoint" <F9>
"Online" "Step over" <F10>
"Online" "Step in" <F8>
"Online" "Single Cycle" <Ctrl>+<F5>
"Online" "Write Values" <Ctrl>+<F7>
"Online" "Force Values" <F7>
"Online" "Release Force" <Shift>+<F7>
"Window" "Messages" <Shift>+<Esc>
LD Editor Commands
"Insert" "Network (after)" <Shift>+<T>
"Insert" "Contact" <Ctrl>+<O>
"Insert" "Parallel Contact" <Ctrl>+<R>
"Insert" "Function Block" <Ctrl>+<B>
"Insert" "Coil" <Ctrl>+<L>
"Extras" Paste below" <Ctrl>+<U>
"Extras" "Negate" <Ctrl>+<N>
Data types
Standard Data types
Data types You can use standard data types and user-defined data types when pro-
gramming. Each identifier is assigned to a data type which dictates how
much memory space will be reserved and what type of values it stores.
BOOL BOOL type variables may be given the values TRUE and FALSE. 8 bits of
memory space will be reserved.
Integer Data Types BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, and UDINT are
all integer data types
Each of the different number types covers a different range of values. The
following range limitations apply to the integer data types:
REAL / LREAL REAL and LREAL are so-called floating-point types. They are required to
represent rational numbers. 32 bits of memory space is reserved for REAL
and 64 bits for LREAL.
STRING A STRING type variable can contain any string of characters. The size entry
in the declaration determines how much memory space should be reserved
for the variable.It refers to the number of characters in the string and can
be placed in parentheses or square brackets. If no size specification is
given, the default size of 80 characters will be used.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Time Data Types The data types TIME, TIME_OF_DAY (abb. TOD), DATE and
DATE_AND_TIME (abb. DT) are handled internally like DWORD.
Time is given in milliseconds in TIME and TOD, time in TOD begins at
12:00 A.M.
Time is given in seconds in DATE and DT beginning with January 1, 1970
at 12:00 A.M.
The time data formats used to assign values are described in the chapter
on Constants.
Syntax:
<Field_Name>:ARRAY [<ll1>..<ul1>,<ll2>..<ul2>] OF <elem. Type>.
ll1, ll2 identify the lower limit of the field range; ul1 and ul2 identify the upper
limit. The range values must be integers.
Example:
Card_game: ARRAY [1..13, 1..4] OF INT;
Initializing Arrays:
You can initialize either all of the elements in an array or none of them.
Enumeration values are recognized in all areas of the project even if they
were locally declared within aPOU. It is best to create your enumerations as
objects in the Object Organizer under the register card Data types.
They begin with the keyword TYPE and end with END_TYPE.
Syntax:
TYPE <Identifier>:(<Enum_0> ,<Enum_1>, ...,<Enum_n>);
END_TYPE
The <Identifier> can take on one of the enumeration values and will be
initialized with the first one. These values are compatible with whole num-
bers which means that you can perform operations with them just as you
would with INT. You can assign a number x to the <Identifier>. If the enu-
meration values are not initialized, counting will begin with 0. When initiali-
zing, make certain the initial values are increasing. The validity of the num-
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Example:
TRAFFIC_SIGNAL: (Red, Yellow, Green:=10); (*The initial value for each
of the colors is red 0, yellow 1, green 10 *)
TRAFFIC_SIGNAL:=0; (* The value of the traffic signal is red*)
FOR i:= Red TO Green DO
i := i + 1;
END_FOR;
You may not use the same enumeration value more than once.
Example:
TRAFFIC_SIGNAL: (red, yellow, green);
COLOR: (blue, white, red);
Error: red may not be used for both TRAFFIC_SIGNAL and COLOR.
Structures Structures are created as objects in the Object Organizer under the register
card Data types. They begin with the keyword TYPE and end with
END_TYPE.
The syntax for structure declarations is as follows:
TYPE <Structurename>:
STRUCT
<Declaration of Variables 1>
.
.
<Declaration of Variables n>
END_STRUCT
END_TYPE
TYPE Polygonline:
STRUCT
Start:ARRAY [1..2] OF INT;
Point1:ARRAY [1..2] OF INT;
Point2:ARRAY [1..2] OF INT;
Point3:ARRAY [1..2] OF INT;
Point4:ARRAY [1..2] OF INT;
End:ARRAY [1..2] OF INT;
END_STRUCT
END_TYPE
You can gain access to structure components using the following syntax:
<Structure_Name>.<Componentname>
For example, if you have a structure named "Week" that contains a com-
ponent named "Monday", you can get to it by doing the following:
Week.Monday
References You can use the user-defined reference data type to create an alternative
name for a variable, constant or function block.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Create your references as objects in the Object Organizer under the regi-
ster card Data types. They begin with the keyword TYPE and end with
END_TYPE.
Syntax:
TYPE <Identifier>: <Assignment term>;
END_TYPE
Example:
TYPE message:STRING[50];
END_TYPE;
IEC Operators
TwinCAT PLC Control supports all IEC Operators. In contrast with the
standard functions, these operators are recognized implicitly throughout the
project. Operators are used like functions in POU implementation. Below is
a list of all supported operators:
Arithmetic Operators
ADD Addition of variables of the types: BYTE, WORD, DWORD, SINT, USINT,
INT, UINT, DINT, UDINT, REAL and LREAL.
Two TIME variables can also be added together resulting in another time
(e.g., t#45s + t#50s = t#1m35s)
Example in IL:
LD 7
ADD 2,4,7
ST var1
Example in ST:
var1 := 7+2+4+7;
Example in FBD:
Example in IL:
LD 7
MUL 2,4,7
ST var1
Example in ST:
var1 := 7*2*4*7;
Example in FBD:
SUB Subtraction of one variable from another of the types: BYTE, WORD,
DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL and LREAL.
A TIME variable may also be subtracted from another TIME variable resul-
ting in third TIME type variable. Note that negative TIME values are unde-
fined.
Example in IL:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
LD 7
SUB 8
ST var1
Example in ST:
var1 := 7-2;
Example in FBD:
DIV Division of one variable by another of the types: BYTE, WORD, DWORD,
SINT, USINT, INT, UINT, DINT, UDINT, REAL and LREAL.
Example in IL:
LD 8
DIV 2
ST var1
Example in ST:
var1 := 8/2;
Example in FBD:
MOD Modulo Division of one variable by another of the types: BYTE, WORD,
DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL and LREAL. The
result of this function will be the remainder of the division. This result will be
a whole number.
Example in IL:
LD 9
MOD 2
ST var1 (* Result is 1 *)
Example in ST:
var1 := 9 MOD 2;
Example in FBD:
INDEXOF Perform this function to find the internal index for a POU.
Example in ST:
var1 := INDEXOF(POU2);
SIZEOF Perform this function to determine the number of bytes required by the
given data type.
Example in IL:
arr1:ARRAY[0..4] OF INT;
var1:=INT;
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
LD arr1
SIZEOF
ST var1 (* Result is 10 *)
Example in ST:
pt := ADR(pt^) + SIZEOF(INT);
Bitstring Operators
AND Bitwise AND of bit operands. The operands should be of the type BOOL,
BYTE, WORD or DWORD.
Example in IL:
var1 :BYTE;
LD 2#1001_0011
AND 2#1000_1010
ST var1 (* Result is 2#1000_0010 *)
Example in ST:
var1 := 2#1001_0011 AND 2#1000_1010
Example in FBD:
Example in IL:
var1 :BYTE;
LD 2#1001_0011
OR 2#1000_1010
ST var1 (* Result is 2#1001_1011 *)
Example in ST:
Var1 := 2#1001_0011 OR 2#1000_1010
Example in FBD:
XOR Bitwise XOR of bit operands. The operands should be of the type BOOL,
BYTE, WORD or DWORD.
Example in IL:
Var1 :BYTE;
LD 2#1001_0011
XOR 2#1000_1010
ST Var1 (* Result is 2#0001_1001 *)
Example in ST:
Var1 := 2#1001_0011 XOR 2#1000_1010
Example in FBD:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
NOT Bitwise NOT of a bit operand. The operand should be of the type BOOL,
BYTE, WORD or DWORD.
Example in IL:
Var1 :BYTE;
LD 2#1001_0011
NOT
ST Var1 (* Result is 2#0110_1100 *)
Example in ST:
Var1 := NOT 2#1001_0011
Example in FBD:
Bit-Shift Operators
A diagram is used to represent the following operators as FBD operators.
SHL
Example:
LD 1
SHL 1
ST Var1 (* Result is 2 *)
SHR
Example:
LD 32
SHL 2
ST Var1 (* Result is 8 *)
ROL
Example:
Var1 :BYTE;
LD 2#1001_0011
ROL 3
ST Var1 (* Result is 2#1001_1100 *)
ROR
Example:
Var1 :BYTE;
LD 2#1001_0011
ROR 3
ST Var1 (* Result is 2#0111_0010 *)
Selection Operators
All selection operations can also be performed with variables. For purposes
of clarity we will limit our examples to the following which use constants as
operators.
Example in IL:
LD TRUE
SEL 3,4
ST Var1 (* Result is 4 *)
LD FALSE
SEL 3,4
ST Var1 (* Result is 3 *)
Example in FBD:
Example in IL:
LD 90
MAX 30
MAX 40
MAX 77
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
ST Var1 (* Result is 90 *)
Example in FBD:
Example in IL:
LD 90
MIN 30
MIN 40
MIN 77
ST Var1 (* Result is 30 *)
Example in FBD:
LIMIT Limiting
OUT := LIMIT(Min, IN, Max) means:
OUT := MIN (MAX (IN, Min), Max)
Max is the upper and Min the lower limit for the result. Should the value IN
exceed the upper limit Max, LIMIT will return Max. Should IN fall below Min,
the result will be Min.
IN and OUT can be any type of variable.
Example in IL:
LD 90
LIMIT 30,80
ST Var1 (* Result is 80 *)
MUX Multiplexer
OUT := MUX(K, IN0,...,INn) means:
OUT := INK.
IN0, ...,INn and OUT can be any type of variable. K must be BYTE, WORD,
DWORD, SINT, USINT, INT, UINT, DINT or UDINT. MUX selects the Kth
value from among a group of values.
Example in IL:
LD 0
MUX 30,40,50,60,70,80
ST Var1 (* Result is 30 *)
Comparison Operators
GT Greater than
A Boolean operator which returns the value TRUE when the value of the
first operand is greater than that of the second. The operands can be
BOOL, BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT,
REAL, LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and
STRING.
Example in IL:
LD 20
GT 30
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Example in ST:
VAR1 := 20 > 30 > 40 > 50 > 60 > 70;
Example in FBD:
LT Less than
A Boolean operator that returns the value TRUE when the value of the first
operand is less than that of the second. The operands can be BOOL,
BYTE, WORD, DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL,
LREAL, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and STRING.
Example in IL:
LD 20
LT 30
ST Var1 (* Result is TRUE *)
Example in ST:
VAR1 := 20 < 30;
Example in FBD:
Example in IL:
LD 20
LE 30
ST Var1 (* Result is TRUE *)
Example in ST:
VAR1 := 20 <= 30;
Example in FBD
Example in IL:
LD 60
GE 40
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Example in ST:
VAR1 := 60 >= 40;
Example in FBD:
EQ Equal to
A Boolean operator that returns the value TRUE when the operands are
equal. The operands can be BOOL, BYTE, WORD, DWORD, SINT,
USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, DATE, TI-
ME_OF_DAY, DATE_AND_TIME and STRING.
Example in IL:
LD 40
EQ 40
ST Var1 (* Result is TRUE *)
Example in ST:
VAR1 := 40 = 40;
Example in FBD:
NE Not equal to
A Boolean operator that returns that value TRUE when the operands are
not equal. The operands can be BOOL, BYTE, WORD, DWORD, SINT,
USINT, INT, UINT, DINT, UDINT, REAL, LREAL, TIME, DATE, TI-
ME_OF_DAY, DATE_AND_TIME and STRING.
Example in IL:
LD 40
NE 40
ST Var1 (* Result is FALSE *)
Example in ST:
VAR1 := 40 <> 40;
Example in FBD:
Address Operators
ADR Address Function
ADR returns the address of its argument in a DWORD. This address can
be sent to manufacturing functions to be treated as a pointer or it can be
assigned to a pointer within the project.
Example in IL:
LD var1
ADR
ST Var2
man_fun1
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Calling Operator
CAL Calling a Function Block
Use CAL in IL to call up a function block instance. The variables that will
serve as the input variables are placed in parentheses right after the name
of the function block instance.
Example: Calling up the instance Inst from a function block where input
variables Par1 and Par2 are 0 and TRUE respectively.
CAL INST(PAR1 := 0, PAR2 := TRUE)
Syntax:
<elem.Typ1>_TO_<elem.Typ2>
BOOL_TO Conversions Converting from the BOOL type variable to a different type:
For number type variables the result is 1 when the operand is TRUE and 0
when the operand is FALSE.
Examples in St:
i:=BOOL_TO_INT(TRUE); (* Result is 1 *)
str:=BOOL_TO_STRING(TRUE); (* Result is "TRUE" *)
t:=BOOL_TO_TIME(TRUE); (* Result is T#1ms *)
tof:=BOOL_TO_TOD(TRUE); (* Result is TOD#00:00:00.001 *)
dat:=BOOL_TO_DATE(FALSE); (* Result is D#1970 *)
dandt:=BOOL_TO_DT(TRUE); (* Result is
DT#1970-01-01-00:00:01 *)
The result is true for STRING type variables when the operand is "TRUE",
otherwise the result is FALSE.
Examples in St:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Conversion between Conversion from an integral number type to another number type:
Integral Number Types When you perform a type conversion from a larger to a smaller type, you
risk losing some information. If the number you are converting exceeds the
range limit, the first bytes for the number will be ignored.
Example in ST:
si := INT_TO_SINT(4223); (* Result is 127 *)
If you save the integer 4223 (16#107f represented hexadecimally)
as a SINT variable, it will appear as 127 (16#7f represented hexadecimal-
ly).
Example in IL:
LD 2
INT_TO_REAL
MUL 3.5
REAL_TO-/ LREAL_TO Converting from the variable type REAL or LREAL to a different type:
Conversions The value will be rounded up or down to the nearest whole number and
converted into the new variable type. Exceptions to this are the variable
types STRING, BOOL, REAL and LREAL.
When you perform a type conversion from a larger to a smaller type, you
risk losing some information .
Example in ST:
i := REAL_TO_INT(1.5); (* Result is 2 *)
j := REAL_TO_INT(1.4); (* Result is 1 *)
Example in IL:
LD 2.7
REAL_TO_INT
GE %MW8
TIME_TO/TIME_OF_DAY Converting from the variable type TIME or TIME_OF_DAY to a different
Conversions type:
The time will be stored internally in a DWORD in milliseconds (beginning
with 12:00 A.M. for the TIME_OF_DAY variable). This value will then be
converted.
When you perform a type conversion from a larger to a smaller type, you
risk losing some information .
Examples in St:
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
When you perform a type conversion from a larger to a smaller type, you
risk losing some information .
Examples in St:
STRING_TO Conversions Converting from the variable type STRING to a different type:
The operand from the STRING type variable must contain a value that is
valid in the target variable type, otherwise the result will be 0.
Examples in St:
TRUNC Converting from REAL to INT. The whole number portion of the value will
be used.
When you perform a type conversion from a larger to a smaller type, you
risk losingsome information .
Examples in St:
i:=TRUNC(1.9); (* Result is 1 *)
i:=TRUNC(-1.4); (* Result is 1 *)
Example in IL:
LD 2.7
TRUNC
GE %MW8
Numeric Functions
ABS Returns the absolute value of a number. ABS(-2) equals 2.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Example in IL:
LD 7
EXPT 2
ST var1 (* Result is 49 *)
Example in ST:
var1 := 7 EXPT 2;
String Functions
LEN
Example in IL:
LD ’ABBY’
LEN
ST Var1 (* Result is 4 *)
Example in ST:
Var1 := LEN (’ABBY’);
LEFT
Example in IL:
LD ’ABBY’
LEFT 3
ST Var1 (* Result is ’ABB’ *)
Example in ST:
Var1 := LEFT (’ABBY’,3);
RIGHT
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Example in IL:
LD ’ABBY’
RIGHT 3
ST Var1 (* Result is ’ BBY ’ *)
Example in ST:
Var1 := RIGHT (’ABBY’,3);
MID
Example in IL:
LD ’ABBY’
MID 2,2
ST Var1 (* Result is ’BB’ *)
Example in ST:
Var1 := MID (’ABBY’,2,2);
CONCAT
Example in IL:
LD ’ABBY’
CONCAT ’ CHRIS ’
ST Var1 (* Result is ’ABBY’,’CHRIS’*)
Example in ST:
Var1 := CONCAT (’SUSI’,’WILLI’);
INSERT
Example in IL:
LD ’ ABBY ’
INSERT ’XY’,2
ST Var1 (* Result is ’ ABXYBY ’ *)
Example in ST:
Var1 := INSERT (’ ABBY ’,’XY’,2);
DELETE
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Example in IL:
LD ’ ABXYBY ’
DELETE 2,2
ST Var1 (* Result is ’ ABBY ’ *)
Example in ST:
Var1 := DELETE (’ ABXYBY ’,2,2);
REPLACE
REPLACE replaces a partial string from a larger string with a third string.
REPLACE(STR1, STR2, L, P) means: Replace L characters from STR1
with STR2 beginning with the character in the P position.
Example in IL:
LD ’ ABXYBY ’
REPLACE ’K’,2,2
ST Var1 (* Result is ’ AKYBY ’ *)
Example in ST:
Var1 := REPLACE (’ABXYBY’,’’,2,2)
FIND
Example in IL:
LD ’ ABXYBY ’
FIND ’XY’
ST Var1 (* Result is 3 *)
Example in ST:
Var1 := FIND (’ ABXYBY ’,’XY’);
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
RS
SEMA
If BUSY is TRUE when SEMA is called up, this means that a value has
already been assigned to SEMA (SEMA was called up with CLAIM =
TRUE). If BUSY is FALSE, SEMA has not yet been called up or it has been
released (called up with RELEASE = TRUE).
Trigger
R_TRIG
The output Q0 and the help variable M will remain FALSE as long as the
input variable S1 is FALSE. As soon as S1 returns TRUE, Q0 will first re-
turn TRUE, then M will be set to TRUE. This means each time the function
is called up, Q0 will return FALSE until S1 has falling edge followed by an
rising edge.
F_TRIG
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
FUNCTION_BLOCK F_TRIG
VAR_INPUT
S1: BOOL;
END_VAR
VAR_OUTPUT
Q0: BOOL;
END_VAR
VAR
M: BOOL := FALSE;
END_VAR
Q0 := NOT S1 AND NOT M;
M := NOT S1;
END_FUNCTION_BLOCK
The output Q0 and the help variable M will remain FALSE as long as the
input variable S1 returns TRUE. As soon as S1 returns FALSE, Q0 will first
return TRUE, then M will be set to TRUE. This means each time the func-
tion is called up, Q0 will return FALSE until S1 has a rising followed by a
falling edge.
Counter
CTU
Incrementer:
CU, RESET and Q are BOOL variables, PV and CV are INT variables.
CTD
Decrementer:
CD, LD_ and Q BOOL variables, PV and CV are INT variables. (You might
be curious to know that the only reason LD_ is not named LD is because it
would then be a keyword).
When LD_ is TRUE, the counter variable CV will be initialized with the up-
per limit PV. If CD has a rising edge from FALSE to TRUE, CV will be lowe-
red by 1 provided CV is greater than 0 (i.e., it doesn’t cause the value to fall
below 0).
CTUD
INT variables.
Timer
TP
Timer
TP(IN, PT, Q, ET) means:
IN and PT are input variables of the BOOL and TIME types respectively. Q
and ET are output variables of the BOOL and TIME types respectively. If IN
is FALSE, Q is FALSE and ET is 0.
As soon as IN becomes TRUE, the time will begin to be counted in millise-
conds in ET until its value is equal to PT.It will then remain constant.
TON
Timer On Delay
TON(IN, PT, Q, ET) means:
IN and PT are input variables of the BOOL and TIME types respectively. Q
and ET are output variables of the BOOL and TIME types respectively. If IN
is FALSE, Q is FALSE and ET is 0.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
TOF
Constants
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
BOOL Constants BOOL constants are the logical values TRUE and FALSE.
TIME Constants TIME constants can be declared in TwinCAT PLC Control. These are gene-
rally used to operate the timer in the standard library. A TIME constant is
always made up of an initial "t" or "T" (or "time" or "TIME" spelled out) and a
number sign "#".
This is followed by the actual time declaration which can include days
(identified by "d"), hours (identified by "h"), minutes (identified by "m"), se-
conds (identified by "s") and milliseconds (identified by "ms"). Please note
that the time entries must be given in this order according to length (d befo-
re h before m before s before m before ms) but you are not required to
include all time increments.
TIME1 := T#14ms;
TIME1 := T#100S12ms; (*The highest component may be allowed to ex-
ceed its limit*)
TIME1 := t#12h34m15s;
DATE Constants These constants can be used to enter dates. A DATE constant is declared
beginning with a "d", "D", "DATE" or "date" followed by "#". You can then
enter any date with format Year-Month-Day.
Examples:
DATE#1996-05-06
d#1972-03-29
TIME_OF_DAY Constants Use this type of constant to store times of the day. A TIME_OF_DAY decla-
ration begins with "tod#", "TOD#", "TIME_OF_DAY#" or "time_of_day#"
followed by a time with the format: Hour:Minute:Second. You can enter
seconds as real numbers or you can enter fractions of a second.
Examples:
TIME_OF_DAY#15:36:30.123
tod#00:00:00
DATE_AND_TIME Con- Date constants and the time of day can also be combined to form so-called
stants DATE_AND_TIME constants. DATE_AND_TIME constants begin with
"dt#", "DT#", "DATE_AND_TIME#" or "date_and_time#". Place a hyphen
after the date followed by the time.
Examples:
DATE_AND_TIME#1996-05-06-15:36:30
dt#1972-03-29-00:00:00
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Number Constants Number values can appear as binary numbers, octal numbers, decimal
numbers and hexadecimal numbers. If an integer value is not a decimal
number, you must write its base followed by the number sign (#) in front of
the integer constant. The values for the numbers 10-15 in hexadecimal
numbers will be represented as always by the letters A-F.
Examples:
14 (Decimal number)
2#1001_0011 (Binary number)
8#67 (Octal number)
16#A (Hexadecimal number)
These number values can be from the variable types BYTE, WORD,
DWORD, SINT, USINT, INT, UINT, DINT, UDINT, REAL or LREAL.
Implicit conversions from "larger" to "smaller" variable types are not per-
mitted. This means that a DINT variable cannot simply be used as an INT
variable. You must use the type conversion functions from standard.lib to
be able to do this (see the Type Conversions chapter in the appendix).
REAL/LREAL Constants REAL and LREAL constants can be given as decimal fractions and repre-
sented exponentially. Use the standard American format with the decimal
point to do this.
Example:
7.4 instead of 7,4
1.64e+009 instead of 1,64e+009
STRING Constants A string is a sequence of characters. STRING constants are preceded and
followed by single quotation marks. You may also enter blank spaces and
special characters (umlauts for instance). They will be treated just like all
other characters.
In character sequences, the combination of the dollar sign ($) followed by
two hexadecimal numbers is interpreted as a hexadecimal representation
of the eight bit character code. In addition, the combination of two charac-
ters that begin with the dollar sign are interpreted as shown below when
they appear in a character sequence:
$$ Dollar signs
$’ Single quotation mark
$L or $l Line feed
$N or $n New line
$P or $p Page feed
$R or $r Line break
$T or $t Tab
Examples:
'w1Wüß?'
' Abby and Craig '
':-)'
Variables Variables can be declared either locally in the declaration part of a POU or
in the global variable list.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
The variable identifier may not contain any blank spaces or special cha-
racters, may not be declared more than once and cannot be the same as
any of the keywords. Capitalization is not recognized which means that
VAR1, Var1, and var1 are all the same variable. The underscore character
is recognized in identifiers (e.g., "A_BCD" and "AB_CD" are considered two
different identifiers). An identifier may not have more than one underscore
character in a row. The first 32 characters are significant.
Variables can be used anywhere the declared type allows for them.
System Flags System flags are implicitly declared variables that are different on each
specific PLC. To find out which system flags are available in your system,
use the command "Insert" "Operand".An Input Assistant dialog box pops
up, select the category System Variable.
System variables in Twin- The following system variables are available in TwinCAT. The structure of
CAT the variables is declared in the PLCSystem.LIB so this library has to be
included in the library manager. The first structure displays Systeminfos
and is a structure of SYSTEMINFOTYPE. It contains the following compo-
nents:
Accessing variables for Two-dimensional array components can be accessed using the following
arrays, structures and syntax:
POUs. <Fieldname>[Index1, Index2]
Function block and program variables can be accessed using the following
syntax:
<Functionblockname>.<Variablename>
Addresses
Address The direct display of individual memory locations is done through the use of
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
I Input
Q Output
M Memory location
X Single bit
None Single bit
B Byte (8 Bits)
W Word (16 Bits)
D Double word (32 Bits)
Examples:
The current PLC configuration for the program determines whether or not
an address is valid.
Memory location You can use any supported size to access the memory location.
For example, the address %MD48 would address bytes numbers 192, 193,
194, and 195 in the memory location area (48 * 4 = 192). The number of
the first byte is 0.
You can access words, bytes and even bits in the same way: the address
%MX5.0 allows you to access the first bit in the fifth word (Bits are generally
saved wordwise).
Functions
In ST a function call can also appear as an operand.
Example:
Result := Fct(7) + 3;
Build Error
Error messages Here you will find the error messages that the parser displays (italics) and
possible causes.They are shown in alphabetical order:
"ADR does not require an Replace the term or the constant with a variable.
expression or constant or
addressed variable as op-
erand"
""Function name not al- Replace the function call with a variable or a constant.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
lowed here""
"<Number> operands is too Check to see how many operands the operator <operator> requires and
many for <operator>. Ex- insert the ones that are missing.
actly <number> are nee-
ded."
"<Number> operands is too Check to see how many operands the operator <operator> requires and
few for <operator>. At least remove those that aren’t needed.
<number> are needed"
"Only BOOL variables are Change the type of declaration to BOOL or change the addressto a diffe-
allowed at a bit address" rent format.
"IL Operator Expected" Change the first word in the line to a valid operator or a valid function.
"POU ends incorrectly: add The POU ends with an incomplete expression. Add the correct ending or
ST or delete the last ex- delete it.
pression."
"POU <Name> is not de- Define a POU named <name> using the menu command "Project" "Ob-
fined in the project" ject add" or change the name to the name of the POU defined.
"POU <Name>needs ex- Check the number of input variables this POU requires, then add or remove
actly <number> inputs" them as needed.
"Identifier expected" Enter a valid identifier at the beginning of the declaration part.
"CAL, CALC, or CALN re- Declare an instance for the function block that you would like to call up.
quire function block in-
stance as operand"
"<Component> is not a If the variable is a structure, change the component into one of the compo-
component of <variable>" nents that are declared in this structure.
If the variable is a function block instance, change the <component> into an
input or output parameter that is declared in this function block.
"Index expression of an Change the index into a constant or an INT type variable.
array must be of type INT"
"Conditional Operator re- The result of the previous instruction is not a BOOL type variable. Insert an
quires type BOOL" operator or a function whose result is BOOL.
"Name used in interface is Rename your POU with the menu command "Project" "Object Rename"
not identical with POU or change the name of the POU in its declaration part. The name must
name" appear directly after the keywords, PROGRAM, FUNCTION or FUNC-
TIONBLOCK.
"End value of FOR state- Change the variable to an INT type variable.
ment must be of type INT"
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
<name>"
"Start value of FOR state- Change the variable to an INT type variable.
ment must be of type INT"
"Expression in FOR state- Change the variable to a variable with write permission.
ment is not variable with
write access"
"Function block call requi- Insert the name of the desired instance or remove the call for the function
res function block instance" block.
"A jump must have exactly Change the jump destination to a defined label.
one label"
"END_STRUCT or identifier A structure definition must end with the keyword END_STRUCT.
expected"
"END_VAR or identifier Write in valid identifier or END_VAR at the beginning of the declaration
expected" part.
"Error in initial value" Enter a constant (constants) for the initial value which corresponds to the
declaration type.
"No instance specied for Change the text of the instance for function block <name> (initialized with
call of function block <na- "Instance") in the identifier of a valid instance declaration.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
me>"
"Integer number or symbo- Only integers or symbolic constants can be used as the condition for a
lic constant expected" CASE instance. Change the incorrect condition.
"<Identifier> is not a func- Change <identifier> into one of the functions from the libraries that are lin-
tion" ked to the project or into one of the function declared in the project.
"IF and ELSIF require a Change the expression to an expression with a BOOL type result.
Boolean expression for the
condition"
"Illegal time constants" Check to see if the time constant you wrote is correct and change any mi-
stakes you find. Possible mistakes are:
The t or # is missing at the beginning.
A time entry appears twice (e.g., t#4d2d).
Incorrect sequence of times.
Incorrect time indicator (the d, h, m, s or ms is missing).
"’[<index]’ needs array va- Declare the identifier before the bracket as an array or change it into a de-
riables" clared array variable.
"INI operator needs function Change the operands into a function block instance. To do this, declare the
block instance or a data unit operand as a function block or use a previously declared function block, or
type instance" use a data unit type instance.
"No write access to variable Change <name> into a variable with write permission.
<Name> allowed"
"Comments are only allo- Write the comments at the end of the line.
wed at the end of the line in
IL"
"LD expected" The instruction "LD" is the only one allowed in this line.
"Multiple underscore in Remove one of the underscore characters from the identifier.
identifier"
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Address expected after Insert a valid address after the AT or change the keyword AT.
’AT’"
"Number expected after ’+’ Change the word after + or - into a valid constant.
or ’-’"
"<Name> is not an input Check over the input variables for the called function block and change
variable of the called func- <name> into one of these variables.
tion block"
"<Name> is no function Replace <name> with the name of a valid function block.
block"
"<Name> must be a decla- Change the text of the function block instance (initialized with "Instance")
red instance of the function into an identifier for a valid function block instance declaration.
block <FBName>"
"’N’ modifier requires a Remove the N and negate the operand explicitly with the NOT operator
BOOL type operand"
"NOT requires an operand Change the operand into a BOOL type operand.
of type BOOL"
"Only VAR and Copy the declaration into a VAR or VAR_GLOBAL area.
VAR_GLOBAL can be lo-
cated to addresses"
"Variable with write access Replace the first operand with a variable that has write permission
or direct address required
for ST, STN, S, R"
"<Operator> in parentheses This operator is not allowed within parentheses. Either remove the paren-
is not allowed" theses or the operator.
"Operator is not extendable. Check the number of operands for this operator and remove the surplus
Remove the surplus ope- operands.
rands"
"Type mismatch in para- Check the type of the operand with the number <number> of this operator,
meter <number>: Cannot function or function block. Change the type of the variable that caused the
convert <type> to <type>." error to a type that is allowed or select a new variable of an allowed type.
"Closing bracket with no Remove the end bracket or insert the beginning one.
corresponding opening
bracket"
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
"Jump to an undefined step: Change <name> into the name of an existing step or add a step named
<Name>" <name>.
"Jump and Return require The result of the previous instruction is not a BOOL result. Insert an ope-
an Boolean input" rator or a function with a result of the type BOOL.
"Jump and Return are only Delete the jump or return that is not allowed.
allowed on the right side of
a network"
"<Label> label is not de- Define a label with the name <LabelName> or change <LabelName> into a
fined" defined label.
"Expecting type specificati- Write a valid type behind the identification in the declaration
on"
"Unknown type: <string>" Change <string> into a valid type.
"Unrecognized variable or This watch variable is not declared in the project. Press <F2> to access
address" help with declared variables.
"Unexpected End" In the declaration part: Add the keyword END_VAR to the end of the decla-
ration part.
In the text editor: Insert instructions that end the last instruction sequence
(e.g., ST).
"UNTIL requires a BOOL Change the expression to an expression with a BOOL type result.
expression as condition"
"Type mismatch: Cannot Check the required types of operators (search for Operator in your help file)
convert <Type1> into <Ty- and change the variable type that produced the error into a type that is al-
pe2>. lowed or select another variable.
"Invalid address: Check in your PLC configuration to see which addresses are allowed and
<Address>" replace the addresses with permissible addresses or change the PLC con-
figuration.
"Type mismatch on input A value that is <Type2> (which is not allowed) is assigned to the variable
_1_variable <name>: Can- <name>. Change the variable or the constant into a variable or constant of
not convert <Type1> into the type <Type1>.
<Type2>."
"Type mismatch in para- Use a <Type2> type variable for the assignment to the <name> parameter
meter <name> of <name>: or change the type of assigned variable to <Type1>.
Cannot convert <Type1>
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
into <Type2>."
"Type mismatch in para- Check to see what type of <parameter> parameter are required in the
meter <Parameter> of <POU> POU. Change the type of the variable that caused the error to <Ty-
<POU>: Cannot convert pe2> or select another variable that is <Type2>.
<Type1> into <Type2>."
"Identifier <name> not de- Declare this variable in the declaration part of the POU or in the global va-
fined" riable list.
"VAR, VAR_INPUT, The first line after the name of the POU must contain one of these key-
VAR_OUTPUT or words.
VAR_INOUT expected"
"’.’ needs structure varia- The identifier to the left of ’.’ is not a structure variable or instance for a
ble." function block. Change the identifier into a structure variable or into a in-
stance for a function block or remove the period and the identifier to its
right.
"WHILE requires a Boolean Change the expression to an expression with a BOOL type result.
expression as its condition"
"Expecting Number, ELSE The end of a CASE statement is incorrect. Add the keyword END_CASE.
or END_CASE"
"Too many indices for Check how many indices are declared for the array(1, 2, or 3) and remove
array" the extra ones.
"Overflow of identifier list" You must learn to restrain yourself, no more than 64000 identifiers are al-
lowed.
"Too few indices for array" Check how many indices are declared for the array (1, 2, or 3) and add
those that are needed.
"Out of Memory" Leave the system by saving. Close Windows, restart it and then restart the
compilation.
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Index
CONCAT · 144
Concatenation · 144
A CONSTANT · 81, 84, 113
Constants · 81, 130, 150
ABS · 143 Contact · 24, 99, 100, 128
Access rights · 59, 64 Contents and Index · 78
ACOS · 143 Context Sensitive Help · 79
Action · 21, 22, 35, 36, 37, 38, 104, 106, 110 Copy · 58, 62, 67, 68, 78, 97, 128, 158
Action Init · 35, 36 COS · 143
Active step · 21 Cross reference list · 60
ADD · 13, 96, 132 CTD · 148
Address Function · 140 CTU · 147
Addresses · 122, 153 CTUD · 148
ADR · 134, 140, 154 Cut · 61, 67, 68, 69, 97, 98, 128
AND · 13, 15, 16, 29, 95, 101, 134, 146, 147, 151
ARRAY · 130, 131, 134
ASIN · 143 D
Assignment · 15, 16, 29, 94, 102, 132
Assignment operator · 16 Data type · 12, 39, 40, 125, 129, 130, 131, 132
AT Declaration · 82 Data types · 12, 39, 40, 125, 129, 130, 131, 132
ATAN · 143 DATE · 130, 138, 139, 141, 142, 150, 151
Auto Load · 43 DATE Constants · 150
Autodeclaration · 44, 84 DATE_AND_TIME · 130, 138, 139, 142, 151
Autoformat · 44 DATE_AND_TIME Constants · 151
debugger · 88
Debugging · 4, 26, 47
B Declaration · 31, 33, 44, 80, 84, 85, 113, 127, 129, 131
Declaration Editor · 80, 84, 85
Backup · 42 Declaration Part · 31, 33
Bitvalues · 44, 45 Declarations as a Table · 84
BOOL · 25, 82, 83, 84, 100, 107, 129, 134, 135, 136, 138, Declarations as table · 44
139, 140, 141, 142, 146, 147, 148, 149, 150, 154, 155, Defined Data Types · 130
156, 158, 159, 160 Delete · 61, 67, 69, 74, 97, 118, 126, 127, 128, 145, 156, 158
BOOL Constants · 150 DELETE · 145
BOOL_TO Conversions · 140 Deleting in FBD · 97
Breakpoint · 26, 45, 46, 73, 74, 88, 89, 110, 111, 128 Desktop · 39, 41, 42, 45
Breakpoint Dialog Box · 74 DINT · 129, 132, 133, 137, 138, 139, 140, 143, 151
Breakpoint position · 46, 88 Directory · 57
breakpoints · 4, 26, 74, 88, 89, 92, 98 DIV · 13, 133
Build · 42, 47, 54, 58, 154 Document · 51, 54, 55, 56, 58, 113, 114
BYTE · 45, 82, 129, 132, 133, 134, 135, 136, 137, 138, 139, Document Frame · 113, 114
140, 141, 142, 143, 151 Download · 38, 73
Drag&Drop · 60
DT · 130, 141, 142, 151
DT_TO Conversions · 142
C DWORD · 45, 117, 129, 130, 132, 133, 134, 135, 136, 137,
138, 139, 140, 142, 143, 151
CAL · 9, 11, 13, 26, 88, 89, 140, 155
Call tree · 60
Calling a function · 10, 15 E
Calling a function block · 10, 15
Calling function blocks in ST · 17
CASE · 15, 18, 155, 156, 160 Editors · 40, 44, 80
CASE instruction · 18 EN Input · 101
CheckBounds · 8 EN POU · 25, 26, 101, 103
clipboard · 61, 62, 67, 68, 69, 78, 97, 102, 106 END_FUNCTION_BLOCK · 8, 147
Coil · 25, 99, 101, 103, 128 END_PROGRAM · 9, 11
Collapse Node · 110 END_TYPE · 130, 131, 132
Colors · 46 Enumeration · 130
Comment · 44, 84, 85, 86, 91, 107, 109 EQ · 12, 13, 16, 29, 139
Communication Parameters · 72, 76, 77 Error messages · 154
Compress · 121 EXIT · 15, 16, 20, 36, 37, 38, 88, 156
EXP · 143
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Index 160
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
TWIN&$7
INDUSTRIE ELEKTRONIK Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149
Index 162
SHL · 135 TwinCAT PLC Control · 4, 5, 6, 23, 24, 26, 27, 28, 39, 40,
Shortcut Mode · 83 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 53, 55, 59, 72, 73,
Show Call Stack · 75 78, 80, 82, 83, 87, 88, 90, 91, 93, 99, 104, 121, 127, 132,
SHR · 135 150
Simulation · 27, 73, 76, 157 TYPE · 130, 131, 132
SIN · 15, 143 Types · 129, 130, 141
Single Cycle · 26, 73, 75, 128
SINT · 129, 132, 133, 137, 138, 139, 141, 142, 151
SIZEOF · 134 U
SQRT · 143
SR · 146 UDINT · 129, 132, 133, 137, 138, 139, 151
ST · 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 21, 26, 55, 62, 67, UINT · 129, 132, 133, 137, 138, 139, 151
68, 73, 84, 86, 91, 132, 133, 134, 135, 136, 137, 138, 139, Undo · 67, 127
140, 141, 143, 144, 145, 146, 150, 154, 158, 159 Unused variables · 66
ST operator · 14 User group · 49, 59
Standard Library · 125, 140 User information · 42, 43
standard.lib · 6, 12, 30, 125, 151 USINT · 129, 132, 133, 137, 138, 139, 151
Start Trace · 117, 119
Statistics · 57
Status bar · 39, 41
Step · 18, 20, 33, 73, 74, 75, 89, 105, 106, 107, 109, 110, V
111, 128, 155, 158
Step Attributes · 106, 107, 109 VAR · 9, 28, 30, 80, 81, 84, 112, 113, 147, 156, 158, 159
Stop · 45, 73, 77, 118, 119 VAR_GLOBAL · 84, 112, 113, 158
Stop Trace · 118, 119 VAR_IN_OUT · 81
Stretch · 121 VAR_INOUT · 84, 159
STRING · 83, 84, 129, 132, 138, 139, 140, 141, 142, 151 VAR_INPUT · 28, 80, 84, 147, 159
STRING Constants · 151 VAR_OUTPUT · 80, 84, 147, 159
STRING_TO Conversions · 142 Variables · 82, 83, 84, 112, 113, 118, 119, 131, 152
STRUCT · 131, 156 Variables declaration · 82
Structure · 122, 131, 153 Visualizations · 40
Structured Text · 14, 87, 91
Structures · 12, 27, 82, 131
SUB · 13, 16, 132 W
Syntax Coloring · 83
System Flag · 152 Watch and Receipt Manager · 4, 12, 60, 80, 112, 122, 123,
124
Watch List · 122, 123
T WHILE loop · 19
Window · 30, 39, 40, 41, 53, 77, 88, 125, 128
TAN · 143 WORD · 45, 129, 132, 133, 134, 135, 136, 137, 138, 139,
Text Editors · 73, 87, 90, 91 140, 142, 143, 151
TIME · 30, 32, 107, 130, 132, 138, 139, 141, 142, 148, 149, Work space · 39, 40
150, 151 Write Receipt · 122, 123, 124
TIME Constants · 150
Time per Scan · 118
TIME_OF_DAY · 130, 138, 139, 142, 151 X
TIME_OF_DAY Constants · 151
Timer · 148, 149 XOR · 13, 15, 134
TO_BOOL Conversions · 141
TOD · 130, 141, 142, 151
TOF · 149 Y
TON · 149
Tool bar · 39, 40, 110
Tooltip · 39, 60, 86, 88, 92, 98, 103, 110 Y Scaling · 121
TP · 30, 148
Transition · 21, 38, 105, 106, 128
trigger · 26, 118, 119 Z
Trigger · 118, 119, 147
TRUNC · 142 Zoom · 21, 97, 106, 128
Zoom Action · 21, 106, 128
TWIN&$7