Hello everyone,
I’m trying to get a communication with an Modbus server device over an X20 CP483.
I can read values out, and it’s also possible to write in register.
Now i configured for each bit from the register a separate integer. (Picture above)
Would it also possible to read direct an array of integer. Is there an easier possibility
to read from multiple register?In Help I couldn’t find any example.
This can’t be configured with the configurable “no code” client, ModbusTcp_any.
You can use arrays with the AsMbTcp library.
Automation Help: AsMbTcp
Hi,
okay thank you of that information.
Could you also give me an example how to implement in my code?
I’ve seen the needed information, but I couldn’t understand really.
Hi,
now below you find my code. Is this correct?
When I try this application nothing would be working.
What could be wrong?
Hi Franz,
I notice two things:
-
Unless you are doing it outside the Action, you are not calling the mbWriteRegister function block. You need to add “mbWriteRegister()” before END_ACTION.
-
The “mbWriteRegister.dataSize” parameter needs to be the length of the entire memory area you are writing, in bytes (see below screenshot from B&R Online Help ). The easiest way to do this would be to set your “i_DataSize” variable equal to the size of the i_Write_Data array:
mbWriteRegister.dataSize := SIZEOF(i_Write_Data);
Please try making these changes to your code and see if it works.
For your information, there is a Library Sample for the AsMbTcp library (called “LibAsMbTCP1_ST”) which demonstrates reading a coil and writing a register via Modbus TCP. You can add it to your Logical View as follows:
-
Select the top level project folder in the Logical View and double-click “Library Samples” in the Toolbox.
-
Within the Library folder that comes up, navigate to AsMbTCP, select “libAsMbTCP1_ST.zip” and select “Finish”.
-
You will now see the LibAsMbTCP1_ST package added to your Logical View.
1 Like
okay thank you for this information.
I will try it.