Hello Guest it is March 28, 2024, 10:08:24 AM

Author Topic: ModBus configuration allows only 27 registers. Why?  (Read 3092 times)

0 Members and 1 Guest are viewing this topic.

ModBus configuration allows only 27 registers. Why?
« on: February 24, 2019, 08:52:32 PM »
I get strange behavior when configuring ModBus plugin in Mach3.

Everything is fine and working perfectly if there is no more than 27 Registers declared in ModBus Configuration in Mach3.
I use Input-Holding and Output-Holding to communicate with a slave.
115200 Baud Rate, 8-1-N
It's no matter if I assign Input-Holding or Output-Holding, it does not allow me to declare more than 27 registers.

If I add for example 30 registers, my slave gets random serial data, ModBus Configuration screen starts to lag and becomes kinda slow.

The best part is, that when I'm testing ModBus communication in "Test ModBus" screen - everything is fine, I can receive and send all 127 registers from/to slave, no errors.

I tried hundreds of different configurations, but it would not work. I also deleted ModBus file, so MACH3 could create new file for configuration. Did not help..

I am creating controller pendant, and 27 registers is not enough...

Any ideas?
Re: ModBus configuration allows only 27 registers. Why?
« Reply #1 on: February 24, 2019, 09:09:10 PM »
If you are trying to transfer the 27 registers in one transaction, you may be exceeding the maximum Modbus message length.

Peter
----------------------------------------------------
Homann Designs
http://www.homanndesigns.com
email: peter at homanndesigns.com
Re: ModBus configuration allows only 27 registers. Why?
« Reply #2 on: February 25, 2019, 07:18:13 AM »
Hi Peter,

Thank you for the reply!

According to Modbus documentation MAX message size is 256 Bytes.
Holding registers are 16 bites = 2bytes.
256 / 2 = 128 registers

Or I am wrong?
Re: ModBus configuration allows only 27 registers. Why?
« Reply #3 on: February 25, 2019, 07:53:42 AM »
I found a reason!

The problem lies within my slave, and not MACH3.

You gave me right direction, Peter! It is about message length.

Serial buffer size of my slave is only 64 bytes by default.

Function 16 (write multiple registers) itself uses 9 bytes (for ID, Function, Address,  Number of registers, Number of bytes, and two Bytes CRC)

So I am left with 55 bytes which can hold max 27 registers.

I had to change buffer size to 256 on my slave..

Oh...
« Last Edit: February 25, 2019, 08:13:02 AM by AUKURAS »