07-24-2018 09:11 AM
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.
07-24-2018 09:16 AM - edited 07-24-2018 09:20 AM
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.
07-24-2018 09:43 AM
I have attached the two projects.
07-24-2018 09:50 AM
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.
07-24-2018 10:41 AM
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.
07-24-2018 11:12 AM
@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.
This VI returns the three AC voltage readings every 500mS
07-24-2018 11:32 AM - edited 07-24-2018 11:53 AM
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?
07-24-2018 04:52 PM
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.