KW Multiprog Quickstart

Download as pdf or txt
Download as pdf or txt
You are on page 1of 76

MULTIPROG

QUICK START GUIDE

Manual issue date: April 2002

Windows is a trademark of Microsoft


Corporation.


Copyright 2002 by
KW-Software GmbH
All rights reserved.

KW-Software GmbH
Lagesche Strae 32
32657 Lemgo
Germany

Phone: +49 5261 93730


Fax: +49 5261 937326
WEB: http://www.kw-software.com
EMAIL: [email protected]
CONTENTS

CONTENTS
CONTENTS 2
INTRODUCTION 4
ABOUT THIS MANUAL 5
PLC PROGRAMMING SYSTEM REQUIREMENTS 6
HARDWARE REQUIREMENTS 6
SOFTWARE REQUIREMENTS 6
INSTALLING THE SOFTWARE 7
DEVELOPING A SAMPLE PROJECT 11
CREATING A NEW PROJECT USING THE PROJECT W IZARD 11
STARTING THE PROJECT W IZARD 11
USING THE PROJECT W IZARD 12
DEVELOPING THE LD CODE 17
INSERTING AN LD NETWORK 17
DECLARING THE PROPERTIES 18
INSERTING A COUNTER USING THE EDIT W IZARD 22
INSERTING THE COUNTER 'RESET' CONTACT 24
DECLARING THE PROPERTIES OF THE COUNTER'S 'RESET' CONTACT 25
INSERTING A SECOND LD NETWORK AND EDITING NETWORK
DESCRIPTION COMMENTS 30
COMPILING THE EXAMPLE PROJECT 37
'MAKING' THE PROJECT 37
HANDLING ERRORS AND MESSAGES 39
DOWNLOADING THE PROJECT TO THE PLC OR IO SIMULATION 40
DEBUGGING THE PROJECT 42
DEBUG MODE 42
ONLINE EDITING 43
CROSS REFERENCE W INDOW 47
VARIABLES W ATCH W INDOW 48
FORCING AND OVERWRITING 49
BREAKPOINTS 50
PRINTING THE PROJECT DOCUMENTATION 53
SELECTING A PRINTER 53
SETTING THE PAGELAYOUT 53
PRINTING THE PROJECT 54
PRINT PREVIEW 54
PRINTING A SINGLE WORKSHEET 55
ADDITIONAL FEATURES 56
USING THE I/O CONFIGURATION 56
CREATING AN USER DEFINED FUNCTION 59
CHANGING THE TASK CYCLE TIME 67

PAGE 2 QUICK START GUIDE


CONTENTS

APPENDIX 69
IEC PROJECT COMPONENTS IN THE PROGRAMMING SYSTEM 69
PROGRAM ORGANIZATION UNITS (POUS) 69
INSTANTIATION OF POUS AND FUNCTION BLOCKS 71
VARIABLES AND DATA TYPES 71
VARIABLE TYPES 71
VARIABLES ADDRESSES 72
DATA TYPES 73

QUICK START GUIDE PAGE 3


INTRODUCTION

INTRODUCTION
MULTIPROG is a standard programming system for IEC
designed PLCs and traditional PLCs. It is based on the
standard IEC 61131-3 and includes the full range of IEC
features.

The programming system is based on a modern 32 bit windows


technology, providing comfortable handling including zoom,
drag & drop and dockable windows. The system allows the
handling of IEC configuration elements, including libraries and
provides a powerful debug system. With MULTIPROG all
functionalities are easily accessible via the menu and it only
takes you a few dialogs to get through project generation.
Having finished that, you can immediately start developing your
program.

The programming system consists of a PLC independent kernel


for programming in the various IEC programming languages. To
do so, the textual languages ST and IL as well as the graphical
languages LD, FDB and SFC are provided. Each editor
provides an Edit Wizard allowing keywords, statements,
operators, functions and function blocks to be inserted fast and
easy. The Edit Wizard can also be used for declaring data
types. Specific parts adapted to the different PLCs complete the
independent kernel.

PAGE 4 QUICK START GUIDE


INTRODUCTION

ABOUT THIS MANUAL

This manual provides step by step instructions for developing,


editing and running a sample Ladder Diagram (LD) program
using MULTIPROG. The development of the sample project is
divided into several phases as shown in the following figure:

CREATING
(PHASE 1)

EDITING
(PHASE 2)

COMPILING
(PHASE 3)

DOWNLOADING
(PHASE 4)

DEBUGGING
(PHASE 5)

PRINTING
(PHASE 6)

Each phase will be described in detail and without any gap


from project generation to project documentation.

The example application explained in this manual is a basic


motor control circuit. The logic requires the operator to press
the start button three times to start the motor. The motor stops
running after 20 seconds.

QUICK START GUIDE PAGE 5


PLC PROGRAMMING SYSTEM REQUIREMENTS

PLC PROGRAMMING SYSTEM


REQUIREMENTS

HARDWARE REQUIREMENTS

Device Minimum Recommended

IBM compatible PC with


200 MHz 350 MHz
Pentium processor

System RAM 64 MB 128 MB

60 MB free
Hard disk
memory space

CD ROM drive or

VGA Monitor
Color settings 256 colors True color
Resolution 800 x 600 1024 x 768

RS232 interface Optional

Mouse Recommended

SOFTWARE REQUIREMENTS

 Microsoft Windows 95, Microsoft Windows 98,


Microsoft Windows NT 4.0 SP5 or Windows 2000

 Microsoft Internet Explorer 4.02

PAGE 6 QUICK START GUIDE


INSTALLING THE SOFTWARE

INSTALLING THE SOFTWARE


To install the software, insert the CD in your CD ROM drive.

Execute the setup file to launch the Installation Wizard which


will guide you through the installation process.

Click 'Next' to proceed.

Select the default languages you want the installation wizard to


install with MULTIPROG 3.0.

Click 'Next' to proceed.

QUICK START GUIDE PAGE 7


INSTALLING THE SOFTWARE

Select the program manager group you want the installation


wizard to add to your system. 'Multiprog 3.0' is given as default
group. If you do not want the installation wizard to add an icon
on your desktop, deactivate the corresponding checkbox.

Click 'Next' to proceed.

Select the directory in which MULTIPROG is to be installed.


The default path is already given. Click 'Next' to proceed.

PAGE 8 QUICK START GUIDE


INSTALLING THE SOFTWARE

To start the installation, click on 'Install'. If you want to abort the


installation, press the 'Exit' button. If you want to change any
entries click on 'Back' to return to the previous steps.

Click 'OK' to proceed.

QUICK START GUIDE PAGE 9


INSTALLING THE SOFTWARE

Select, whether you want to read the README file which


contains the latest information on MULTIPROG. Select 'No', if
you do not want to read the file. Then click 'OK'.

After the installation has been completed you have to reboot


your computer. Click 'OK'.

PAGE 10 QUICK START GUIDE


CREATING A NEW PROJECT USING THE PROJECT W IZARD DEVELOPING A SAMPLE PROJECT

DEVELOPING A SAMPLE PROJECT


Start the programming system.

We will now develop a sample project using the programming


language Ladder Diagram (LD). In the first phase we create a
new, empty project.

In order to get the best possible result we recommend to use


the identifiers and names we use in this manual.

PHASE 1 CREATING A NEW PROJECT USING THE


PROJECT WIZARD

The Project Wizard guides you in 6 steps through the process


of creating the new project. Here, you have to define the name
and path of the project, the programming language and the type
of the PLC used.

STEP 1 STARTING THE PROJECT WIZARD

Click on the 'New Project' icon:

The 'New Project' dialog appears.

Double click on the 'Project Wizard' icon:

The dialog 'Project Wizard (Step 1 of 6)' appears.

QUICK START GUIDE PAGE 11


