PMX as Master or Slave in CAN networks PMX as Master or Slave in CAN networks | HBM

CODESYS application - PMX CAN as master and slave

This is a guide to starting CODESYS applications for PMX. Basic experience with CODESYS is assumed. Experienced users are free to adopt a different approach. Further help is available from the examples that are installed as standard on the desktop when the PMX package is installed and from the online help for the package. The necessary files are on the "PMX CODESYS" CD that is included in the scope of supply of every PMX containing CODESYS or can be downloaded from the support page at hbm.com.

In this example, two PMX are linked via the CANopen interface. One PMX operates as master, the second PMX as slave in the network. In the second PMX, a PDO with 4 measured values is created which transmits the measured values to the first PMX (master) for display in 4 calculation channels.

Start

Open Codesys development software. Create a standard project and select the PMX as device “CODESYS Control HBM PMX V3”.

 

When you have opened the project, right-click on the file name in the device structure on the left-hand side and select "Add Device"...

... and select another PMX.

This results in the following structure with two PMX devices

Activate gateways

Double-click the first PMX (CODESYS_Control). In the window that opens on the right, double-click the gateway to update the status. Then double-click on one of the PMX devices (in this case: [0000.64E4]) to activate the gateway.

Repeat the procedure for the second PMX (Device) in the structure and assign in accordance with the other PMX (in this case: [0000.8190]).

Add CAN devices

  • For Codesys_Control_HBM_PMX_V3, add a CANbus, a CANopen_Manager and PMX_Messwerte using the "Add Device" menu.
  • For Device, add a CANbus and a CAN_Local_Device.
  • Set the baud rate for the CANbuses. (in this case: 100 000 bits/s)

Declaration of variables and mapping to the device

Open the PLC-PRG tab via the “Device” and declare variables as shown below.

Double-click CAN_Local_Device. In the window that opens, click the "Edit I/O area" button. In the "Edit I/O area" window click "Add area..." and add an area as shown below.

Double-click “Device” or open the tab. Click the "Internal I/O Mapping" tab. In the variable column, double-click the cell to open for mapping a variable to a slot.

Please note: Always activate the  checkbox in the lower right corner

Open "CAN_Local_Device" again and click the "CANbus Slave I/O Mapping“ tab...

... map the variables in this case too.

Please note: Always activate the  checkbox in the lower right corner

Declaration variables and mapping to Codesys_Control

Right-click Application under CODESYS_Control_HBM_PMX_V3, scroll to "Add Object" and select "POU". In this case, declare the variables analogously to the device declaration.

Right-click Application and select "Add Object" and select a task configuration.

In the window on the right, select "Add Call" and select "POU".

Double-click CODESYS_Control_HBM_PMXV3 or open the tab. Click the "Internal I/O Mapping" tab. In the variable column, double-click the cell to open for mapping of a variable to the corresponding Codesys output channel.

Please note: Always activate the  checkbox

Map the variables under “PMX_Messwerte”.

Run programs

Click Device and log in; then press F5 to start the application The following screen is displayed.

Now log out (important: without stopping the application).

Right-click Application under Codesys_Control_HBM_PMX_V3 and select "set active application" and log in again.

Configure Web browser

Open PMX in the browser. Since two PMX devices are connected, the following overview is displayed. Copy the second PMX's IP address. Open each of the two PMX devices in a separate tab.

Check the termination. For this purpose, use the Administrator to load the settings and system options for each device.

Make sure that CAN Termination is ON for both devices.

The browser enables the values to be displayed on the result channels; for this purpose, select "Connection with delay", select the respective CPU channel as input and specify a result channel as output. Allow for a sufficient number of decimal places.

TIP

Further information and help with creating Codesys programs is available from the Codesys online Help, on the Internet at https://www.codesys.com/ or in the Codesys chat room https://forum.codesys.com/

Benefit from the knowledge and information available in the Codesys Store. You'll find many examples of programs and solutions there, covering a wide range of tasks https://store.codesys.com

Disclaimer

These examples are for illustrative purposes only. They cannot be used as the basis for any warranty or liability claims.