LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus IO server over serial between two PCs

I am trying to set up a master/slave configuration between two PCs using the modbus protocol. I created a modbus serial master IO server on the first computer and a serial slave IO on the other one and I connect the two computers COM ports with a serial cable. But it seems there is no communication between the master and slave applications. When I setup the IO servers on each side, LabVIEW doesn't ask for the other side's address. How is it supposed to communicate? Is there a way to tell the master IO server the address of the slave?

 

 

0 Kudos
Message 1 of 15
(4,460 Views)

Apologies I can't open your project.

 

Here is what I see when I mock one up.

 

Modbus.png

 

Is it possible that you have selected modbus ethernet (TCP/IP) instead?

 

modbus ethernet.png

 

Modbus TCPIP is a different Beast.

 

The Slave doesn't need to know who it's talking to, it just needs to respond to whomever is asking.

In theory it can have multiple masters..

 

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 2 of 15
(4,451 Views)

Timmar, Thanks. I did do that. But the address in your picture is used to specify the server's own address. How about specifying the address of the remote server so that it can connect to it?

0 Kudos
Message 3 of 15
(4,447 Views)

The Master and Slave addresses need to be the same, I think this is so you can multi-drop modules on the same bus.

 

In my example it is 1 on the Master and 1 on the Slave, so - Connect!

 

Since it is Com port to com port there is no need for additional addressing.

 

 

When I have problems like this (and I do often) I go back to first principles.

 

Does the comms link work in both directions?

Use hyperterminal or something similar, (I have written my own in labview that allows me to read and write from alll com ports on any device).

 

Maybe try putting the master and slave on the same PC on different com ports and doing a loopback between com 1 and 2.

 

Once you have established this it is then up to labview.

 

The libraries must first be deployed (not sure if you need a DSC licence for Modbus on a PC, it might be worth a look).

 

Check your modbus addresses match

 

Attached is real world variable

 

modbus sample.png

 

I have had problems in the past were rebooting the target hardware allowed the modbus library start to communicate.

[This may have been coincidental but worth a try]

 

Good Luck

 

 

 

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 4 of 15
(4,438 Views)

Ok. I tried creating a Master IO server and a Slave IO server on the same PC. one of them tied to COM3 and the other to COM5. I gave them the same address "1". Still can't get a connection. I even tried to look at the output of the com port on another computer with a terminal program. Nothing coming at the other end.

0 Kudos
Message 5 of 15
(4,417 Views)

Did you check your Comms Cable?

 

95 percent of my problems have been cabling or Blown Comms Ports.

 

I am assuming you are using a Null Modem.

 

Did you check bidirectional Comms On it.

 

Have you successfully deployed the libraries )Right Click on library Deploy) make sure you see the messages,

 

If it doesn't Deploy Clean it won't work.

 

I assume you are sending Data into the system as well? Look at the error messages coming from the Shared Variable node, They can help

 

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 6 of 15
(4,412 Views)

I don't think you should be giving each server the same address.  Each device should have a different address.

0 Kudos
Message 7 of 15
(4,400 Views)

Ravens Fan,

 

It is a Master/Slave pairing. They need to have the same address. I use serial Modbus on a daily bassis, they just don't work if they aren't the same.

 

On the other hand if you have 2 masters or 2 slaves that won't work.

iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
0 Kudos
Message 8 of 15
(4,394 Views)

The master will have a different address from the slave.  A master can have multiple slaves and obviously each slave can't have the same address, otherwise there would be confusion.  You cannot have multiple masters because they would likely interfere with each other if they are both trying to communicate at the same time and each would get responses back that were requested by the other master.

 

Now if you tell me that the address setting for the master's dialog box is the setting so that the server know which slave address it is trying to communicate with to get a particular register of data, and NOT the address of the master itself, then I'll agree with you that the address needs to match.

0 Kudos
Message 9 of 15
(4,385 Views)

Do you guys have any example code using the modbus serial IO server? Or do you know any step by step tutorial on how to setup my shared variables? The only thing I could find online is how to setup the servers and that's it.

0 Kudos
Message 10 of 15
(4,379 Views)