DEVELOPING A SAMPLE PROJECT CREATING A NEW PROJECT USING THE PROJECT W IZARD

STEP 2 USING THE PROJECT WIZARD

Figure 1:
Dialog 'Project Wizard
(Step 1 of 6)' for
specifying the project
name and project path

Fill in the dialog fields as follows:

a. Enter the desired project name ('My_first_Project') into the


first input field as shown in the figure above. The Project
Wizard will save the project to a corresponding file
'My_first_Project.mwt' and create a subfolder of the same
name, in which the code bodies, variables' files, etc. will be
stored.

According to the rules for projects, the name and the path of
the project must not contain any blanks or special
characters. The maximum number of characters for the
project name is 24.

The default path for the project has been entered


automatically.
If you want to store your project in another path, specify this
in the second input field as described below:

b. Click on the browse button:

The 'Select Directory' dialog appears.

c. Choose a folder for the new project.

d. Click on the button 'Next' to continue.

The dialog 'Project Wizard (Step 2 of 6)' appears.

PAGE 12 QUICK START GUIDE


CREATING A NEW PROJECT USING THE PROJECT W IZARD DEVELOPING A SAMPLE PROJECT

Figure 2:
Dialog 'Project Wizard
(Step 2 of 6)' for
entering the first POU
and selecting the
programming language

e. Enter the name for the first POU, which will be automatically
inserted by the Project Wizard in the project tree when
creating the project. Enter 'Main' for our example POU.
Choose the language for the first program by activating the
corresponding radio button.
As we want to program our sample project in the graphical
language Ladder Diagram, select 'Ladder (LD)'.

f. Click 'Next' to continue.

The dialog 'Project Wizard (Step 3 of 6)' appears.

Figure 3:
Dialog 'Project Wizard
(Step 3 of 6)' for
selecting the
configuration name and
type

g. Enter the desired configuration name into the input field.


The configuration can be compared to a programmable
controller system, e.g. a rack. In our example we enter
'Configuration'.

QUICK START GUIDE PAGE 13


DEVELOPING A SAMPLE PROJECT CREATING A NEW PROJECT USING THE PROJECT W IZARD

h. Select a configuration type for the project. This is necessary


because the system generates PLC specific code when
compiling the project.
Select the PLC type in the list box. In our example we
choose 'IPC_32', so the compiler will generate Intel code
for ProConOS 3.2.

For detailed information about PLC types please refer to the


corresponding PLC manual.

i. Click 'Next' to continue.

The dialog 'Project Wizard (Step 4 of 6)' appears.

Figure 4:
Dialog 'Project Wizard
(Step 4 of 6)' for
selecting the resource
name and type

j. Enter a name for the resource (in our example 'Resource').


The resource can be compared to a CPU which can be
inserted into the rack (i.e. into the configuration).
In the list box select the resource type. The list box only
offers CPU types which belong to the configuration you
have defined in the dialog 'Project Wizard (Step 3 of 6)'
(refer to Figure 3).

k. Click 'Next' to continue.

The dialog 'Project Wizard (Step 5 of 6)' appears.

PAGE 14 QUICK START GUIDE


CREATING A NEW PROJECT USING THE PROJECT W IZARD DEVELOPING A SAMPLE PROJECT

Figure 5:
Dialog 'Project Wizard
(Step 5 of 6)' for
selecting the task name
and type

l. Enter the name of the first task into the input field (in our
example 'Task').
In the list box select the task type 'CYCLIC'.

Detailed information about the different task types can be


found in the online help system.

m. Click 'Next' to continue.

The dialog 'Project Wizard (Step 6 of 6)' appears.

Figure 6:
Dialog 'Project Wizard
(Step 6 of 6)' displaying
an overview on the
project settings

This dialog shows the project description, which is an


overview of the settings you have made in the steps 1 to 5.
If an invalid name was entered the error message 'Invalid
name' appears and the 'Finish' button is greyed out. If this is
the case, check the spelling of the suspected identifier.

QUICK START GUIDE PAGE 15


DEVELOPING A SAMPLE PROJECT CREATING A NEW PROJECT USING THE PROJECT W IZARD

To correct an error browse to the corresponding step using


the 'Back' button. Make sure that the rules for defining
identifiers are followed.

n. If no error message occurs click 'Finish':

The new project will be created and inserted in the project


tree window.
In the project tree window, you can see the newly generated
project with its POU 'Main' in the subtree 'Logical POUs' and
the configuration, resource and task in the subtree 'Physical
Hardware'.

Figure 7:
Automatically
generated project in
the project tree

The empty code body worksheet of the program 'Main' is


automatically opened.

PAGE 16 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

PHASE 2 DEVELOPING THE LD CODE

Now that we have created the new project we will start phase 2
and develop the project code.

To do so, we will use the programming language Ladder


Diagram (LD). Having finished editing the project code, the
project can be compiled, downloaded and debugged.

In the following steps we will explain how to

 insert a first LD network

 declare the properties of LD objects which are


automatically inserted with the first LD network

 insert and connect a function block in the LD code body


worksheet using the Edit Wizard

 insert and connect a contact in the LD code worksheet


using the connection mode

 declare the properties of contacts and coils

 insert a second LD network and edit network description


comments

STEP 1 INSERTING A LD NETWORK

We want to insert the first LD network '001':

a. Click with the left mouse button into the worksheet to set an
insertion mark at the position shown below. Here, the
network will be inserted.

b. Click on the 'Contact network' icon to insert the LD network:

c. The network comes with a contact and a coil, and its width
is set automatically as well.

QUICK START GUIDE PAGE 17


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

Figure 8:
New LD network in
the worksheet

STEP 2 DECLARING THE PROPERTIES

We now want to declare the properties of the LD objects which


have been automatically inserted with the first LD network

a. Double click on the contact 'C000'.


As an option you can mark the contact by clicking on it and
then press <Enter>.

The 'Contact/Coil Properties' dialog appears.

b. Change the variable name from its default name 'C000' to


'Motor_Start'.
Figure 9:
Dialog 'Contact/Coil
Properties' for
setting the contact
properties

c. Click 'Apply' or press <Enter>. The dialog page 'Common' is


opened automatically.

d. In the list box 'Usage' (see Figure 10) select


'VAR_EXTERNAL' so that the variable will be declared as
global variable, meaning it can be used in each POU of the
project.

PAGE 18 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

e. We now want to assign the variable 'Motor_Start' to our I/O


simulator, so we can test the logic on the screen. To do so,
we have to assign the variable's physical PLC address in
the input field 'I/O address'. Since this contact is meant to
start the motor, we need to declare an input variable.
Enter '%IX0.0' for the declaration of the located variable
'Motor_Start'. This is the simulator position, where '0.0'
designates 'first module.first point'.
Figure 10:
Dialog 'Contact/Coil
Properties' for
setting the contact
properties

f. Open the dialog page 'Local scope' and select 'Default' from
the tree.
By selecting this entry we define, that the VAR_EXTERNAL
declaration of the new variable will be inserted into the
variables group 'Default' of the local variables grid
worksheet.

As we are declaring a global variable (usage


VAR_EXTERNAL) we have to select both, a local and a
global scope.

QUICK START GUIDE PAGE 19


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

Figure 11:
Dialog 'Contact/Coil
Properties' for
setting the contact
properties

g. Open the dialog page 'Global scope' and select 'Default'


from the tree.
By selecting this entry we define, that the VAR_GLOBAL
declaration of the new variable will be inserted into the
variables group 'Default' of the resource's global variables
grid worksheet.

As we are declaring a global variable (usage


VAR_EXTERNAL) we have to select both, a local and a
global scope.

PAGE 20 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

Figure 12:
Dialog 'Contact/Coil
Properties' for
setting the contact
properties

For detailed information on the variable declaration and the


function of local and global variables refer to the Appendix,
section 'Variables and Data Types'.

