CODESYS V3: Installation and Getting Started: User Documentation
CODESYS V3: Installation and Getting Started: User Documentation
User Documentation
Version: 17.0
Template: templ_tecdoc_en_V1.0.docx
File name: CODESYS Installation and Start.docx
1 Welcome
Before you install CODESYS, be aware of the system requirements described in the CODESYS Store.
Run the file Setup_CODESYSV<Version>.exe to start the installation wizard which will guide you through the
installation.
In order to minimize the risk of data security breaches, we recommend the following organizational and
technical measures for the system that will run your applications:
Whenever possible, avoid exposing PLCs and controller networks to public networks and Internet. Use
additional data link layers for protection, such as a VPN for teleaccess, and install firewall mechanisms.
Restrict access to authorized persons only, and change any existing default passwords during the initial
commissioning, and change them regularly.
If you still want to publish your web visualization, then we strongly recommend that you assign it at least a
simple password protection to prevent access to the functionality of your PLC over the Internet. (As an example,
see the project "SimpleWebvisuLogin.project" which is provided with the standard installation setup of the
programming system.)
Use the latest versions of Gateway Server and the Web Server. A security hole was detected for the Gateway
Server and the Web Server up to V3.4 SP4 Patch 2 (US ICS CERT: ICS-ALERT-12-097-02). This was fixed in
V3.5 and later.
4 Start
Start CODESYS from the Start menu (by default, the path is Programs –> CODESYS <version>).
You can also click the CODESYS icon that is located on the desktop after installation.
Template: templ_tecdoc_en_V1.0.docx
5 Help
Help is provided in the Help menu, as well as the context-sensitive <F1> key. Currently, the web-based online
help opens by default. This can be disabled in the CODESYS options so that the offline help (CHM format) is
used.
See in the following a description on how to create a simple project containing a PLC program. Moreover, it
describes how to download this program via a Gateway Server to the PLC (target system) and run and monitor
it. The CODESYS Control Win V3 controller target runtime used for the example is installed with the standard
CODESYS setup.
The sample program is created in structured text and consists of a program PLC_PRG and a function block
FB1.PLC_PRG contains a counter variable ivar and calls function block FB1 . FB1 receives a value from PLC_PRG
at the input in, adds "2" to it, and displays the result in the output out. Then out is read by PLC_PRG.
(Note that the following description refers to the default configuration of the user interface which is available
after a default installation of the development system.)
You can also start CODESYS by clicking the CODESYS icon which is available on the desktop after
installation.
In the New Project dialog, select Standard project template and specify a Name and Location for the project file.
Click OK to confirm.
The Standard Project dialog opens:
Template: templ_tecdoc_en_V1.0.docx
Select the CODESYS Control Win V3 device and Structured Text (ST) implementation language for the
automatically created PLC_PRG. Click OK to confirm.
Now the project name is displayed in the title bar of the CODESYS user interface and as a symbolic root node
in the POU view and the device view.
In the declaration part, place the cursor after VAR and press the enter key to insert a blank line. Type in the
following declarations here: ivar and erg of type INT, as well as fbinst of type FB1:.
PROGRAM PLC_PRG
VAR
ivar: INT;
fbinst: FB1;
erg: INT;
END_VAR
You can also type in lines of code without any previous declarations in the implementation part. Then when you
set the focus in a variable name, a light bulb symbol will appear, which you can click to get the declaration
possibilities: see (4).
smart tag function. In the implementation part, set the cursor in a variable identifier und click the symbol
below it. Click Declare variable to open the following dialog for you to declare a variable:
The variables name and its scope, as well as the current POU (Object) are provided automatically. Now specify
the desired data type according to the declaration described in (3).
Click OK to confirm the dialog. Then the declaration of erg is inserted in the declaration part. The comment is
displayed above the declaration line:
Template: templ_tecdoc_en_V1.0.docx
Select POU. In the Add POU dialog, type in the name FB1 and for Type, select the Function block option.
For Implementation language, select Structured Text (ST). Click the Add button to confirm.
Another editor window opens where the function block FB1 can be edited. Declare the following variables there:
FUNCTION_BLOCK FB1
VAR_INPUT
in:INT;
END_VAR
VAR_OUTPUT
out:INT;
END_VAR
VAR
ivar:INT:=2;
END_VAR
6.3 Insert and configure the objects for running and controlling the program on the PLC
(6) Start the Gateway Server and the PLC
Start the Gateway Server:
By default, the GatewaySysTray program is installed with the installation of CODESYS. You can use this
program to communicate with the Gateway Server. You can call it by means of the system tray.
The Gateway Server is started automatically as a service when the system starts. Check whether or not the
symbol is displayed in the system tray at the bottom edge of the screen. When the symbol is displayed, the
Gateway is stopped.
Start the PLC:
By default, the ControlSysTray program is installed with the installation of CODESYS. You can use this program
to show the CODESYS Control service. The controller (CODESYS Control Win V3) is available as a service
when the system starts. In V3.5 SP2 and later, the control service is no longer automatically started when the
system starts. To start the PLC, do the following:
In the system tray, right-click the icon. A context menu opens.
In the context menu, click Start PLC. The icon changes to .
Note: Check the options for accessing the PLC. PLCs must never be accessible from the Internet or
untrustworthy networks under any circumstances. In particular, the programming ports of the PLC must never
be accessible from the Internet without security protection (mostly UDP ports 1740..1743 and TCP ports 1217 +
11740 and the PLC-specific ports). If access from the Internet must nevertheless be granted, then it is
imperative that a secure method be selected to connect to the PLC (e.g. VPN).
In the Devices window the name ‘Application’ is displayed in bold letters. This means that this application is set
as “active application”. Thus all commands and actions concerning the communication with the PLC will refer to
this application. In order to set an application as “active one” select the application entry in the Devices window
and choose command Set Active Application from the context menu.
The Gateway Server is provided with the CODESYS setup. In the Gateway menu, click Add New Gateway to
open the following Gateway dialog:
Specify a symbolic Name for the gateway. Set the driver type to TCP/IP and specify the IP address as localhost.
(In the Value column, select the field. Press the space bar to open an input field.) Leave the Port unchanged
and click OK.
The Gateway is entered in the field on the left part of the Communication Settings dialog and added to the list
box for Select the Network Path to the Controller. When the gateway is running correctly, a solid green circle is
displayed at the symbol of the entry. Otherwise, a red circle is displayed.
Template: templ_tecdoc_en_V1.0.docx
Now define the communication channel to the device, which is then used via the set Gateway.
Click the Scan Network button to search for all devices in the local network that you can communicate with.
Select the device with the name of your computer and click OK.
This sets the channel as active, which means that all communication actions apply specifically to it. Remember
this later when you have multiple communication channels in the project.
Click OK to close the Communication Settings dialog and apply the settings.
individual parameters are inserted automatically and the corresponding rows can be opened by means of the
plus sign at the front of each row. The current value of each expression is displayed in the value column:
If you have not already done it, in the online menu, click Start Application. Now the program runs on the PLC
and the current values are displayed in the Value column:
Writing and forcing of values is possible in the same way as described above in 2.
To disconnect from the PLC, select the application object and in the context menu click Logout.
Now you can press <F8> repeatedly to execute the Step Into command in the Debug menu and run the
program in steps. This also steps into the function block instance. To skip this function block processing, instead
of <F8> you can press <F10> to execute the Step Over command. The current variable values are displayed at
the processing position just reached.
See also the Breakpoints dialog (View -> Breakpoints). The currently defined breakpoints are listed here and
Template: templ_tecdoc_en_V1.0.docx
Change History
3.0 Release after adaptations in chap.6.3 (default device) and 6.4 MN 26.03.2007
(monitoring possibilities)