Getting Started CoDeSys Program - EN PDF
Getting Started CoDeSys Program - EN PDF
Getting Started CoDeSys Program - EN PDF
CoDeSys program
IEC-line series
update: 09-01-2014
IEC-line by OVERDIGIT
overdigit.com
2.
Selecting, for example, the WP240 target, the options window will be displayed:
IEC-line by OVERDIGIT
Page 2
The target options are grouped into several pages (tabs). Of particular interest are some options on
the "General" page:
The "Online Change" allows you to update the program on the PLC (with download function)
without stopping the execution of the previous version. Enabling of this option is recommended
only if this feature is requested.
The "Load bootproject automatically" creates and automatically transfers, after each download of
the program, an executable version required each time the PLC restarts (working version). This
function can also be done manually once, using the "Online>Create boot project" menu at the end
of the program development. However, in this case, the transfer of the boot program in the PLC
occurs only if the online connection is already active otherwise it is only created the boot program
in the PC folder of the project.
Another option page of the target of particular interest is "Visualization":
IEC-line by OVERDIGIT
Page 3
In particular the "Web visualization" option allows the creation of graphic pages and transfer this to
the PLC memory. These pages can then be viewed through the Web server capabilities, even
remotely, via a Web browser.
We recommend that you enable this option only if you intend to use the Web server because, with
this option enabled, all the files for the visualization are generated. In addition, these files are
transferred to the PLC memory during the download, along with the IEC program. However, it is
possible to inhibit their automatic transfer, while downloading, activating the "Inhibit download of
visualization files".
Confirming the options of the target by pressing the "OK" a window appears for the creation of a
new POU (Program Organization Unit):
We choose to create a program in LD (ladder) graphic language. The default proposed name for
this unit is PLC_PRG. The choice of this name by default allows you to avoid the creation of a task,
as required by IEC61131-3, for the execution of the program.
A POU named PLC_PRG is automatically associated by the system with a 10ms cyclic task, and so
for single POU and single task programs, no other definition is needed.
IEC-line by OVERDIGIT
Page 4
The editing window of the POU is divided into two areas. The upper area shows all the declarations
of local variables of the POU. These statements are represented in table mode or text mode. Use
the context menu (right mouse button) after you place the cursor in the area and change the status
of the "Declaration in table form."
The lower part contains the instructions or graphic objects that define the program.
In the case of graphical programming the main design elements are available in the top toolbar
below the main menu.
It is recommended to save the new project (File>Save as) in a specific folder of PC to archive also
other files generated by CoDeSys. To save the program the name TEST.pro is used.
Continuing the example, insert a "normally open contact" at the beginning of the branch of the
ladder. The name of the BOOL variable associated with the contact is momentarily displayed with
"???" waiting for a definition:
IEC-line by OVERDIGIT
Page 5
To define the variable name, click on the "???" field. In addition to the direct typing of the symbol is
possible with the F2 key (input assistant) call up the window for selecting a specific name among
those already defined and available.
In this sample program are not yet available special symbols to include in the application. The
specific target has not I/O bits until its expansion structure is defined via the "PLC Configuration"
menu. For the purpose of this simple example, then two variables have been manually declared
(Input and Output) of BYTE type.
We choose to create a simple program that connects digital input (Input.0) with digital output
(Output.0), so that the output will be activated all the time the input is ON:
IEC-line by OVERDIGIT
Page 6
Insert a relay coil associated to the output bit Output.0, after contact of the input:
IEC-line by OVERDIGIT
Page 7
3.
IEC-line by OVERDIGIT
Page 8
For the Ethernet connection we choose the "Tcp/Ip" device and we can optionally define the name
of the communication. Once the new connection is created the parameters must be set. In
particular, for an Ethernet connection, you must set the network address of the target:
NOTE: To confirm the network address, use the Enter key on your keyboard after typing the
address and leaving the cursor inside the text box.
For remote connections via the Internet the address must be the domain name chosen by the
Dynamic DNS service (such as "myplc.dyndns.org").
In the case of serial RS232 port should be instead created a new connection by clicking the Device
"Serial":
IEC-line by OVERDIGIT
Page 9
The Port parameter value must match the serial port on the Personal Computer connected the
target, while the value of baud rate must remain set to 38400.
NOTE: To connect the programming environment by RS232 port, must be defined in CHIP.INI
configuration file the COMx=PROG parameter because a different setting make COMx available for
the user IEC application program by the appropriate libraries.
Finally we may add a third connection using the USB port.
The USB connection is realized by a virtual serial COM for which the settings are identical to the
RS232 port. In this case you must install on both PC and PLC the appropriate software drivers. In
this case must be installed on PC the usbserd.inf driver for the handling of a virtual COM.
Once you have set the communication parameters, select one of the connections and confirm with
OK.
IEC-line by OVERDIGIT
Page 10
After verifying the correct connection of the communication cable between the PC and the target,
confirming the transfer of the program.
When the transfer ends, trigger execution (Run) of the program by using the toolbar button or the
"Online>Run" menu. This starts the PLC program and the monitor function of the variables. In
particular, the following figure shows the ON state of the input bit with the consequent activation
of the output bit:
IEC-line by OVERDIGIT
Page 11
At the end of the program development must be run the boot program transferring on the CPU
using the "Online>Create boot project" menu unless you have activated the option of target "Load
bootproject automatically".
NOTE: Once the programming is finished, before unplug the communication cable, exit online using
the appropriate key on the toolbar or the "Online>Log Out" menu.
IEC-line by OVERDIGIT
Page 12