h. Click 'OK' to confirm the 'Contact/Coil Properties' dialog.


The variable and its declaration will be inserted.

Now your screen should look as follows:


Figure 13:
LD code worksheet
with global input
variable
'Motor_Start'

QUICK START GUIDE PAGE 21


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

STEP 3 INSERTING A COUNTER USING THE EDIT WIZARD

Now we want to insert and connect a counter in the LD code


worksheet using the Edit Wizard.

a. As we want to insert the counter between 'Motor_Start' and


'C001', click on the line to mark it:
Figure 14:
Line marked to
specify the position
for inserting the
counter

b. If the Edit Wizard is not already opened, click on the 'Edit


Wizard' icon in the toolbar:

The Edit Wizard appears.

c. Open the group 'Function


blocks' (if not already open).
In the list of function blocks
browse for the entry 'CTU'
and double click on it.

The dialog 'Variable Properties' appears.

PAGE 22 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

Figure 15:
Dialog 'Variable
Properties' for
setting the counter
properties

d. Change the instance name from its default name to


'Motor_Count' in the 'Name' input field and click 'OK'. The
'Common' dialog page is opened automatically. Confirm the
dialog with 'OK'.

e. Hide the Edit Wizard by clicking on the 'Edit Wizard' icon


again:

Your worksheet should now look as follows:


Figure 16:
LD code worksheet
with inserted
counter 'CTU'

QUICK START GUIDE PAGE 23


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

STEP 4 INSERTING THE COUNTER 'RESET' CONTACT

Now we want to define the 'Reset' input of the CTU function


block and connect it to the left powerrail.

a. Click on the 'Reset' input to mark it:


Figure 17:
Marked input of the
counter for
connecting a
contact

b. Click on the 'Add contact left' icon in the toolbar to insert a


contact left of the 'Reset' input.

Figure 18:
Inserting a contact
in the LD network

c. Click on the 'Connect Objects' icon in the toolbar:

d. Click on the contact 'C002' for the starting point of the


connection line.

e. Move the mouse to the left powerrail and click once to end
the line.
Figure 19:
Connecting the
contact using the
connection mode

Moving the contact:


f. Switch from connection mode to mark mode by pressing
<Esc> or clicking on the 'Mark' icon:

g. Click on the contact 'C002'.


Drag the contact to the left powerrail until it is positioned
below 'Motor_Start'.

PAGE 24 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

h. Release the mouse button to drop the contact 'C002':


Figure 20:
Moving the contact

STEP 5 DECLARING THE PROPERTIES OF THE COUNTER'S


'RESET' CONTACT

Next we declare the properties of the reset contact 'C002'.

a. Double click on the contact 'C002' to open the 'Contact/Coil


Properties' dialog.

b. Change the name from the default name 'C002' to 'Motor'.


Figure 21:
'Contact/Coil
Properties' dialog
for setting the
contact properties

c. Click 'Apply' or press <Enter>. The dialog page 'Common' is


opened automatically.

d. In the list box 'Usage' (see Figure 22) select


'VAR_EXTERNAL' so that the variable will be declared as
global variable, meaning it can be used in each POU of the
project.

e. We now want to assign the variable 'Motor' to our I/O


simulator, so we can test the logic on the screen.

QUICK START GUIDE PAGE 25


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

The input field 'I/O address:' specifies the physical PLC


address for the variable. Enter '%QX0.0' for the declaration
of the variable 'Motor', where 'Q' designates 'Output' and
'0.0' signifies 'first output module.first point'.
Figure 22:
Dialog 'Contact/Coil
Properties' for
setting the contact
properties

Since we have already specified the local and global scope


(i.e. variable group) for the first variable 'Motor_Count', it is
not necessary to select a group for all further variables of
the same groups.
For further information about the location and size prefixes
refer to the Appendix, section 'Variables and Data Types'.

f. Click 'OK' or press <Enter> to confirm the 'Contact/Coil


Properties' dialog. Now your LD worksheet should look as
follows:
Figure 23:
Newly declared
variable 'Motor' in
LD code worksheet

Defining the counter parameters

Defining the counter's preset value:

g. Double click on the blue connection point of the preset value


'PV'.

PAGE 26 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

The 'Variable Properties' dialog appears (see Figure 24).

h. As we want the motor to start after pushing the start button


three times, enter 'INT#3' as preset value in the 'Name' input
field. 'INT' means 'Integer', '#' designates a constant and '3'
is the actual value.
Figure 24:
'Variable Properties'
dialog for defining
the type and name
of a variable

i. Confirm the dialog with 'OK'. The integer value is directly


inserted into the code body.
Figure 25:
Newly declared
constant in LD code
worksheet

Configuring the counter's current value 'CV':

j. Double click on the green connection point of the current


value output 'CV'.

The 'Variable Properties' dialog appears.

k. Enter 'Pressed' as variable name. The current value of the


counter will now be stored in the variable 'Pressed'.

l. Click 'OK'. The dialog page 'Common' is opened


automatically.

The current value is an integer, so select the data type 'INT'


from the 'Data Type' list box.

QUICK START GUIDE PAGE 27


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

Figure 26:
'Variable Properties'
dialog for setting the
variable properties

m. Click 'OK'. Your worksheet should look as follows:


Figure 27:
Newly declared
variables in LD
code worksheet

Configuring the coil 'C001':

n. Double click on 'C001'. The 'Contact/Coil Properties' dialog


appears.

o. For this coil we select the existing variable 'Motor'. The list
below the 'Name' input field contains all variables which
have already been declared (local or global), depending on
the activated scope radio button.
From the list select the local variable 'Motor'.

PAGE 28 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

Figure 28:
'Contac/Coil Properties'
dialog for selecting a
variable for a coil

p. Since we want the motor to run continuously after we


started it, we will use a SET coil.
From the 'Type' list box select '-(S)-' (see Figure 28).

q. Click 'OK'. Your worksheet should look as follows:


Figure 29:
Inserted 'Motor'
variable

QUICK START GUIDE PAGE 29


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

STEP 6 INSERTING A SECOND LD NETWORK AND EDITING


NETWORK DESCRIPTION COMMENTS

Now we want to insert a logic to stop the motor and edit the
network description comments.

a. Click with the left mouse button at a suitable distance below


the existing LD network, to set an insertion mark at the
position shown below.
Figure 30:
Insertion mark for
inserting a second
LD network

Place cursor here

b. Click on the 'Contact Network' icon to insert a new LD


network:

Figure 31:
Second LD network
inserted in the LD
code body
worksheet

c. Double click on the contact 'C003' to declare the contact


properties.

d. In the 'Contact/Coil Properties' dialog which appears select


the local variable 'Motor' from the list:

PAGE 30 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

Figure 32:
Dialog 'Contac/Coil
Properties' for
setting the variable
type for the contact

e. Click 'OK'. The variable 'Motor' is inserted at contact 'C003'.


Inserting a timer:

Now we will insert the timer that controls how long the motor
will run.

f. Open the Edit Wizard by clicking on the 'Edit Wizard' icon in


the toolbar.

g. In the second LD network, mark the line between 'Motor'


and 'C004' to insert and connect a function block at this
position.
Figure 33:
Marked line

h. From the Edit Wizard's 'Group' list box select the group
'Function blocks'.

QUICK START GUIDE PAGE 31


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

