CODESYS Installation and Start-1
CODESYS Installation and Start-1
User Documentation
CODESYS® is a registered trademark. Technical specifications are subject to change. Errors and omissions excepted. No reproduction or distribution, in whole or in
part, without prior permission. Note: Not all CODESYS features are available in all territories. For more information on geographic restrictions, please contact
[email protected].
Version: 18.0
Template: templ_tecdoc_en_V3.0.docx
File name: CODESYS Installation and Start.docx
© CODESYS Group
CONTENT
Page
1 Welcome 3
2 System Requirements and Installation 3
3 Recommendations for Data Protection 3
4 Start 3
5 Help 3
6 Creating and Running a Project 3
6.1 Start CODESYS and create a project 4
6.2 Write a control program 5
6.3 Insert and configure the objects for running and controlling the
program on the PLC 7
6.4 Run and watch the application on the PLC 9
6.5 Debug an application 11
7 Remove, Modify, or Repair the Installation 12
Change History 13
Teate: templ_tecdoc_en_V3.0.docx
© CODESYS Group
3/13 CODESYS V3: Installation and Getting Started
Welcome
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.)
Teate: templ_tecdoc_en_V3.0.docx
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.
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
© CODESYS Group
4/13 CODESYS V3: Installation and Getting Started
Creating and Running a Project
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.)
Click CODESYS <version> in the Start menu of your computer, or click 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:
Select the CODESYS Control Win V3 device and Structured Text (ST) implementation language for the
automatically created PLC_PRG. Click OK to confirm.
© CODESYS Group
5/13 CODESYS V3: Installation and Getting Started
Creating and Running a Project
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.
© CODESYS Group
6/13 CODESYS V3: Installation and Getting Started
Creating and Running a Project
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:
Teate: templ_tecdoc_en_V3.0.docx
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:
© CODESYS Group
7/13 CODESYS V3: Installation and Getting Started
Creating and Running a Project
In the device tree, select the Application object. In the context menu or in the Project menu, click Add Object.
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:
Teate: templ_tecdoc_en_V3.0.docx
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.
Teate: templ_tecdoc_en_V3.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.
© CODESYS Group
9/13 CODESYS V3: Installation and Getting Started
Creating and Running a Project
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.
Click Login (in the context menu when the application object is selected, or in the Online menu). A dialog opens:
"Application ‘Application‘ does not exist on device ‘PLCWinNT‘. Do you want to create it and continue with
download?"
Click Yes to start the build and download of the application.
The build messages are displayed in the message view. In the case that the example has been configured
correctly, no compile errors are expected and the application can now be started on the PLC (see (11)).
© CODESYS Group
10/13 CODESYS V3: Installation and Getting Started
Creating and Running a Project
be useful for debugging purposes when specific variables need to be watched at a glance.
In the View menu, click "Watch - Watch 1". The view opens.
In the Expression column, click in the first row to open an input field. Specify the path for the variable to be
watched. We recommend that you use the Input Assistant for this ( button): "PLCWinNT.PLC_PRG.ivar".
Press the enter key to close the input field. The data type of the variable is configured automatically in the row.
Insert more rows for other variables. The watch list displayed below contains only expressions from PLC_PRG,
but of course any set of variables from all POUs of the project can be combined. Note in the case of instance
variables, such as for those of FB1 instances, that it is enough to specify the expression "PLC_PRG.fbinst". The
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:
© CODESYS Group
11/13 CODESYS V3: Installation and Getting Started
Creating and Running a Project
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
can be edited or new ones can be added.
Note that the breakpoint positions are saved even when you log out of the PLC. The next time you log in, they
will be displayed as light red markers and can be reactivated.
Now you have built your first project with CODESYS V3 and run it in the PLC. For more information
about using the development system, see the current help.
We wish you success in your programming, and we appreciate any feedback.
© CODESYS Group
12/13 CODESYS V3: Installation and Getting Started
Remove, Modify, or Repair the Installation
© CODESYS Group
13/13 CODESYS V3: Installation and Getting Started
Change History
Change History
3.0 Release after adaptations in chap.6.3 (default device) and 6.4 MN 26.03.2007
(monitoring possibilities)
18.0 CDS-77782: New template applied, release after formal review MN 14.07.2021
© CODESYS Group