MauroRiboniMX_0-1696236162035.png

Various methods to use ModbusRTU (RS485) with ctrlX CORE

MauroRiboniMX
Contributor
The Goal

ModbusRTU is of course an old protocol, but sometimes it's still necessary to use, in the case of simple machines or system upgrades. In this how to, we will see some methods of interacting with ModbusRTU devices.

Disclaimer

This guide takes into account that the people are already able to program the ctrlX CORE from PLC and EtherCAT points of view. 

Way number 1: full industrial with S20-RS-UNI
Setup used

RTU with S20RTU with S20List of material:

  • ctrlX CORE 
  • EtherCAT Bus coupler with the "RS-UNI" module
  • ModbusRTU device: an EFC5610
  • Apps: EtherCAT Master + PLC app 1.20-2.2

The manuals can be found on the Bosch Rexroth website using the search button. 

Step 1: Wiring 

Looking inside the RS-UNI documentation we can see how the system should be configured:

RS UNI docsRS UNI docs

In this configuration we are at the start then we go for the configuration number 1 expressed in figure 8.1

Step 2: Setup the EtherCAT configuration

The EtherCAT configuration setup is very easy, we need to create the "ethercatmaster" device and scan the network configuration or create it manually. In the end in this case it should look like this:

EtherCAT ConfigurationEtherCAT Configuration

Step 3: Configure the PLC to run the example
Import the example

In the library manager we have to insert the CXA_MODBUSRTU library. I created POU in the configuration. This routine is then called inside the PLC task.

RTU libRTU liblooking inside the Examples section on the library we have to look for the example named "Example_IH_S20MBRTUMaster". 

RTU lib examplesRTU lib examples

This examples explains how to use the library. Copying in the POU prg the variable section and the program section is enough. 

Map the process variables

Now we have to import the S20_RS_UNI module in the program and map the variables. It is enough to right click and go trough the process:

Select Realtime dataSelect Realtime data

We have to map correctly the variables we have in the POU with the ones that we have available from the S20_RS_UNI device.  

Map the variablesMap the variables

Modify the example 

Now we have to set the example with the settings from our device in order to setup the correct communication. What we have to set is: 

  • Communication baud rate and the other protocol entries. For example this configuration shows how to communicate with RS485, 9600 as baud rate, and 8 data bit with no parity (and 1 stop bit). Do not modify the protocol type otherwise the system will stop working. keep it transparent.

Select the correct parametersSelect the correct parameters

  • Communication addresses: EtherCAT address and uiSlot address of the submodule.

Map Correctly the AddressesMap Correctly the Addresses

Done, now we should be able to load the program and use some function to read and write coils and parameters. Using the EFC5610 the manual suggests 2 registers: one to read and one to write:

EFC5610 parametersEFC5610 parameters

Way number 2: use a TCP-Modbus gateway

There are a lot of devices that can implement this feature online. Each of them is different, so it is not possible to create a unique guide. The idea anyway is to use an external device to convert the communication from and to serial to another protocol.

RS485 to ethernetRS485 to ethernet

Way number 3: node-red + USB-SERIAL adapter (Use at your risk)

Some users may want to use a USB-serial adapter with node-red but it is not a full industrial solution and his limitations should be investigated by the user. This solution is not officially supported. 

Technically using the Modbus nodes from node-red it is possible to:

  • Use a driver free USB to serial adapter (it is not possible to install drivers so, it works or it doens't)
  • Connect it to the core and wire it to the device
  • Use node-red to interact with the adapter

I link down the configuration adopted. USB-Serial address my vary. Check on a desktop ubuntu first if it works out of the box.

Conf Node-Red 1Conf Node-Red 1

 

Conf Node-Red 2Conf Node-Red 2

 

Read 2 parameters OutputRead 2 parameters Output

Use it at your own risk.

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