cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Modbus TCP

Kevled
New Poster

Modbus TCP

Hello everyone,

I'm posting this message because I need to make a modbus tcp communication with a ctrlX core PLC. I saw that on the store, there is an app "CTRLX CORE Modbus tcp", is it necessary to download it to communicate with a modbus tcp module?

Then I read that the XF50 port is reserved for EtherCat. So I guess the app allows to configure the XF51 port to communicate?

Thanks in advance for your answer,

Kévin

10 REPLIES 10
CodeShepherd
Community Moderator

Re: Modbus TCP

Could you please have a look to this post for further information?

Kevled
New Poster

Re: Modbus TCP

I have succeeded in communicating with my modbus module (the IL_ModbusTCPclient module and the IL_modbusTCPRead device Identification module are working), but I can't read the information in the registers (float 32) of the Schneider module.

I don't know what the differences are between the ModbusTCPReadCoils, ModbusTCPReadHoldingRegister and ModbusTCPReadinputRegister blocks.

In my case, I created a real array to store the data with a word pointer to it.
But it gives me as error :

Resource_error for the ModbusTCPReadinputRegister block which means an error "Input 'ModBusLink' is invalid".

Communication_error for the IL_ModbusTCPclient block which means "the socket is not connected or Remote station closed Connection".

I admit that if you have an idea, I would be delighted.

Thanks in advance for your answer,

Translated with www.DeepL.com/Translator (free version)

Sozu
Community Moderator

Re: Modbus TCP

CoilData, SizeOfCoilData
The "CoilData" input maps the coils defined in Modbus. Coils form a bit field with a maximum length of 65536 bits. The bits can be read as well as written. The data exchange takes place via the array created at the "CoilData" input. Each byte of the array represents 8 bits.

The size of the array in bytes must be created at the "SizeOfCoilData" input. The SIZEOF() operator can be used for this. The function block uses "SizeOfCoilData" to check whether incoming requests are within the created field.

InputData, SizeOfInputData
The "InputData" input maps the discrete inputs defined in Modbus. Discrete inputs form a bit field with a maximum length of 65536 bits. The bits can only be read. Data exchange takes place via the array created at the "InputData" input. Each byte of the array represents 8 bits.

The size of the array in bytes must be created at the "SizeOfInputData" input. The SIZEOF() operator can be used for this. The function block uses "SizeOfInputData" to check whether incoming requests are within the created array.

HoldingRegisterData, SizeOfHoldingRegisterData
The input "HoldingRegisterData" maps the holding registers defined in Modbus. The registers form a field of words (16 bit values) with a maximum length of 65536 words. The registers can be read as well as written. Data exchange takes place via the array created at the "HoldingRegisterData" input.

The size of the array in bytes must be created at the "SizeOfHoldingRegisterData" input. The SIZEOF() operator can be used for this. The function block uses "SizeOfHoldingRegisterData" to check whether incoming requests are within the created array.

However, the actual error is due to the non-existent connection. The connect reports an error. To do this, you would need to know the detailed information of the error message of the client module. ErrorID and ErrorIdent!

Regards

Sozu
Community Moderator

Re: Modbus TCP

More information you can find in the online help of ctrlX Works:

 

Sozu_0-1662449714327.png

 

Kevled
New Poster

Re: Modbus TCP

Hello, despite the information, it does not work. Either with the module "ModbusTCPReadInputRegisters or ModbusTCPReadHoldingRegisters". The error is "resource_error" and the code "additionnal 1 = 16#0A0F1850" and the code "additionnal 2 = 16#0c230003". Unfortunately, these error codes are not found in the documentation.

If you have any information, thank you in advance for your reply,

Kévin

Sozu
Community Moderator

Re: Modbus TCP

But you have also an error at the function block ModbusClient. What is the error information for this error?

 

Kevled
New Poster

Re: Modbus TCP

Hello, the error code for the client tcp module is :
add1: 16#0A0F0111 and add2: 16#0C23020E. In the documentation, this means that the connection has been closed.

The problem is that when I use the module to retrieve the module constructor information with the client tcp module, I get it.

The variables are of type "float 32", my question is: should I use an array of type "word" with its "pointer to word"?

I confess that I do not understand. I put additional screenshots.

Thank you in advance for your answer

 
 

 

Sozu
Community Moderator

Re: Modbus TCP

Hello,

first of all something about the programme. Setting the enable signal on the ReadInputRegister module to TRUE only makes sense if the client module also supplies an InOperation. The InOperation output can be the input for the Read module, for example. And as long as the client always reports an error, we don't need to look for errors in the read component.
If a 32-bit value is to be read, an array of words with at least 2 elements must be specified as the target. This is also described in the interface description in the documentation.
So I would first do the following:

  • Only call the client module and check that a connection is established and that it remains established.
  • If this is successful, then call the ReadInputRegister module. If the connection is then broken, this is due to incorrect parameterisation of the ReadInputRegister module.
Kevled
New Poster

Re: Modbus TCP

Okay, thank you very much for your answers and clarifications.

 

Sozu
Community Moderator

Re: Modbus TCP

One question:

which PLC Version and which CXA_ModbusTCP Library are used? 

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