Codesys CMT Quick Start Guide

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

CODESYS Quick-Start Guide

cMT-X Series and iR Modules


and using them with CODESYS

Maple Systems, Inc. | 808 134th St. SW, Suite 120, Everett, WA 98204 | 425.745.3229
Table of Contents
Set up CODESYS and Device .......................................................................................................................... 3
Creating a CODESYS Project .......................................................................................................................... 4
Connect CODESYS to EBPro .......................................................................................................................... 7
Connect iR-ETN to CODESYS ....................................................................................................................... 13
Connect iR-COP to CODESYS ....................................................................................................................... 19
Connect iR-ECAT to CODESYS ..................................................................................................................... 26

CODESYS Quick-Start Guide 2


Set up CODESYS and Device
Note that if you are using the cMT-CTRL01, please refer to the cMT-CTRL01 User Manual for instructions
on getting started with CODESYS specific to that model.

1. Create a CODESYS account and download CODESYS v3.5.10.


a. If in the USA, Canada, or Mexico, use this link:
https://us.store.codesys.com/customer/account/login/. Otherwise, use
https://store.codesys.com/.
2. Download the Weintek package file and install the package in CODESYS.
a. Select Tools -> Package Manager:

b. Click Install and select the Weintek package file:

3. Activate CODESYS on your cMT device by connecting it to the internet, opening the HMI system
settings menu, unlocking it, select the Network tab and ensure Obtain an IP Address
Automatically is enabled. Then open the CODESYS tab and enter the CODESYS Activation Code
and click Active.

CODESYS Quick-Start Guide 3


Creating a CODESYS Project
1. Create a new project in CODESYS using the Weintek Built-in CODESYS device.
a. Select File -> New Project, then select Standard Project from the menu:

b. In the Standard Project menu, select the Weintek Built-in CODESYS (Weintek Labs., Inc.)
device:

CODESYS Quick-Start Guide 4


2. Scan for your newly Activated HMI and connect to it.
a. Double click on the Device in the Devices pane:

b. Click Scan Network and select the cMT-X device. Note that the last two IP address octets
are converted to hex and used the identifier in square brackets seen here as cMT-1E10
[000E]. This makes the IP address of this cMT device xxx.xxx.0.14:

CODESYS Quick-Start Guide 5


c. Now you should see the connection from PC to cMT-X in the Scan Network tab:

d. Note that it is also possible to simply type the IP address of the cMT-X device into the
Scan Network tab device section:

CODESYS Quick-Start Guide 6


Connect CODESYS to EBPro
1. Create three tags in the CODESYS project.
a. Double click on PLC_PRG(PRG) in the Devices pane:

b. Add ST code to create three tags:

CODESYS Quick-Start Guide 7


c. Right click on Application in the Devices pane and select Add Object -> Symbol
Configuration, using the default values:

CODESYS Quick-Start Guide 8


d. Note, when done, the project automatically builds. If there are build errors, they display
in the bottom left corner:

Clicking on this will open the errors and warnings. If there are any errors, and this is the
first CODESYS project created, build errors are likely due to missing libraries. Open the
errors and double click one to open the Library Manager:

To fix this, simply click the Download Missing Libraries button, then with all libraries
selected, click Download:

CODESYS Quick-Start Guide 9


2. Export the CODESYS tags to an XML file.
a. With the new Symbol Configuration selected in the Devices pane, check the PLC_PRG
box to add all the new tags to export:

b. Select Build -> Generate Code to generate the XML file, which can be found in the
project directory:

CODESYS Quick-Start Guide 10


3. Add a Weintek Built-in CODESYS device to your EBPro project and import the XML file of
CODESYS tags.
a. Add a Weintek Built-in CODESYS device to your EBPro project:

CODESYS Quick-Start Guide 11


b. Click the Import Tags button and navigate to the XML tag export file created for the
CODESYS project previously. It will be in the CODESYS project directory:

c. You can now access all tags from your CODESYS project in EBPro.

