Structure type from ModbusTcp_any

Hello,

I am working on the project with B&R PLC communicating through Modbus TCP with ABB Unitrol1020 AVR.

I used ModbusTcp_any block, where I configured all the necessary registers (Picture 1 & 2). The communication was succesful and I can write/read data, but the reason making this topic is, if it is possible to use Structure data type on Variable in ModbusTcp_any Blocks for more clarity.

Right now, I have to make this structured text configuration to turn off or turn on individual bits in 16-bit register. It works, but with each register, it will be pure mess (Picture 3).

Do you guys know how to make the STRUCT type work with ModbusTcp_any, for example to have command MBW_CW1.MBRequestWrite := TRUE/FALSE in the first line in Picture3?

Thanks a lot!

Hi @FilReis ,
Welcome to the community!
Not sure if it’s possible to do what you want.

In the past I used that feature integrated in AS in 4/5 projects and in all cases the requirements was the same: configure the Modbus TCP/IP communication in very fast way where all variables you need for your task are available in the I/O mapping (without additional memcpy to extract the element you need).

In other prj where the customer needs more flexibility we recommend (at least in US) this library developed by Stephan:

The definition of blocks is “hard coded“ on the single hw configuration, so if you have more configurations normally we recommend the more flexible solution
with the library

Just to have an idea about what B&R offers in their official libraries, have a look on DRV_mbus, for modbus serial communication.
I used that in my last prj, all data I needed to read were stored in 24 modbus registers, one next to other; I just called one function block and I passed the address of my array of integers:

then you need few lines to convert the integer array to your user structure, for example:

Similar concept with Stephan’s library where compare Modbus_Tcp_any you don’t need to configure anything in the hw configuration.

Thanks
Ciao
Valerio

1 Like

Hi @FilReis, have you found solution for your issue? can you update us?

Hello,

it seems @valerio.manenti is correct. With the function ModbusTCP_any it is impossible to create structured type, but it can be created by using the classic way as creating a Modbus Function Block and defining an array buffer to store data.

Thanks for asking.

1 Like