LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Master/Slave confusion

Solved!
Go to solution

@RavensFan wrote:

Okay.  So the IP address in there of 10.92.56.38 is your PC's IP address?  In which case this device does want to be the master and wants your PC to be the slave.  It is the more difficult way to handle the communications.  I'd say it is 10 times more difficult to get this set up.

 

You'll need more than just what you've shown in your basic VI.  You'll need a slave daemon which keeps track of all the registers you define in your PC so that the slave VI's know what data to send when this device master sends requests for data.

 

Look in the palette for the Modbus TCP >>  Slave API and you'll see a VI in there called Modbus Slave Example.  Drop that in to a blank VI and open it up.  It will give you an architecture example of what you'll need to have running on your PC.  The key part is that you need to define registers in your VI and set their values.

 

The other concern I have looking at the example is terminology and the direction of data flow and I can't tell if terminology is reversed in this example, or if there are a couple of cases missing.  In Modbus,  a master can read or write to a holding register on a slave, a master can only read from an input register on a slave.  So all of these registers are essentially memory locations within the slave.  In your case the device is the master, and the PC is the slave with this code running.  I see a set for Set Input Registers.  That makes sense, you Write to the Input Registers on this slave, and the master device is able to send the command to read them.

 

I see a Fetch Holding Registers.   That makes sense if the master is to a Write to the Holding registers and in your VI you want to be able to see what values it wrote.  So that takes care of a Write command on the master.  But your master is using a Read Holding Registers command.  What I don't see in this example is the corresponding case that allows the VI to set the value in the slave (this PC) so that the master can read it.

 

So I think this example VI may be incomplete.  You may need to add another case and a set of controls that allow you to set the holding registers on the PC into the Slave daemon's memory space, so that the master comms device is able to read the values.


I am not familiar with the notifiers (I would like to learn). Is it possible to run this daemon without it?

 

I didn't add all the cases in the VI I shared. I was just trying to set one coil and check if I see this change on the Master. 

0 Kudos
Message 11 of 13
(862 Views)

Sorry, I meant Queues. 

0 Kudos
Message 12 of 13
(859 Views)

slave_comm.png

 

This worked for me. 

Message 13 of 13
(844 Views)