LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus problems with multiple clients

I am having a problem communicating with a Modbus Server in a multiple client, serial network. I don't have the DSC module installed, so I'm using the modbus library. When I run the vi without any other clients the program runs fine, but it appears that when the network is 'flooded' with Modbus data, the Visa read function is not fast enough to recognize the slave address. This results in a very slow response, or even a complete loss of data flow.

Any help would be appreciated!

 

Chris

L.V. 8.6.1

OS Win XP

 

0 Kudos
Message 1 of 21
(5,683 Views)
Having multiple clients in a serial network is a bad idea, unless the clients can perform a correct time sharing by means of an external clock. Concurrent access to the server may corrupt requests of all clients. If you can, you should move the server to an external node, building for example an Ethernet network instead of a serial one. The network server only would communicate with the Modbus device and dispatch requests from the clients.
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 21
(5,674 Views)

are you saying that you have multiple master devices on the serial network. or multiple slave devices and one master device?? What type of serial network?? rs232, rs485 multidrop, two wire or four wire rs485?? Are you polling all of the devices for info or using a broadcast mode where data is continuously transmitted?? How many devices and what baud rate are you using?? RTU mode or ASCII mode?? RTU mode will use half the characters. The VISA read function needs to wait for complete modbus data packets, either by calculating ahead of time how many bytes to receive, or waiting for a termination character.

 

The slave address should be contained in a full modbus data packet. I would recommend recalculating the modbus command checksum inside your labview code and comparing it to the checksum inside the data packet. This way you guarantee data integrity.

0 Kudos
Message 3 of 21
(5,661 Views)

Thank you for your reply, I was out of the office for a while...

Unfortunately the system's setup doesn't allow me to change to ethernet. I do agree Modbus IP is a lot easier to work with.

0 Kudos
Message 4 of 21
(5,601 Views)

The system consists of 17 slaves and a single master. My computer is one of those slaves. The network type is 2 wire RS485, RTU mode. I'm trying to use the Modbus Slave VI that comes with the Modbus Library. I have used it before, but only as a master. It seems the "MB Serial Recieve.vi" in the Deamon cannot detect the correct slave address, slowing the process. 

When I ignore the slave address, it seems to work just fine, a bit slow perhaps. Still this is not the solution...

Perhaps anyone else ran into a simulair problem? 

0 Kudos
Message 5 of 21
(5,589 Views)

The slave daemon seems to be able to set the slave address.  But the Serial slave example has a slave address of 1 hardcoded in it and sets the control value for the slave address in the daemon to that value of 1.  (Look in frame 4 of the stacked sequence structure in the serial slave example.)

 

Not a real good example since it hard codes that.  You may want to change that constant to match yours, or even turn the constant into a control.

0 Kudos
Message 6 of 21
(5,580 Views)
Back in the days of using modicon P190's to program plc's, we always used address 1 for the programming ports. When we started modbus plus networking plc's, this caused some issues with electricians getting into the wrong plc and modifying programs. So we made a rule to not allow any networked plc programming port to have address 1. Serial port still had address 1 for local programming and no bridge mode programming was allowed. You definitely don't want the slave daemon to be hard coded. NI should release a new version that corrects this implementation.
0 Kudos
Message 7 of 21
(5,578 Views)

Thank you for your posts!

Perhaps I'm using some other library, but I can't seem to find this hardcoded 1...

This is the one I am using: http://sine.ni.com/devzone/cda/epd/p/id/4756

The slave address is used in MB serial receive.vi, in frame 'no error', '0', '0', 'default'.

0 Kudos
Message 8 of 21
(5,540 Views)

As Ravens Fans wrote, check MB Serial Example Slave.vi, frame 4, where a constant value 1 is assigned to the Slave Address control of the daemon vi.

You can assign another value, or better load the address from an ini file.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 9 of 21
(5,506 Views)
I must have already spotted it before I got myself tangled up in this mess... Anyway the CPU load seems abnormally high (over 50%)when I run the 'MB Serial Slave Demon.vi' even without anything connected to my COM port. Perhaps I'm looking in the wrong direction?
0 Kudos
Message 10 of 21
(5,421 Views)