Communication between Labview and Controller via Modbus protocol

G

Thread Starter

Genjis

Hi,

I’m trying to create a testing environment for temperature and humidity with Labview. My problem is that I can’t communicate with the device which controls parameters. My equipment is the following:

-West 4400 1/4 Din Profile controller

-USB485ui serial adapter from Amplicon

Communication protocol is Modbus RTU. I tried to communicate and to send modbus command with Hyperterminal, Labview VIs (Looppack or Modbus pack) and others softwares but I can’t get any response from the device. Visa detects it on COM port. It seems that the device is connected but I must send bad commands to it. Is there any simple mean to chek that a modbus device is communicating ?

I’m just a beginner in modbus protocol so if someone could give me any help or advice, it would be great.

Thanks.
 
There is s simple way to check that a modbus device is communicating.

You could try the modbus test program at www.simplymodbus.ca I find it very easy to operate since everything is in one window. It runs in demo mode and allows a few commands so there is no need to purchase if you don't use it very often. The demo never expires.
 
Thank you for your answer,

It works well with simply modbus. It's a really good and simple to use software. Now I can even communicate with the controller thanks to Labview.

Many thanks.
 
Hi,

I am now able to fully control the West device, but I am having some trouble when I try to add others slave devices. I am trying to control the environmental chamber and to read data from sensors simultaneously.

The two devices are communicating with Modbus RTU on the same serial RS485 port. I found that it is a common problem when you are connecting two slave devices on the same serial port. Timeout Error are occurring and it looks like the Labview serial function can’t read and write data on both devices at the same time. It works well in highlight or step mode but not in continuous mode.

Is it possible to connect two modbus devices on the same com port and to communicate with both on Labview ?

Many thanks
 
The driver needs to perform a couple of functions for RS485 multi-dropped communications over a single port.

1. RS485 transmitter control

2. Arbitration of the serial port to be able to handle simultaneous requests and send them out sequentially.

It sounds like the driver that you are using does not perform one or both of those tasks.

Automated Solutions sells a Modbus ActiveX Control that performs both functions and is compatible with LabView:

http://automatedsolutions.com/products/modbusrtu.asp

Tech note for use in Labview is also available:

http://automatedsolutions.com/faq/KB0021.asp

-Mark
http://automatedsolutions.com
 
Modbus/RTU on RS-485 can definitely be used with multiple devices. This is in fact usually the reason why RS-485 is used at all (instead of RS-232). You can have up to 32 nodes on standard RS-485, and that limitation is due to the electrical characteristics of the chips and cabling.

There is however no mechanism built into RS-485 to allow multiple devices to communicate at the same time without stepping on each other's toes. If two devices try to communicate (reply) at the same time they will interfere with each other. If you were using Ethernet TCP/IP it would take care of those coordination issues for you. On RS-485 however, you're working directly on the bare hardware.

It is up to the "master" (your Labview program) to query one device, get its reply, query the second, get its reply, and then repeat. You may also need a slight delay between each set of transmissions because some devices are "deaf" for a short period of time after a message was sent (even it if wasn't for them).

Try putting delays between messages to see if that helps. Start with relatively long delays and then shorten them up until problems start appearing again.
 
Thanks for your answer,

I found a solution with Labview. I'm not communicating with both devices simultaneously but I put the program in a loop which allows the communication with one of the device at a time and which change the address at each iteration. So I am communicating with them sequentially.

It works well but it makes the whole process slower (maybe 2 seconds between each acquisition). It is not a problem at the moment because I have only two slave devices but it will maybe become too slow if I add others slaves. Is it possible to communicate simultaneously with others devices with Modbus if I plug them on different COM ports ? Do you think that the modbus communication command will be able to change the COM Port address and the slave address in the network quickly enough to send nearly simultaneous requests ?

I don't really understand how works arbitration of serial port. Will it allow Labview to write and read on multiple devices simultaneously? Will it solve my problem and make the program quicker? Currently, I'm using the VI library of National Instrument for Modbus protocol. Maybe I will test with the trial version of automated solution before thinking of purchase it for my company.

Thank you,
Nicolas
 
Modbus is master/slave, so transactions over one serial port must be sequential

To communicate with multiple devices simultaneously you'll need one serial port for each device (assuming your app/driver is capable).

-Mark
http://automatedsolutions.com
 
There are three things which affect speed on RS-485:

1) Baud rate. That probably isn't your problem here however.

