LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Ethernet Slave seems to fail when the Master query information simultaneously for more than 16 Coils or Discrete Inputs.

I'm developing an control application by using the Modbus TCP/IP for communicating with the host computer.
I'm using the Modbus Library for LabVIEW
 (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=F1582737BACF5CA8E0340003BA7CCD71&p_node=DZ52363&p_source=External).

The LabVIEW MB Ethernet Slave seems to fail when the MB Ethernet Master query information simultaneously for more than 16 Coils or Discrete Inputs.

The Modbus Application Protocol Specification (http://www.Modbus-IDA.org) state that:
1- The function code 0x01 'Read Coilsis' is designed to read from 1 to 2000 contiguous status of coils in a remote device.
2- The function code 0x02 'Read Discrete Inputs' is designed to read from 1 to 2000 contiguous status of discrete inputs in a remote device.

To test the behaviour of the LabVIEW MB Ethernet Slave I have modified the 'MB Ethernet Example Slave.vi' by adding more Coils and Discrete Inputs. I have added up ONLY to 20 Coils and 20 Discrete Inputs.

By using the 'MB Ethernet Example Master.vi' the answer to the MB query is correct for the first 16 Coils or Discrete Inputs. Starting from the 17th Coil or Discrete Input the MB Ethernet Slave doesn't give any answer.
By shifting the start point address the answer remain correct for the first 16 Coils or Discrete Inputs.

I have tested the slave by using also a third part MB Ethernet Master and the behaviour is the same.

1) There is a reason for this behaviour?

2) There is a Modbus Library for LabVIEW that satisfy the  'Modbus Application Protocol Specification' managing from 1 to 2000 contiguous status of Coils or Discrete Inputs?

Thanks,
Asper
0 Kudos
Message 1 of 9
(7,234 Views)

Asper,

The Modbus Slave implementation in this library is buggy.  Here are the specifics:  The 'MB Registers Manager.VI' is used as the repository for the Slave registers (it's really a LV2-style global).  Depending on the Master's request, the data is either read or written from/to this MB Registers Manager.

In the case of Write, however, the Start Address is not being taken into account (compare this with the Read cases to know what I mean).  The Start Address defaults to 0, always! 

The fix is to wire-in the Start Address to the Index input of the Array Subset primitive.  This alongwith the (already present) Length input should write to the correct set of registers, coils, etc.

NI is aware of this bug. 

Regards,

-Khalid

Message 2 of 9
(7,226 Views)
Dear Khalid,

thanks for the replay.
I have verified what you outline, in the release of the 'MB Registers Manager.VI' that I have recently downloaded by NI the 'Start Address' is correctly wired.

I think that the problem that I have pointed out could not be explained by a wrong 'Start Address' wiring.
I can read 16 Coils or Discrete Inputs independently by the Start Address, the procedure fails when I try to read more.
Moreover the NI Modbus Library write/read correctly both Input Registers and Holding Registers.

I believe that an other bug is present.

I still have need of help.

Asper
0 Kudos
Message 3 of 9
(7,198 Views)
Dear all,
looking for a solution I have found the following post by Jim Gruenbacher:

The "MB Modbus Command to Data Unit.vi" has a mistake in it.
The "Write Multiple Coils" Function Code will not work properly past 8 bits of data.
In case "15", the index to the "Split Array" VI should just be 8.
Either that or you could remove the shift register and use an index array instead.
The current implementation however corrupts the output data past 8 bits.

http://sine.ni.com/apps/we/nidz_display_comments.display_comment?p_comment_id=12729&p_node=DZ52363

The review is correct.

Unfortunately, once the previous bug has been fixed, the NI Modbus Library continues to fail when the MB Ethernet Master query information simultaneously for more than 16 Coils or Discrete Inputs.

I still have need of help.

Asper
Message 4 of 9
(7,183 Views)

Hi Asper,

Just wondering if you ended up solving this issue...

Thanks,

-Khalid

0 Kudos
Message 5 of 9
(7,070 Views)
Asper,

For the Modbus Slave, you will need to make Jim's corrections to the MB Update Registers.vi as well.

This will fix the reading of the Coils beyond address 16.

-Khalid
0 Kudos
Message 6 of 9
(7,059 Views)
Changing the index at 'split array' at "MB Update registers.VI" at case '1,2' to 8 (instead of 8*i) makes it work. Just wanted to confirm it 🙂
 
Oh, by the way, this was done in the modbus serial slave, not the ethernet one..

Message Edited by Corny on 08-11-2006 07:07 AM

0 Kudos
Message 7 of 9
(6,936 Views)
I have the same problem with the MB Ethernet.
I need 40 Outputs.
The first 16 work perfectly.
The next 8 coils do not work, The next 8 work, The next 16 do not work,The next 8 work,The next 24 do not work And work for the last 8. Conclusion, to activate the 40 outputs, I needed 88 coils.

 Because 48 coil, do nothing
 Can someone help me and i cant implemet the jim solution
0 Kudos
Message 8 of 9
(5,826 Views)
I need to correct the Bug in VI MB Modbus Command to Data Unit.
But, i don't have permission to edit this VI.
How can i do this?
0 Kudos
Message 9 of 9
(5,807 Views)