From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicate with network device via modbus tcp

Hi,

 

I'm new to both labVIEW and modbus protocol. I'm trying to make a VI to read data from an Inverter via modbus tcp protocol. I've downloaded the Modbus library and tried making a VI after studying some examples. Attached is a snapshot of the VI I Made.

 

I get an error  (ERROR 56) when I run this VI. This error is generated by "MB Ethernet master query Read.vi". 

I cannot figure out the what is the cause for the error. Please help me.

Thanks in advance.

 

0 Kudos
Message 1 of 8
(3,817 Views)

Hi,

 

Maybe it helps if you use the 'Create ModBus instance' to initialize the connection.

I think you are using the wrong ModBus address. Your documentation probably says read at 40003 one register. This is a DCS like notation and not a ModBus notation. 40003 must be read as use command 4 to read address 0003. Probably the address start at 1 and the ModBus addressing start at zero.

Try it with ModBus address 2 where you filled in 40003

 

Kees

0 Kudos
Message 2 of 8
(3,763 Views)

Thanks for your reply.

As you have suggested I tried with address 2 instead 40003. Still I get the same error. 

I also tried using Real-time module. Attached is the VI I made. Now I get the ERR (-389112): The Modbus slave does not accept the data address contained in the query.

I have also attached the documentation of the device. I'm trying to read the register with address 40004. Therefore I have set starting address to 3. Am I still confused with the addressing? I also tried with starting address 4, but that also does not work.

 

Download All
0 Kudos
Message 3 of 8
(3,757 Views)

I know the addressing notation is very confusing.

Reading your documentation I see a start at address 40001. Behind it is says function code 3.

In DCS notation this makes sense. The 4 is use code 3 and the 0001 is ModBus address 0000.

Try reading address 3 or 4 with the function read input register (= function code 3) Now you are using read holding register (= function code 4)

Most devices reply the same on both commands but you never know.

 

Kees

 

0 Kudos
Message 4 of 8
(3,742 Views)

Thanks again for your reply!
I replaced read holding registers.vi with read input registers and tried reading address 3. Still I get Error -389112.
I tried to communicate with the device using the program "Simply Modbus TCP client 8" too. There also I get the Exception code 02: illegal data address as shown in the attachment. 

Does this error occur because of the wrong addressing? 

 

Joon

 

0 Kudos
Message 5 of 8
(3,732 Views)

I'm not familiar with the Simply Modbus application, but I wonder if the "minus offset" value is causing you to attempt to read the wrong address.

 

One thing you could try doing is reading one register at a time, as both a holding and an input register, in a for loop where you wire the iteration terminal to the address. Then you could at least see if there are some addresses that do read properly. If you do this, make sure you don't wire the error wire to a shift register, because if you do then the first one that generates an error will cause any following reads to be skipped.

0 Kudos
Message 6 of 8
(3,718 Views)

Did you also tries to read address 3 without the 4000 ?

and follow Nathand suggestion reading 1 register. I always do that to avoid multiple errors. 

 

Looked at the picture again. Your application reads from slave 1, 1 register at ModBus address 2

So the minus offset does that. It could be that the 40003 is the real ModBus address with or without a -1 offset.

Try to read 1 register from 40003 without the minus offset.

 

 

 

Kees

0 Kudos
Message 7 of 8
(3,693 Views)

Hi,

After playing with different address formats finally I got a response from the device. In order to read the register 40004, the starting address of  "read holding register.vi" should be set to 40003.  Addressing modbus via different labview modules is very confusing to begin with.

Thanks for your help.

 

Joon

0 Kudos
Message 8 of 8
(3,682 Views)