2) Field device response time. If you ask a device (e.g. one if your West controllers) for data, nothing else can talk until it responds. If it takes a long time to get around to responding then communications will be slow.

3) Master (your Labview program) cycle time. If your Labview program has a slow polling rate, then communications will be slow.


For issue #2 or #3, separating the devices onto separate communications ports will allow them to talk simultaneously. The question will be whether the Labview driver will allow the use of multiple ports simultaneously (e.g. by allowing multiple instances of the driver to be loaded at the same time).

Another solution would be if you can get a Modbus/TCP driver for Labview you could then use Ethernet instead of RS-485 (Modbus/TCP is the version of Modbus intended for Ethernet). You would then add a Modbus TCP to RTU gateway for each controller. The West controllers would communicate with the gateways using Modbus/RTU over RS-485 (or RS-232) and the gateways would communicate with Labview (on your PC) using Modbus/TCP. Communications with each controller could then take place simultaneously.

Some gateways have multiple ports, but check the specs in detail to make sure you can use them simultaneously in parallel rather than sequentially.
 
C
There are certainly many, many, hosts that poll large numbers of Modbus slaves at a much higher rate. I think you have a software issue. And yes, there is no inherent reason you can't run multiple networks so 2 ports should get you twice the throughput. But, polling them sequentially is sort of the way it's done, changing the address for
each query. Your Labview method is just too slow. Maybe they would have some suggestions?

You should be able to write a faster program even in BASIC. Many folks here could poll them faster from a terminal:^)

Regards
cww
 
The best way to get support is by contacting your local NI branch and our application engineers can help you figuring out your real problem.

Double check if the USB RS-485 card you're using includes termination/bias resistors that eliminate reflections. check this:

http://www.ni.com/support/serial/resinfo.htm

http://digital.ni.com/public.nsf/allkb/12BB6CD900B2D0EF862564980050F5A7

All our RS-485 boards have this built-in.

Regarding software, please use the LV MODBUS library (available for free on our web) or LV DSC MODBUS server.

Below you will find useful material that helps you getting started:

RS-485: http://search.ni.com/nisearch/app/main/p/bot/no/ap/global/lang/en/pg/1/q/RS-485/

Introduction to MODBUS: http://zone.ni.com/devzone/cda/tut/p/id/7675

I hope this helps.
Rod
 
W
Not all Modbus devices use the same function codes to do writes and reads from the Modbus devices. What you maybe be experiencing is one of those cases. You should use OPC for this. The OPC Server for Scada Modbus supports varies Modbus function calls to accommodate many different devices. Labview also support OPC as an OPC client. So all you need to do is:
-Install the OPC Server for Scada Modbus on the labview machine:

http://is.gd/cwZR8

-Create a device entity in the OPC Server and put the its configuration
-Connect your Labview OPC Clinet to it
-Consult the User Manual for the OPC Server to see the appropriate function code that should be used in the tag syntax and you will be on your way to talk to the device.

Hope this was helpful

Cheers,
Wassim Daoud
Global Solutions Architect
www.MatrikonOPC.com
 
Hi,

I am new to serial communications protocols and have trouble connecting to a West 6100+ controller with Labview. The protocol is MODBUS. Physically the connection is fine as I'm able to alter the parameters using the software that is provided with the controller using a RS-485 to USB converter.

Am not sure where to start - do I need to use the driver that comes with it? which is a .mdb file. Do I use the VISA VIs? or modbus library?

Any assistance would be gratefully received.
 
Top