CODESYS Quick-Start Guide 12


Connect iR-ETN to CODESYS
Before setting up a CODESYS project to communicate with an iR-ETN module, it is assumed that the
development PC running CODESYS, the cMT device running the CODESYS runtime, and the iR-ETN
module have all been connected via Ethernet and are on the same IP subnet. If this is not the case, the
devices will be unable to communicate.

1. Right click on Device (Weintek Built-in CODESYS) and select Add Device:

2. In the Add Device window, select Fieldbuses -> Ethernet Adapter -> Ethernet version 3.5.10 and
click Add Device:

CODESYS Quick-Start Guide 13


3. Right click on the newly added Ethernet device and select Add Device:

CODESYS Quick-Start Guide 14


4. Select Fieldbuses -> Modbus -> Modbus TCP Master -> Modbus TCP Master and click Add
Device:

5. Select the new Modbus TCP Master device, then select Fieldbuses -> Modbus -> Modbus TCP
Slave -> Modbus TCP Slave and click Add Device:

CODESYS Quick-Start Guide 15


6. Double click the newly added Ethernet device to open the Ethernet device configuration. In the
General tab, enter the IP address and Subnet mask to match your iR-ETN’s configuration:

7. Double click the Modbus TCP Master device and navigate to the ModbusTCPMasterParameters
tab and set AutoReconnect to TRUE:

8. With CODESYS connected to the base device, i.e. Device (Weintek Built-in CODESYS), click […] in
the Ethernet device General tab and select the Network interface corresponding to the Ethernet
device’s IP address:

9. Double click on the Modbus TCP Slave device and go to the ModbusTCPSlave Parameters tab.
There, change the Unit-ID Parameter to match the Unit ID on the iR-ETN module:

CODESYS Quick-Start Guide 16


10. To add a tag to the Modbus device, go to the Modbus Slave Channel tab and click Add Channel
to open the Modbus Channel window. Select the access type to match the data type of the tag.
In this case, a bool-type tag is being added, so the Read Discrete Input type is used:

11. Double click on PLC_PRG in the Devices pane and add a Boolean tag:

12. With the tag added, double click on the Modbus TCP Slave device once more, go to the
ModbusTCPSlave I/O Mapping tab, expand the Variable tree entirely and click the […] button to
connect it to the new read Boolean tag:

CODESYS Quick-Start Guide 17


13. In the Input Assistant window, select Application -> PLC_PRG -> read to attach the read Bool tag
to the Modbus channel created prior.

CODESYS Quick-Start Guide 18


Connect iR-COP to CODESYS
Before setting up a CODESYS project to communicate with an iR-COP module, it is assumed that the
development PC running CODESYS and the cMT device running the CODESYS runtime are connected via
Ethernet, and the cMT device is connected to the iR-COP module using the CAN bus. For information on
how to wire the CAN bus, please see the installation guide pinout diagrams for the cMT device in use, as
well as the installation guide and user manual for the iR-COP on DIP switch settings and wiring.

1. Right click on Device (Weintek Built-in CODESYS) and select Add Device:

2. In the Add Device window, first check the Display all versions checkbox, and then select
Fieldbusses -> CANbus -> CANbus version 3.5.10 and click Add Device:

CODESYS Quick-Start Guide 19


3. Select the newly added CANbus (CANbus) device, and then in the Add Device window, select
FieldBuses -> CANopen -> CANopenManager -> CANopen_Manager version 3.5.10:

CODESYS Quick-Start Guide 20


4. Select the newly added CANopen_Manager, and then in the Add Device window, select
Fieldbusses -> CANopen -> Remote Device -> iR-COP Revision 3, FileVersion 1.3:

CODESYS Quick-Start Guide 21


5. Select the newly added iR-COP device, and then in the Add Device window, add each module
connected to the iR-COP in the order connected. In this example, we only have an iR-DM16-P
connected:

CODESYS Quick-Start Guide 22


