LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Communication Help

Hello,

 

I am having troubles doing some basic testing using Modbus. For now I am trying to do local Modbus communication on one machine to make sure everything is working before testing out on two different machines.

I created two basic VI’s. One for the slave and one for the master and created the Modbus I/O Master Server in the master VI and a I/O Slave Server in the slave VI. I created the same variables in each library  and connected them in the VI's. I then went to the Modbus Library settings and set the address (local). I ran both and when I changed values on the slave VI nothing was being changed on the master.

I then did some messing around and when I made two master servers it worked. I’m not sure why it worked with two masters but it did and I think I am doing something wrong since it should be master/slave communication. Any help will be useful. Thank you in advance.

 

 

Download All
0 Kudos
Message 1 of 8
(2,545 Views)

What is that? All I see in your pictures is some shared variables, controls, and indicators.

 

Where's the Modbus part?

 

BTW: DON'T attach pictures of your code, attach your actual code.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 8
(2,544 Views)

I have attached the two projects.

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

So do you need help with Shared Variables?

 

Because other than the Modbus library being included in your project I see no Modbus used at all in any of your code.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 8
(2,526 Views)

From my basic understanding of ModBus in LabView is i create the I/O server and create and set the registers for the master and the slave and basically use them as variables. I used this guide as a reference http://www.ni.com/tutorial/13911/en/. We first created a master VI using this guide and then created another slave VI using this guide as a reference one again, but when we ran the VI's the values did not change. We then decided to make two master VI's by adding a master I/O server to each one.  We ran them and that worked. 

 

Somethings that I need to know is that are we approaching this properly. Can we use two VI's that are master I/O servers on two different machines and can they communicate via shared variables and Ethernet connection? If not how can we do this? I assumed we had to Mater/Slave communication, but that for some reason did not work when we tested it out.

0 Kudos
Message 5 of 8
(2,517 Views)

@AussieEric wrote:

From my basic understanding of ModBus in LabView is i create the I/O server and create and set the registers for the master and the slave and basically use them as variables. I used this guide as a reference http://www.ni.com/tutorial/13911/en/. We first created a master VI using this guide and then created another slave VI using this guide as a reference one again, but when we ran the VI's the values did not change. We then decided to make two master VI's by adding a master I/O server to each one.  We ran them and that worked. 

 

Somethings that I need to know is that are we approaching this properly. Can we use two VI's that are master I/O servers on two different machines and can they communicate via shared variables and Ethernet connection? If not how can we do this? I assumed we had to Mater/Slave communication, but that for some reason did not work when we tested it out.


I guess I do not understand that method of communicating with a Modbus device.  I am currently learning Modbus myself working with a power analyzer that communicates over Modbus .

 

From what I have seen communicating with a Modbus device is no different that communicating with another device except it uses the Modbus protocol.

 

Here is an example of one of my test programs. The Modbus device (power analyzer) is connected using a Modbus to USB adaptor. That adaptor installs a virtual serial port, communicating with it is very similar to communicating with  any other serial device, except of course it uses Modbus.

 

Modbustest.png

This VI returns the three AC voltage readings every 500mS

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 8
(2,515 Views)

Doh... I am glad I never looked at any of the tutorials. Talk about over complicating things.

 

Are you using Modbus over TCP or Serial? 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 8
(2,512 Views)

Oooh, I know that one... it's an Accuenergy Acuvim something-or-other.

 

I wrote a driver library for the Acuvim-L series but sadly "rolled my own" Modbus library because the NI-Modbus class library either didn't exist or I didn't know about it.

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 8 of 8
(2,492 Views)