Reading multiple registers at the same time by Modbus | LabJack
 

Reading multiple registers at the same time by Modbus

6 posts / 0 new
Last post
Tom
tomsimmons's picture
Reading multiple registers at the same time by Modbus

I'm looking to read the value of about 10 registers simultaneously so I capture their values at a specific point in time.

Modbus prevents more than a number of registers being read at a time, so I would seem to need to read the registers individually but at the same time, is this possible?

I was wondering if I could create threads for each register I'd like to read, then use something like thread barriering to force all threads to read at the same time.  However, what will the T4 do when it receives several requests at the same time?

Perhaps there is a better way of doing this?

 

Tom

LabJack Support
LabJack Support's picture
" Modbus prevents more than a

" Modbus prevents more than a number of registers being read at a time "

This limitation comes from the communication system. USB is limited to 64 bytes per packet. Ethernet is limited to ~1024. So switching to Ethernet may be the solution you need.

Threading...

The T4 processes commands one at a time, so each thread would have to wait for the completion of the previous command. This would be controlled by our driver.

 

Tom
tomsimmons's picture
Thanks for your prompt reply.

Thanks for your prompt reply. 

I'm already using ether net, when I discovered the limit I queried it with the author of the library I'm using and it was they who mentioned this limit.

Even with a slightly larger limit, the first register I'm reading is 0, another I need is at 3008, so it doesn't seem feasible to read everything at once, and therefore isn't possible to read all registers at a point in time. 

 

Tom

LabJack Support
LabJack Support's picture
Are you implementing Modbus

Are you implementing Modbus yourself?

 

If so, then you need to use the Feedback function (modbus function #76):

https://labjack.com/support/software/api/modbus/protocol-details

 

Our cross-platform LJM driver already implements these details. I recommend using the driver if possible.

https://labjack.com/support/software/api/ljm/function-reference/lowlevel...

Tom
tomsimmons's picture
No, I'm experimenting with

No, I'm experimenting with one or two of the libraries already available for C#.

We are using the LabJack as a testbed, the final product being a larger piece of kit from Stahl called the IS1+.

 

Tom

LabJack Support
LabJack Support's picture
There are a few LJM driver

There are a few LJM driver functions that will help you here. They are:

LJM_eReadNames - Read multiple non-consecutive registers

LJM_eWriteNames  - Read multiple non-consecutive registers

LJM_eNames - Read and/or write multiple non-consecutive registers

 

Those function allow you to pack multiple reads or writes into a single packet.

 

Full multi-value function documentation:

https://labjack.com/support/software/api/ljm/function-reference/multiple...