Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

ctrlX CORE Modbus TCP App .jpg

Modbus TCP: Setup TCP communication step by step and use the data in the PLC

MauroRiboniMX
Contributor
 
Disclaimer and Topology

The goal is to set up the Modbus TCP app from scratch and communicate with a device. Here we have an example with Wago 750-881 buscoupler equipped with 2 digital Inputs, 2 digital Outputs and 2 analog Outputs. Additionally the communication with a XM22 device will be shown.

Modbus TCP connectionModbus TCP connection

IP addresses
  • XM22: 192.168.1.25
  • ctrlX CORE: 192.168.1.1
  • WAGO buskoppler: 192.168.1.15
Requirements
  • ctrlX CORE - x3 or x7 or a ctrlX OS installation
  • Modbus TCP app installed>=1.20 + license
  • Some Slave/Server device

1 - Setup the communication
With Wago

Open the app page and click on "Add Modbus TCP Device".

Add deviceAdd device
In the window we have to insert the Modbus TCP device infos and click over save:

  • A name of choice
  • The device IP address
  • The device port
  • The unit ID: Normally 255 (Remark to the unit ID, it depends on the device, normally default is 255. On Modbus TCP it has to match with the connected hardware, but can be present multiple times. In Modbus RTU it's the unique slave address)

Device ParametersDevice Parameters

Click on "add subscription" button.

Add subscriptionAdd subscription

 The subscription should be fulfilled with the right parameters:

  • Name chosen
  • Function Code: the function that the subscription should fulfill, it depends by what we need to do and can be found in the device description/datasheet:
    • FC1: Read Multiple Coils
    • FC3: Read Multiple Holding Registers
    • FC4: Read Multiple Input Registers
    • FC6: Write Single Holding Registers
    • FC15: Write Multiple Coils
    • FC16: Write Multiple Holding Registers
    • FC23: Read/Write multiple Holding Registers
  • The address that we want to read/write
  • Sometimes (if needed) the datatype contained by the register
  • The number of the addresses that we want to use
  • The Polling interval

Setup SubscriptionSetup Subscription

 Once I have added all the subscriptions the overall setup looks like this:

Modbus WagoModbus Wago

 All the data are then present in the datalayer for editing and reading and can be used by any app.

Modbus TCP DatalayerModbus TCP Datalayer

with XM22 device

Open the app page and click on "Add Modbus TCP Device" and add the device data.

TCP server and settingsTCP server and settingsWe have shared the following data: an array of 100 uint so they will be 200 bytes. Any register from ctrlX side is then an uint16 variable. Additionally we have 8 coils.

Data sharedData shared

 We add the right configurations, since we want to keep updated all the 100 variables the register configuration will look like this:

Registers configurationRegisters configuration

 The overall configuration will be the following:

Global ConfigurationGlobal Configuration 2 - Import the data inside PLC Engineering

Login on time in the PLC with an empty project (or with your project) and then logout. Right click on the datalayer, select real time data and then selectively from ctrlX CORE.

Import Data Modbus DatalayerImport Data Modbus Datalayer

To select the modbustcp_client entry, click on the import button and after this all the data will be in the Datalayer_Realtime tree.

ModbusTCP PLC app ImportModbusTCP PLC app ImportNow we can use the Modbus TCP data inside the PLC App 

Modbus TCP PLC appModbus TCP PLC app

Support

Forum Communication

Related Links

Have Fun 😎

MauroRiboniMX
MauroRiboniMX
Hello, I am Mauro a ctrlX DEVELOPR at night and a̶n̶ A̶p̶p̶l̶i̶c̶a̶t̶i̶o̶n̶ E̶n̶g̶i̶n̶e̶e̶r̶ Product Manager during the day 😎 . Ask me anything about ctrlX AUTOMATION but my best topics are IoT, AI, SDK and Communication!
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist