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.
Connect iR-COP to CODESYS
Follow these steps to connect an iR-COP product to CODESYS.
Add Device
Right click on Device (Weintek Built-in CODESYS) and select Add Device:
Add a CANbus adapter
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
Select “Device” from the newly added CANbus adapter to add CAN Open Manager
Select the newly added CANbus (CANbus) device, and then in the Add Device window, select FieldBuses -> CANopen -> CANopenManager -> CANopen_Manager version 3.5.10
From CAN Open Manager, Add iR-COP Remote Device
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
From iR-COP device, add the modules physically connected to the iR-COP
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.
Configure COM port baud rate
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
Add Tags to CODESYS program
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.
Set iR-COP Node IDs
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 deviceIn this example, we have the Node set to 00 01, so we set the Node ID to 1
MAP the program variables to the physical I/O
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
Ensure Variables are set to update automatically
Still on the CANopen I/O Mapping tab, set Always update variables to Enabled 2 (always in bus cycle task)