i. From the list of function blocks select the timer 'TON' ('Timer
On Delay') and insert it by double clicking on it.

j. The dialog 'Variable Properties' appears. Enter 'M_Time' as


instance name in the 'Name' input field:
Figure 34:
Dialog 'Variable
Properties' for
declaring the
instance name

k. Click 'OK'. The 'Common' dialog page is opened


automatically. Confirm the dialog with 'OK'.
Since you have marked the line before inserting the object,
the function block will be inserted and connected directly at
the specified position.
Your screen should look as follows:
Figure 35:
LD code worksheet
with second LD
network and
function block
'TON'

l. Hide the Edit Wizard by clicking on the 'Edit Wizard' icon


again:

PAGE 32 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

Now we want to determine the timer's preset time 'PT', which


will control how long the motor runs:

m. Double click on the blue connection point of input 'PT'.

The 'Variable Properties' dialog appears.


Figure 36:
'Variable Properties'
dialog for declaring a
local variable

n. Enter 'T#20s' as time constant in the 'Name' input field. Here


'T' designates a time value, '#' signifies 'constant' and '20s'
is the actual time value of 20 seconds (because we want the
motor to run 20 seconds).

o. Click 'OK'. The constant 'T#20s' is inserted directly at the


input PT (see Figure 39).

Now we are going to define a variable to hold the elapsed


time 'ET':

p. Double click on the green connection point of output 'ET'.

The 'Variable Properties' dialog appears.

q. Enter 'Actual_Time' as name for the local variable.

QUICK START GUIDE PAGE 33


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

Figure 37:
'Variable Properties'
dialog for declaring a
local variable

r. Click 'OK'. The 'Common' dialog page is opened


automatically.

s. The timer output 'ET' needs a variable of the data type


'TIME'. For that reason, select the data type 'TIME' from the
'Data type' list box.
Figure 38:
'Variable Properties'
dialog for declaring a
local variable

PAGE 34 QUICK START GUIDE


DEVELOPING THE LD CODE DEVELOPING A SAMPLE PROJECT

t. Click 'OK' to insert the newly declared variable.

Your worksheet should look as follows:


Figure 39:
LD code worksheet
with second LD
network and
function block
'TON'

The last variable we have to declare is the one for the coil
'C004'.

u. Double click on the coil 'C004' to open the 'Contact/Coil


Properties' dialog. Select the variable 'Motor' from the
variable list.

v. This coil will stop the motor when energized. Since we use a
Set coil to start the motor, we need to use a Reset coil to
stop it.
So set the coil type to 'RESET' by selecting the
corresponding list box entry as shown in the following figure.
Figure 40:
'Contact/Coil
Properties' dialog
for setting the coil
and variable type

w. Click 'OK'. Your worksheet should look as follows:

QUICK START GUIDE PAGE 35


DEVELOPING A SAMPLE PROJECT DEVELOPING THE LD CODE

Figure 41:
LD code worksheet
with inserted
second LD network
and function block
'TON'

Finally, we will insert the network description comments.

x. Double click on the left powerrail in the LD code worksheet:


Figure 42:
Marked powerrail

The 'Comment' dialog appears:


Figure 43:
'Comment' dialog
for entering
comments in the
LD code worksheet

y. In the 'Comment' dialog type 'Motor Control Circuit'.

By clicking on the button 'Font >>', you can change the font
properties. Select 'blue' as color and the font width '20'.

z. Click 'OK'.

PAGE 36 QUICK START GUIDE


COMPILING THE EXAMPLE PROJECT DEVELOPING A SAMPLE PROJECT

PHASE 3 COMPILING THE EXAMPLE PROJECT

Now that the editing process is finished we have to compile the


project. During compilation the contents of the worksheets are
translated and transformed to special code which can be
executed by your PLC.

The programming system provides several possibilities for


compiling. For detailed information please refer to the online
help.

STEP 1 'MAKING' THE PROJECT

a. In our example we are working with the simulation. Make


sure, that the simulation has been activated. To do so, right
click in the project tree on the folder 'Resource' and select
'Settings...' from the appearing context menu:
Figure 44:
Project tree with
context menu for
calling the resource
settings

The 'Resource settings' dialog appears:

QUICK START GUIDE PAGE 37


DEVELOPING A SAMPLE PROJECT COMPILING THE EXAMPLE PROJECT

Figure 45:
Dialog 'Resource
settings' for setting
the output device

b. Activate 'Simulation 1', if necessary, and close the dialog


with 'OK'.

c. Click on the 'Make' icon in the toolbar:

The compilation process is displayed in the 'Build' tab of the


message window. Errors and warnings detected during
compilation are logged in the corresponding sheets of the
message window. You can use the message window to access
a particular code body worksheet by double clicking on the error
message.
Figure 46:
Message Window
after compiling the
project using the
'Make' command

PAGE 38 QUICK START GUIDE


COMPILING THE EXAMPLE PROJECT DEVELOPING A SAMPLE PROJECT

STEP 2 HANDLING ERRORS AND MESSAGES

During the 'Make' process it is possible that you will detect


errors or warnings.

Errors will prevent the compile process from being completed


and include such issues as syntax errors or structure problems.
Warnings indicate potential problems like a variable that is not
being used. Warnings do not prevent the compilation process
from being completed.

You can ignore warnings, but you must fix errors to proceed
with the exercise.

 To display the detected errors, click on the 'Errors' tab in


the message window.
A list of the errors will then be displayed in the message
window.

 In order to display the list of warnings, click on the


'Warnings' tab.

 In most cases double clicking on an error/warning will


directly open the worksheet in which the programming
error/the reason for the warning has occurred. The
corresponding line or object is marked.
You can also mark the error and press <SHIFT> + <F1>
to get the corresponding help topic with information on the
cause of the error and the further steps necessary to fix it.

 Fix all errors (if any have occurred) and re-compile the
project using the 'Make' icon.

 Only then you can download the program to the PLC.

QUICK START GUIDE PAGE 39


DEVELOPING A SAMPLE PROJECT DOWNLOADING THE PROJECT TO THE PLC OR IO SIMULATION

PHASE 4 DOWNLOADING THE PROJECT TO THE PLC OR


IO SIMULATION

Now, the compiled project has to be downloaded (i.e. sent) to


the PLC or I/O Simulation.

The communication with the PLC or the simulation is done


using the PLC control dialog, named 'Resource'.

When working with several resources, different dialogs are


used to download a project and control the targets.
Please refer to the online help system for detailed information.

a. Click on the 'Project Control Dialog' icon to open the


resource control dialog.

The control dialog appears showing the resource name in


its titlebar.
Figure 47:
'Resource' dialog
for controlling the
PLC or simulation

b. Press the 'Download' button.


The 'Download' dialog appears:

PAGE 40 QUICK START GUIDE


DOWNLOADING THE PROJECT TO THE PLC OR IO SIMULATION DEVELOPING A SAMPLE PROJECT

Figure 48:
'Download' dialog
for initiating the
project download

The dialog is used to start the download process. You can send
either a "normal" project or the zipped project source (which can
be used as a backup) to the PLC or simulation.

c. Press the 'Download' button in the 'Project' section to


download the project:

The successful download process is indicated by a blue


status bar at the bottom of the screen.

d. Press the 'Cold' button in the control dialog to execute a


cold start:

The state of the resource changes from 'Stop' to 'Run':

QUICK START GUIDE PAGE 41


DEVELOPING A SAMPLE PROJECT DEBUGGING THE PROJECT

PHASE 5 DEBUGGING THE PROJECT

In the following, the programming system debug tools will be


explained. The system supports several debug tools providing a
fast and easy way to bring your application online.

STEP 1 DEBUG MODE

Worksheets can be switched from edit mode (offline) to debug


mode (online) and vice versa. The Online mode is used to
detect programming errors and to make sure that the PLC
program is running correctly. In Online mode the current values
and states of the variables are displayed.

a. Make sure that the PLC/Simulation is running. The PLC


state is shown at the top of the 'Resource' control dialog. If
the program is not running, perform a cold start by pressing
the 'Cold' button in the control dialog.

b. To activate the debug mode, make sure that the code body
of our POU 'Main' is open, and click on the 'Debug on/off'
icon in the toolbar:

Note that the states and current values of the variables are
displayed in several colors indicating the different states:

 blue = false

 red = true

You can toggle between the online and the offline mode by
clicking on the 'Debug on/off' icon.

c. Click on the button 'DEMOIO - DRIVER' in the Windows


taskbar to open the I/O simulator:
Figure 49:
I/O simulator

PAGE 42 QUICK START GUIDE


DEBUGGING THE PROJECT DEVELOPING A SAMPLE PROJECT

d. If necessary, place the I/O Simulator (by drag and drop) to a


corner of the screen so that the worksheet is not hidden.
e. Turn bit 0 of module 0 on and off three times by clicking on
the first green "virtual LED" of the first input module:
Figure 50:
Toggle bit to start
sample program

Watch the reaction in the worksheet:

 The motor starts running after marking 'Motor_Start' three


times, because the current value 'CV' reaches the preset
value 'PV' (note the update on the screen).
 When the 'Motor' Set coil is switched on, it also starts the
timer 'M_Time' in rung 002.
 'M_Time' (the actual time) runs for 20 seconds until 'ET'
(elapsed time) reaches the preset time value 'PT'. The
'Motor' Reset coil in rung 002 is switched on, thus
unlatching the 'Motor' Set coil in rung 001 and turning the
motor off.

STEP 2 ONLINE EDITING

Online editing is possible without stopping the program


execution on the PLC / simulation. This operation is called
'Patch POU'. When you use 'Patch POU', the changes you
made in the code are compiled, the related code is generated
and then downloaded automatically to the PLC. During the
whole patch process the code execution on the PLC is not
interrupted.

As a Patch POU example we want to insert an Emergency Stop


for the motor: Activating the input 'Emergency_Stop' will stop
the motor immediately.

a. Switch to Offline Mode by clicking on the 'Debug on/off'


icon:

Our code body worksheet appears in editing mode again.


The resource, however, just like a real controller, is still
running:

QUICK START GUIDE PAGE 43


DEVELOPING A SAMPLE PROJECT DEBUGGING THE PROJECT

b. Set the insertion mark in the LD code worksheet below rung


002.

c. Click on the 'Network' icon to insert a new LD network:

Your worksheet should look as follows:


Figure 51:
Inserting an LD
network

d. Double click on the contact 'C005' to open the 'Contact/Coil


Properties' dialog.

e. Change the name from the default name 'C005' to


'Emergency_Stop'.

PAGE 44 QUICK START GUIDE


DEBUGGING THE PROJECT DEVELOPING A SAMPLE PROJECT

Figure 52:
Dialog 'Contact/Coil
Properties' for
setting the contact
properties

f. Click 'OK'. The 'Common' dialog page is opened


automatically.

g. From the list box 'Usage', select 'VAR_EXTERNAL' to


declare 'Emergency_Stop' as a global variable.

h. We will use the second input point in the I/O simulator for
the emergency stop. Enter '%IX0.1' as the address for this
variable in the 'I/O address' input field and click 'OK'.

QUICK START GUIDE PAGE 45


DEVELOPING A SAMPLE PROJECT DEBUGGING THE PROJECT

Figure 53:
'Contact/Coil
Properties' dialog
for setting the
contact properties

For further information on the location and size prefixes


refer to the Appendix, section 'Variables and Data Types'.

i. Double click on the contact 'C006'. The 'Contact/Coil


Properties' dialog appears. Select '-(R)-' from the 'Type' list
box and 'Motor' from the global 'Variable' list box. Then click
'OK'.

Your worksheet should look as follows:


Figure 54:
Online editing,
changed variable
properties

Now that we have changed the code, we make a Patch POU.


This process will compile the changes and download them to
the PLC without stopping the PLC.

PAGE 46 QUICK START GUIDE


DEBUGGING THE PROJECT DEVELOPING A SAMPLE PROJECT

j. Click on the 'Patch POU' icon in the toolbar to compile the


modified code and download it to the I/O Simulator:

After the patch process has been successfully completed,


the worksheet will be automatically set to Online mode.

k. Click on the 'DEMOIO - DRIVER' button in the Windows


taskbar to open the I/O simulator.

l. Turn bit 0 of module 0 on and off three times by clicking on


the corresponding input point (LED) (refer to Figure 50 on
page 43).

m. Use the new Emergency_Stop contact to immediately stop


the motor by clicking on bit 1 of the input module 0 in the
I/O simulator.

STEP 3 CROSS REFERENCE WINDOW

The cross reference list contains all variables, function blocks,


jumps, labels and connectors which are used within the current
project. This tool is particularly helpful for debugging and error
isolation.

a. Click on the 'Cross Reference Window' icon in the toolbar to


open the Cross Reference Window (if not already opened):

b. Place the cursor in the Cross Reference Window and right


click on the window background to open the context menu:
Figure 55:
Cross Reference
Window with
context menu for
building the cross
references

c. Select the menu item 'Build Cross References'.

The cross reference list will be created.

QUICK START GUIDE PAGE 47


DEVELOPING A SAMPLE PROJECT DEBUGGING THE PROJECT

Figure 56:
Cross reference list
in the sample
project

d. Double clicking on a variable in the Cross Reference


Window will open the worksheet in which this variable is
used and highlight the variable.
In addition if you mark a variable in the worksheet, the
corresponding variable in the Cross Reference Window will
be marked as well.

e. Close the Cross Reference Window and the Message


Window by clicking on the corresponding toolbar icons.

and

STEP 4 VARIABLES WATCH WINDOW

The Variables Watch Window is a powerful tool allowing you to


insert different variables easily into a list and observe their
runtime behavior. Once a variable is added to the Watch
Window, the corresponding worksheet does not have to be
open to monitor its current value. As a result, you can focus on
those variables you want to see for easier access.

a. If this is not yet the case, switch the worksheet into Online
Mode by pressing the 'Debug on/off' icon.

b. Right click in the worksheet and select 'Open Watch


Window...' from the context menu or click on the 'Watch
Window' button.

The Watch Window appears.

c. In the online worksheet right click on 'Motor_Start' to open


the context menu and select 'Add to Watch Window' to
insert this variable into the list.

d. Repeat this procedure for the variables 'Pressed' and


'Actual_Time'. The three variables will appear in the list as
shown in the figure below.

PAGE 48 QUICK START GUIDE


DEBUGGING THE PROJECT DEVELOPING A SAMPLE PROJECT

Figure 57:
Variable Watch
Window

You can now use the I/O Simulator to manipulate the


contacts and observe the changes of the values, both in the
logic and in the Watch Window simultaneously.

STEP 5 FORCING AND OVERWRITING

In Online mode variables can be forced or overwritten. In both


cases a new value is assigned to the corresponding variable.
Force: A value is assigned to a variable (usually a contact or
coil). The value remains until the force is reset.
Overwrite: A value is temporarily assigned to a variable by the
user. The value remains until the program overwrites this value
again with the original value in the next program cycle.

The steps necessary for forcing and overwriting a variable are


nearly the same.

Be very careful forcing or overwriting variables while your PLC


is running. Forcing and overwriting variables mean that the PLC
program is executed with the values of the forced or overwritten
variable.

In our example we want to force the variable 'Motor_Start':

a. Make sure, that the worksheet is in Online Mode. If not,


press the 'Debug on/off' icon in the toolbar:

b. Click on the button 'DEMOIO - DRIVER' in the Windows


taskbar to open the I/O simulator.

c. Make sure, that all inputs are set to 'FALSE' by clicking on


each illuminated LED (no input LED should be highlighted).

d. Double click on 'Motor_Start'. The 'Debug: Resource' dialog


appears:

QUICK START GUIDE PAGE 49


DEVELOPING A SAMPLE PROJECT DEBUGGING THE PROJECT

Figure 58:
'Debug: Resource'
dialog for forcing
and overwriting
variables

e. Select the radio button 'TRUE', then click on 'Force'. As a


result 'Motor_Start' will be forced 'on' and highlighted red in
the online worksheet.

f. Double click 'Motor_Start' again and select 'Reset force' to


deactivate the force.

If you repeat the steps e. and f. the logic will start executing.

g. In the 'Debug' dialog click on 'Reset force list.

Now we want to overwrite the variable 'Motor'.

h. Double click on the 'Motor' coil in rung 001, then click on


'Overwrite'. This starts 'Motor_Time'. After 20 seconds, the
'Motor' Reset coil in rung 002 will turn off 'Motor'.

STEP 6 BREAKPOINTS

Breakpoints can be set online in all worksheets using the


controls in the right area of the 'Debug: Resource' dialog shown
in Figure 58.

When a breakpoint is set, program execution halts at that


breakpoint until the developer makes it continue. The
programming system provides the possibility to execute a
program until the next breakpoint is reached (Single Step) or
until the same breakpoint is reached again (Single Cycle).

If a breakpoint is reached, the PLC state changes to HALT


[DEBUG] and the control dialog shows the buttons 'Go', 'Step'
and 'Trace' to continue with.

Go: Clicking 'Go' causes the program to execute until the next
breakpoint is met.

PAGE 50 QUICK START GUIDE


DEBUGGING THE PROJECT DEVELOPING A SAMPLE PROJECT

Step: Clicking 'STEP' causes the program to execute the next


instruction.
Trace: If an user defined function or a function block call is
reached, the function or function block code body is opened
and debugged step by step.

Be very careful using breakpoints while the PLC is running,


since the breakpoint actually halts program execution. The
behavior of the I/Os when reaching a breakpoint depends on
the PLC type.
a. To observe breakpoint operation, the corresponding
worksheet must be in Online mode ('Debug on/off' icon
pressed):

b. Click on the 'PLC Control' icon to open the resource control


dialog:

c. Double click on 'Motor_Start' and select 'Set' in the 'Debug:


Resource' dialog to set a breakpoint at this variable.

'Motor_Start' is highlighted orange in the online worksheet


to indicate the point at which program execution is stopped.

d. Press the 'Go' button in the 'Resource' dialog to activate


program execution until the next breakpoint is met.

QUICK START GUIDE PAGE 51


DEVELOPING A SAMPLE PROJECT DEBUGGING THE PROJECT

As we have set only one breakpoint, the program stops


again on 'Motor_Start'. This is called a Single Cycle.

e. Click on 'Step' several times and notice that the orange


highlight moves to the next instruction each time to indicate
the point at which the program execution has stopped. This
is a Single Step execution. Also notice that 'Motor_Start' has
a red highlight to indicate where the breakpoint has been
set.

f. Double click on 'Motor_Start' and press 'Reset' in the debug


dialog to reset the breakpoint. Then click 'Go' in the
'Resource' dialog to resume program execution.

g. Click on the 'Debug on/off' icon again to switch to Offline


mode:

h. In the Control dialog, click on the 'Stop' button to stop the


PLC, and close the 'Resource' control dialog using the
'Close' button.

and

PAGE 52 QUICK START GUIDE


PRINTING THE PROJECT DOCUMENTATION DEVELOPING A SAMPLE PROJECT

PHASE 6 PRINTING THE PROJECT DOCUMENTATION

For documentation purposes it is useful to print the whole


project. The programming system offers several possibilities to
print your project documentation. The 'File' menu contains the
commands for a preview of the current page, for defining the
printer settings, and for printing the entire project or single
worksheets.

STEP 1 SELECTING A PRINTER

Printer options are located under 'Print Setup...' in the 'File'


menu. Selecting this item will open the standard Windows
dialog 'Print Setup'.

STEP 2 SETTING THE PAGELAYOUT

A pagelayout defines the appearance of printed worksheets


such as the page size, page margins (borders), the source
area, foot and head lines containing information such as a
company's logo, date, project name or page numbers.

The programming system allows the usage of different


pagelayouts. In addition the pagelayouts can be changed.
When printing your project or parts of it the default pagelayout is
used automatically.

To change the default pagelayout:

a. Select menu 'Extras | Options...'.

b. Open the tab 'Pagelayouts'.

c. Select the desired pagelayouts. In our example we use the


default pagelayout.

A pagelayout is created and edited using the pagelayout editor.


For further information refer to your online help system.

QUICK START GUIDE PAGE 53


DEVELOPING A SAMPLE PROJECT PRINTING THE PROJECT DOCUMENTATION

STEP 3 PRINTING THE PROJECT

a. Choose the menu item 'Print Project...' from the 'File' menu.
The 'Print Project' dialog appears.

b. In the 'Print Project' dialog deselect the parts of the project


you do not want to be printed by deactivating the
corresponding checkboxes.
Figure 59:
'Print Project' dialog

c. Click on the 'Print' button.

STEP 4 PRINT PREVIEW

The print preview allows you to have a look at how the


worksheet would look like when being printed and to modify it if
required. It helps you organize the elements on the page in a
clear and structured way.

Cross references are not displayed in the preview.

How to call the preview:

a. Make sure that the worksheet you want to see is the active
window.

b. Choose the menu item 'Print Preview...' from the 'File' menu.
The print preview of the active worksheet will be displayed.

c. To print the single worksheet which is displayed, click on the


'Print' button.

PAGE 54 QUICK START GUIDE


PRINTING THE PROJECT DOCUMENTATION DEVELOPING A SAMPLE PROJECT

STEP 5 PRINTING A SINGLE WORKSHEET

You can print single worksheets that are opened in the graphic
editor or text editor.

Cross references are not printed using the menu item 'Print'.

How to proceed:

a. Make sure that the worksheet you want to print is active.

b. Select the menu item 'Print' from the 'File' menu.


The worksheet will be printed.

QUICK START GUIDE PAGE 55


ADDITIONAL FEATURES USING THE I/O CONFIGURATION

ADDITIONAL FEATURES

USING THE I/O CONFIGURATION

The 'I/O Configuration' dialog is used to edit the I/O


configuration worksheet. The I/O configuration normally
contains declarations of the I/O modules, such as the logical
addresses of a module (start and end address), device
declarations (driver name or memory address), etc.

The following steps explain how to use the I/O Configuration. In


our example we will change the number of input modules in the
existing I/O group to 10.

a. To change the I/O Configuration, double click on the


'IO_Configuration' in the subtree 'Physical Hardware':
Figure 60:
Icon 'IO_Configuration
in the subtree 'Physical
Hardware'

The 'I/O Configuration' dialog appears:


Figure 61:
'I/O Configuration'
dialog

At this point you need to select the driver you will use from
the list and configure it as described in the manual for the
corresponding driver.
The current I/O configuration is shown in the dialog. We
want to change this configuration, i.e. we want to define 10
input modules in the existing group.

b. In the 'I/O Configuration' dialog click on the 'Properties'


button:

The 'Properties' dialog appears.


c. In the field 'Length' enter 10 and press the <TAB> key to
update the entry in the field 'End address':

PAGE 56 QUICK START GUIDE


USING THE I/O CONFIGURATION ADDITIONAL FEATURES

Figure 62:
'Properties' dialog
for configuring the
I/O Simulator

d. Confirm the 'Properties' and I/O Configuration dialogs with


'OK' to return to programming.

e. Compile the project by clicking on the 'Make' icon in the


toolbar.

For detailed information on the compilation refer to Phase 3


on page 37 of this Quick Start Manual.

f. Download the project to the target as described in Phase 4


on page 40.

If the PLC/simulation is still running at this moment, the


following message dialog appears before the download:

If this is the case, click on 'Yes' to continue the download.

QUICK START GUIDE PAGE 57


ADDITIONAL FEATURES USING THE I/O CONFIGURATION

g. Click on the button 'DEMOIO - DRIVER' in the Windows


taskbar to open the I/O Simulator. There should be 10 input
modules available now:
Figure 63:
I/O Simulator after
the
I/O Configuration
has been changed
to 10 input modules

PAGE 58 QUICK START GUIDE


CREATING AN USER DEFINED FUNCTION ADDITIONAL FEATURES

CREATING AN USER DEFINED FUNCTION

In this chapter, we want to insert an user defined function in our


project. The function should be generated using the textual
language ST. It counts how often the motor has been active.

Before you start:


Select 'Extras | Options'. In the 'Options' dialog go to the
'Graphical editor' tab and ensure that 'Functions with EN/ENO'
is enabled:

EN/ENO designates an additional boolean input 'EN' (= enable)


and output 'ENO' (= enable output) for IEC 61131 functions in
the programming languages LD and FBD.

EN/ENO is not supported for all targets.

a. To insert an user defined function, click on the 'Add


Function' button in the toolbar:

The 'Insert' dialog appears.

b. Enter 'Cycle_Count' as name and select the language 'ST'.


In the 'Datatype of return value' field you specify which
datatype is applied to the function output. The variable
connected to the function output has to fit to the datatype of
the return value. In our example we use 'INT'.
Figure 64:
Dialog 'Insert' for
inserting an user
defined POU

QUICK START GUIDE PAGE 59


ADDITIONAL FEATURES CREATING AN USER DEFINED FUNCTION

c. Press 'OK'. The function is added to the project tree. The


asterisk at the end of the function name indicates that the
new POU has not yet been compiled.

d. Open the code worksheet 'Cycle_Count' for editing the ST


code by double clicking on it.

e. In the worksheet, enter the following code:

This line of code will generate a value that continuously


increments each time the motor is started.

f. Place the cursor on the variable 'Count':

g. Click on the 'Variables' icon

and declare the local variable as 'INT' and 'VAR_INPUT' as


shown in Figure 65:
Figure 65:
Dialog 'Variables'

PAGE 60 QUICK START GUIDE


CREATING AN USER DEFINED FUNCTION ADDITIONAL FEATURES

h. Confirm the dialog with 'OK'. The declaration will be


automatically inserted in the variables worksheet of the new
ST POU.

i. Close the ST worksheet and save the changes.

After closing the ST worksheet, the new user defined


function is available in the Edit Wizard and can be inserted
into other worksheets of the project.

We now want to call the user defined function 'Cycle_Count'


in our program POU 'Main'.

j. In the code body of the program 'Main', set the insertion


mark below the LD network '003' and insert a new network
using the 'Network' icon.

k. Mark the LD network '004' line between C007 and C008.

l. Open the Edit Wizard and select the group


'My_First_Project':

This group contains all user defined functions and function


blocks of the current project (only 'Cycle_Count' in our
example).

m. Double click on the function 'Cycle_Count' to insert this user


defined function at the position specified before.
Figure 66:
Inserted user
defined function
'Cycle_Count'

Having done this, close the Wizard again.

Now we have to connect a new variable to input 'Count' so


that we can see the internal value.

QUICK START GUIDE PAGE 61


ADDITIONAL FEATURES CREATING AN USER DEFINED FUNCTION

n. Double click on the blue connection point of the 'Count'


input of 'Cycle_Count'.

o. The 'Variable Properties' dialog appears.

p. Declare the local variable 'Motor_Cycles' as follows:


Figure 67:
Dialog 'Variable
Properties''

q. Confirm the dialogs with 'OK' to insert the variable into the
code body and its declaration into the local variables
worksheet.

The same variable now has to be connected to the function


output.

r. Double click on the green connection point of the output of


'Cycle_Count' and select the variable 'Motor_Cycles' from
the variables selection list of the 'Variables Properties'
dialog.

s. Confirm with 'OK' to insert the variable.

PAGE 62 QUICK START GUIDE


CREATING AN USER DEFINED FUNCTION ADDITIONAL FEATURES

t. Change the name of contact 'C007' to 'Motor' using the


'Contact/Coil Properties' dialog. To open the dialog double
click on the contact.

Be sure that the contact 'Motor' is marked.

u. Activate the Edit Wizard. Select the group 'Function blocks'


and insert the function block R_TRIG by double clicking on
it.

v. Enter 'Motor_Edge' in the 'Name' field of the


'Variable Properties' dialog.

w. Press 'OK'. The 'Common' dialog appears. Enter a


description if desired and press 'OK' again to insert the
function block and its declaration.

x. Hide the Edit Wizard by clicking on the 'Edit Wizard' icon


again:

As the contact 'Motor' was marked when selecting the


function block in the Edit Wizard, 'Motor_Edge' is directly
connected to 'Motor'.

y. Double click on the coil 'C008'.

z. Declare the coil as follows:

QUICK START GUIDE PAGE 63


ADDITIONAL FEATURES CREATING AN USER DEFINED FUNCTION

Figure 68:
'Contact/Coil
Properties' dialog

Compile the project using the 'Make' icon, start and then
download it.

Now our sample project is complete. You can check the


behavior of the program using the worksheets in Online mode
and the programming system I/O Simulator (refer to Phase 5 on
page 42 of this manual).

a. Switch the worksheet into online mode and click on the


button 'DEMOIO - DRIVER' in the Windows taskbar to open
the I/O Simulator.

b. Turn bit 0 of module 0 on and off three times by clicking on


the input point.

The program executes:

PAGE 64 QUICK START GUIDE


CREATING AN USER DEFINED FUNCTION ADDITIONAL FEATURES

Notice that each time the logic in the main program executes
(motor starts, runs 20 seconds and stops) the value of
'Motor_Cycles' is incremented by 1.

It is possible to jump into the user defined function


'Cycle_Count' (i.e. to call the related code body worksheet)
without leaving the current worksheet.

a. Double click on the function 'Cycle_Count' in the LD


worksheet.
The following dialog appears:

QUICK START GUIDE PAGE 65


ADDITIONAL FEATURES CREATING AN USER DEFINED FUNCTION

b. Confirm the dialog with 'Yes' to switch from variable status


to powerflow.
The code body worksheet of the function 'Cycle_Count' will
be opened. In the now activated powerflow, the current
values of the accumulator are displayed in the worksheet by
symbols.

Detailed information about powerflow and the symbols used


can be found in the online help system.

c. Close the code body worksheet to return to the LD


worksheet.

PAGE 66 QUICK START GUIDE


CHANGING THE TASK CYCLE TIME ADDITIONAL FEATURES

CHANGING THE TASK CYCLE TIME

The programming system allows you to change the Task Cycle


Time, i.e. the time interval in which the cyclic task is executed.
Thus, decreasing the task cycle time will speed up process
execution. It is important to get the execution of the cycle as
close to scan time as possible.

In our example we change the Task Cycle Time from 100ms to


90ms.

The shortest possible Task Cycle Time depends on the PLC


used.

a. Make sure, that the system is in Offline mode, i.e. the icon
'Debug on/off' is not pressed.

b. To change the Task Configuration, right click on the


'TASK : CYCLIC' icon in the subtree 'Physical Hardware'. In
the context menu that appears select 'Settings...'.

QUICK START GUIDE PAGE 67


ADDITIONAL FEATURES CHANGING THE TASK CYCLE TIME

The dialog 'Task settings for IPC_32' appears:


Figure 69:
Dialog 'Task
settings for IPC_32'
for changing the
Task Cycle Time

The current Task Configuration is shown in the dialog. We


want to change the Task Cycle Time from 100ms to 90ms.

c. In the field 'Interval' enter 90 and click 'OK' to confirm the


dialog.

d. Compile the project by clicking on the 'Make' icon. For


detailed information on the compilation refer to Phase 3 on
page 37 of this Quick Start Manual.

e. Download the project to the target as described in Phase 4


on page 40.

If the PLC/simulation is still running, the following message


dialog appears before the download:

If this is the case, click 'Yes' to continue the download.

f. If desired, debug the project as described in Phase 5,


'Debugging the project' on page 42 of this manual.

PAGE 68 QUICK START GUIDE


IEC PROJECT COMPONENTS IN THE PROGRAMMING SYSTEM APPENDIX

APPENDIX

IEC PROJECT COMPONENTS IN THE


PROGRAMMING SYSTEM

Programming systems that conform to IEC 61131-3 contain the


following component elements:

 Configurations

 Resources

 Tasks

These will be displayed if you select the 'Hardware' tab of the


project tree.

Configurations can be compared to a programmable controller


system such as a rack.
Resources can be compared to a CPU that can be inserted in
the rack. In a resource, global variables can be declared which
are only valid within this resource. In a resource, one or several
tasks can be executed.

In general, tasks determine the time scheduling of the


associated programs. This means that programs have to be
associated to tasks. The settings of the task determine the time
scheduling. The system provides one cyclic task to be assigned
to your program.

PROGRAM ORGANIZATION UNITS (POUS)


Program organization units (POUs) are the language building
blocks of an IEC 61131-3 control program. They are small,
independent software units containing the program code. The
name of a POU must be unique within the project.

In IEC 61131-3 three types of POUs are supported:

 Functions

 Function blocks

 Programs

Functions are POUs with multiple input parameters and exactly


one output parameter. Calling a function with the same values
returns always the same result. Return values can be single
data types. Within a function it is possible to call another
function but not a function block or a program. Recursive calls
are not allowed.

QUICK START GUIDE PAGE 69


APPENDIX IEC PROJECT COMPONENTS IN THE PROGRAMMING SYSTEM

IEC 61131-3 lists different types of standard functions:

 Type conversion functions, such as ANY_INT_TO_REAL

 Numerical functions, such as ABS and LOG

 Standard arithmetic functions, such as ADD and MUL

 Bit-string functions, such as AND and SHL

 Selection and comparison functions, such as SEL and GE

 Character string functions, such as RIGHT and INSERT

 Functions of time data types, such as SUB with the data


type TIME ('SUB_T_T')

Function blocks are POUs with multiple input/output


parameters and internal memory. The value returned by a
function block depends on the value of its internal memory.
Within a function block it is possible to call another function
block or functions. Recursive calls are not allowed.

IEC 61131-3 lists different types of standard function blocks:

 Edge detection function blocks, such as R_TRIG and


F_TRIG

 Counters, such as CTU and CTD

 Timer function blocks, such as TON and TOF

 Bistable function blocks SR and RS


Programs are POUs that contain a logical combination of
functions and function blocks according to the needs of the
controller process. The behavior and the use of programs are
similar to function blocks. Programs have an internal memory.
Programs must be associated to tasks. Within a Program it is
possible to call functions and function blocks. Recursive calls
are not allowed.

PAGE 70 QUICK START GUIDE


INSTANTIATION OF POUS AND FUNCTION BLOCKS APPENDIX

INSTANTIATION OF POUS AND FUNCTION


BLOCKS

According to IEC 61131-3 the code of a FB POU (Function


Block) can be reused in a project by calling the FB in another
POU using an unique name. This is known as "Instantiation". By
calling the FB instance the FB code must be defined only once.
If the FB instance is called, the internal memory of the FB is
allocated to the called instance. This allows the use of different
memory areas.

Each instance has an associated identifier the "instance name"


and contains the input and output parameters and the internal
memory for the POU or FB. A FB can be instantiated in another
FB or in a program. The instance name of an FB has to be
declared in the VAR declaration of the program or FB where it is
going to be used.

VARIABLES AND DATA TYPES


Another powerful feature of IEC 61131 is the use of variables
rather than the direct addressing scheme of traditional PLC
systems. This increases flexibility and broadens the scope of
functionality that can be performed in the programs.

VARIABLE TYPES
Variables must be declared first in order to be used in the logic.

When inserting a variable into a worksheet, you can declare two


variable types:

1. Local variables

2. Global variables

A local variable is only used in one POU, whereas a global


variable can be used in every POU of the corresponding
project.

The local variable is declared in the local variables worksheet


of the POU in which it is used.

The global variable has to be declared as 'VAR_GLOBAL' in


the global variables' declaration of a resource and as
'VAR_EXTERNAL' in each POU in which it is used.

The programming system provides for automatic declaration of


variables and their properties during program creation as the
I/O address/logical name are assigned. Variables can also be
manually declared in the variables worksheet.

QUICK START GUIDE PAGE 71


APPENDIX VARIABLES AND DATA TYPES

VARIABLES ADDRESSES

You can directly address your variables using the 'I/O address'
input field.

In accordance to IEC 61131, a location declaration consists of


the keyword AT, the percent sign '%', a location prefix, a size
prefix and the name of the logical address.
In the programming system it is not necessary to enter the
keyword AT and the percent sign '%'.
Example of a possible variable address: 'QX0.0'.

The following table shows the location and size prefixes for
located variables:

Location prefix Description

I Physical input

Q Physical output

M Physical address in the PLC memory

Size prefix Description

X Single bit size (only with data type BOOL)

None Single bit size

B Byte size (8 bits)

W Word size (16 bits)

D Double word size (32 bits)

When declaring a variable in the system the 'Variables


Properties' dialog is automatically opened. Using this dialog the
declaration of the current variable is inserted or changed
automatically in the corresponding variables' worksheet.
Local variables are inserted in the variables worksheet of the
corresponding POU in the project tree, global variables in the
global variables' worksheet in the subtree 'Physical Hardware'.

The 'Variables Properties' dialog can also be called by clicking


on 'Properties'.

If you want to have a look at the declarations, click on the


'Variables Worksheet' icon in the toolbar

to open the variables grid worksheet of the POU (local


variables grid worksheet):

PAGE 72 QUICK START GUIDE


VARIABLES AND DATA TYPES APPENDIX

Figure 70:
Local variables grid
worksheet

or double click on 'Global Variables' in the project tree to open


the global variables grid worksheet:
Figure 71:
Global variables
grid worksheet

DATA TYPES

Data types determine the kind of value the variable can have.
Data types define the initial value, range of possible values and
the number of bits.

IEC 61131-3 distinguishes three kinds of data types:

 Elementary Data Types:


The value ranges and size of elementary data types
described in IEC 61131-3 are shown in the following table:

QUICK START GUIDE PAGE 73


APPENDIX VARIABLES AND DATA TYPES

Data Description Size Range


Type

BOOL Boolean 1 0...1

SINT Short integer 8 -128...127

INT Integer 16 -32768 ... 0 ... 32767

DINT Double 32 -2,147,483,648 up to


integer 2.147.483.647

USINT Unsigned 8 0 up to 255


short integer

UINT Unsigned 16 0 up to 65535


integer

UDINT Unsigned 32 0 up to 4.294.967.295


double
integer

REAL Real 32 +/-1.18 x 10^-38 up to


numbers +/-3.40x10^38

TIME Duration 32 +# 4.294.976.295 ms up to


+# 4.294.976.295 s

BYTE Bit string of 8 0x00...0xFF


length

STRING Sequence of 80
characters

WORD Bit string of 16 0x0000 ... 0xFFFF


length

DWORD Bit string of 32 0x00000000 ...


length 0xFFFFFFFF

 Generic Data Types:


Generic data types include groups of elementary data
types. They are called e.g. ANY_BIT or ANY_INT.

 User Defined Data Types:


User Defined data types are groups of different data
types, assembled for a specific purpose, and defined as
ARRAYs and STRUCTures.

PAGE 74 QUICK START GUIDE

You might also like