LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus, having trouble reading more than one register.

I think my issue may be something simple. I am able to read exactly one modbus register correctly. If I try to increase the registers to any more than one I get a timeout 6101 error at the Modbus read module. So far I've tried a number of different layouts, and even two different Modbus slaves from different vendors with the same results. I'm using a USB-RS485 converter with the FTDI232 chip. Again, a single register read always returns the correct data - so I'm almost there. The register divide routine on the right had side is rudimentary for now until I can get data from multiple registers. Any help is appreciated.

 

0 Kudos
Message 1 of 5
(3,238 Views)

A couple of thing to try:

- try using a normal while loop

- use the Open/Close functions provided in the library before and after the loop.

 

Regards,

Marco

0 Kudos
Message 2 of 5
(3,222 Views)

I did not find a modbus open or close function in the modbus library.

 

I can read the single register in a loop, it works fine. I removed the loop before posting here to make troubleshooting easer.

 

I've highlighted the modbus command that requests multiple registers. If I set this to anything great than one I get a receive timeout. I could request a single register every time, but the modbus protocol supports grabbing up to 128 (I believe), so why not use it? I need probably six registers at the most.

 

0 Kudos
Message 3 of 5
(3,218 Views)

Hi!

It seems to me the Decode function you are using is missing an input.

 

I'd suggest to give a look to this example provided with the Modbus library:

MB Serial Example Master.vi

 

Here you can find the Init function I called "Open" by mistake.

There are also higher level functions to read coils that may prove easier to use.

Moreover the example can be easily changed to suit your needs.

 

Regards,

Marco

 

p.s. I'Why are you using a timed loop?

 

 

 

 

 

 

0 Kudos
Message 4 of 5
(3,211 Views)

I have solved the issue. On my RS485 converter (I'm using one from bb-electronics), I had "Echo on" enabled. This caused the written command to re-appear on the read buffer. The modbus read function will accept this configuration - but only when reading one register! So, for anyone with this issue in the future - check your echo setting.

 

Someone more familiar with the modbus protocol's working and the internals of the read function could probably explain why this situation would manifest.

 

I understand the timed loop is bad practice - I should loop while no error, but I was trying to fix my core issue before making any improvements.

 

Thanks for your help.

 

0 Kudos
Message 5 of 5
(3,189 Views)