6. Double click on the CANbus (CANbus) device and configure the correct baud rate for the iR-COP
in the General tab. This should match the baud rate set on the DIP switches of the iR-COP:

7. To map tags to the CANopen device, first add tags to the PLC_PRG application. In this example,
BOOL tags are used as the only IO module connected to the iR-COP is an iR-DM16-P:

CODESYS Quick-Start Guide 23


8. Double click on the iR_COP device and go to the General tab. Here, set the Node ID to match the
X1 and X10 DIP switch Node setting on the iR-COP device. In this example, we have the Node set
to 00 01, so we set the Node ID to 1:

9. Now map the variables in PLC_PRG to the IO modules attached. In this example, we are only
using a iR-DM16-P, so we will double click that module, navigate to the CANopen-Module I/O
Mapping tab, and connect each created Boolean variable and attach them to the corresponding
IO:

CODESYS Quick-Start Guide 24


10. Still on the CANopen I/O Mapping tab, set Always update variables to Enabled 2 (always in bus
cycle task).

CODESYS Quick-Start Guide 25


Connect iR-ECAT to CODESYS
1. Right click on Device (Weintek Built-in CODESYS) and click Add Device:

2. In the Add Device window, check the Display all versions checkbox and then select FieldBusses -
> EtherCAT -> Master -> EtherCAT Master Version 3.5.10.0 and click Add Device:

CODESYS Quick-Start Guide 26


3. Select the newly added EtherCAT Master device, and then in the Add Device window, select
Fieldbusses -> EtherCAT -> Slave -> Weintek Labs., Inc. – Coupler -> iR-ECAT and click Add
Device:

CODESYS Quick-Start Guide 27


4. Double click on the newly added EtherCAT Master device to open the settings. In the General
settings tab, click the Source Address (MAC) Browse button to set the gateway address to use
for the EtherCAT interface. This should match the MAC address of the cMT-X device’s CODESYS
LAN port:

CODESYS Quick-Start Guide 28


5. Double click on the iR_ECAT device to open the device settings. In the General tab, check the
Enable Expert Settings checkbox. In the Identification section, select the Configured Station Alias
radio button, and for the value field, enter the node ID set on the X1 and X10 dip switches on
your iR-ECAT device. These may be set to any ID except 00 00. Our example is set to 00 01:

6. Add all attached IO modules in order. This can be done in two ways:
a. Scan for Devices
i. Right click the EtherCAT Master device and click Scan For Devices. If the gateway
for the EtherCAT Master device is set up, and the PC is able to login to the
CODESYS device, this will automatically scan the connected iR-ECAT module and
find all attached IO modules, allowing them to be added all at once. In this
example, only a DM16-P is connected:

CODESYS Quick-Start Guide 29


b. Add each IO module by hand in order.
i. Right click the iR_ECAT device and click Add Device. In the Add Device window,
select Fieldbusses -> EtherCAT -> Module and then add each connected IO
module in the order they are connected to the base module. In this example,
only a DM16-P is connected:

CODESYS Quick-Start Guide 30


7. Add variables in the PLC_PRG program to channel to the connected IO. In this example, we will
simply add one Boolean for each IO:

CODESYS Quick-Start Guide 31


8. Double click in the iR_ECAT device and go to the EtherCAT I/O Mapping tab. There, map the
newly created variables to the IO connected. In this example, we only have an iR-DM16-P
connected, so we will connect our 8 read and write variables to the input and output bits:

9. While in the EtherCAT I/O Mapping tab of the iR_ECAT device, set the Always update variables
to Enabled 2 (always in bus cycle task):

10. Finally, in the iR_ECAT device settings, go to the Expert Process Data tab and check the PDO
Assignment and PDO Configuration checkboxes in the Download section:

CODESYS Quick-Start Guide 32


Your Industrial Control Solutions Source
_____________________
www.maplesystems.com

AW-10101092 Rev 00

Maple Systems, Inc. | 808 134th St. SW, Suite 120, Everett, WA 98204 | 425.745.3229

CODESYS Quick-Start Guide 33

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy