LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus connection through ethernet using the NI Modbus library

Hi, first of all I want to say that I'm new to Labview, so I'm in the studying phase and I may have very basic questions.

 

There's a tool that's basically a big screwdriver with a controller that can be programmed to make certain jobs using desired speed and torque,  it's called Handy2000. You can save in different channels the configurations for the different jobs. The controller has its own software, and I can already connect to it and read/write with no problem using an ethernet cable.

 

I was asked to make an interface in labview to select the channels, show in a graphic way (with photos of the electronic components) what screws correspond to that channel, and show when the steps of a job are done. All of this will be in a panel pc connected to the tool's controller.

 

Since I'm new to labview and to the modbus protocol, I took some time to study the basics. I understand how the protocol works and the very basics of labview programming, so I have an idea of how the front panel will be and what things needs to be modified. But now it's time to start the implementation, and I'm a little lost on how to make the basic configuration to setup the connection and start writing the addresses on labview. By the way I don't have the DSC module, I only have to use the NI Modbus library.

 

I already checked the example functions to use my pc as master and slave and watched the codes for the different type of data (coil, input, input register, holding register), but I don't know how I should start programming, and the most important thing is how to make some tests in the process to check that I'm having the communication between the pc and the controller. I already read in the forum and learned a lot, but failed to see as a completely newbie how to make and change the basic setups to make the thing work.

 

So any help is welcome, specific answers about how to make the basic setup and how to test it, vi examples or basic tutorials to read.

 

Thanks in advance,

Stefan Christiansen

 

p.s: I attached the manual that specifies the addresses for the modbus communication, so if you could give me an example of where I should change the address in the labview code and what should I put  to make a basic read or write it would be very helpful

 

 

0 Kudos
Message 1 of 5
(3,388 Views)

I can't even know if it's connected right 😞

 

First I opened the Master Ethernet Example and the Slave Ethernet Example, and everything worked fine.

Now I tried to do it connected with ethernet cable to the controller using the Master Ethernet Example, and set the "Remote IP Address" to the address of the controller (which I already tested with ping and the connection with my PC is fine, and also I have no problem reading and writing with the controller's software). And when I run it, I get the error 56. The error tells me that it happens at TCP Read in MB Ethernet receive.vi:5. I attached the photo of that vi.

 

I really hope you can help, I need to establish the connection and being able to read/write at least something. 

 

0 Kudos
Message 2 of 5
(3,356 Views)

I tested doing just a TCP Open Connection (with port 502 and the IP address of the controller) and TCP Close Connection, and it worked fine. But then I have problems when I enter the Ethernet Master Query. I also checked in the Master Ethernet Example I wanted to use, using the lightbulb troubleshooting feature, that the starting connection works fine, and the problem occurs when the read of discrete inputs starts. 

So my main problem is probably making the setup of that, with the addresses, the MBAP header, the Modbus command, etc

.

It would be great if someone could tell me the basic setup of addresses and that stuff according to the manual I attached previously, to for example read a single coil (let's say the signal "SET CH1"), so I can figure out the basics and then it would be just a matter of making the big code according to what I need.

0 Kudos
Message 3 of 5
(3,336 Views)

Hi Llisas,

 

So far it seems that everything is working fine with the network connection. Have you tried contacting the manufacturer to make sure that the address that you have is the right one? Sometimes I have seen that the address given in the manuals needs to be complemented with 0x or something similar to make it work. I believe that you could start from there just to make sure that you are trying to read from the correct addresses. 

0 Kudos
Message 4 of 5
(3,294 Views)

Thanks for replying.

 

Finally I could read some stuff (I had to change the Unit ID in the MBAP Header), mostly input registers and discrete inputs. Now the problem is that it doesn't read everything, and I can't read any coil at all or write some stuff, so I'm guessing it must be an address problem with some signals. I'll contact the manufacturer to check that out

0 Kudos
Message 5 of 5
(3,287 Views)