09-03-2010 02:13 AM
can you send me the example to read a value from modbus tcp/ip communication....?
my controller act as a modbus TCP/IP slave device, and address corresponding channels that assigned as 999,1001,1003.....
how to read these value using modbus tcp/ip tool kit...?
09-05-2010 10:56 AM
Have you searched NI.com for Modbus Library? I found this free library from NI did everything I needed for modbus master/slave over serial and TCP/IP.
Michael
09-06-2010 02:34 AM
Hi Balaji
You can download the Modbus Library from http://sine.ni.com/devzone/cda/epd/p/id/4756 .
This library comes with a set of VI's for both serial(RTU/ASCII) and TCP/IP communication over Modbus protocol.I presume you want LabVIEW to act as a master and read register values from your controller (slave) . For this purpose , you can go through MB Ethernet Example Slave.vi and MB Ethernet Example Master.vi, both of which are part of the library. In this case, your slave will be listening on port 502 which is registered for modbus communication.
You can modify the code on MB Ethernet Example Slave.vi, so to replace input registers on slave with data from desired channels by creating a Task in LabVIEW.
Regards,
Bandan | Applications Engineer
National Instruments
06-13-2011 04:47 PM
Hello, Balaji and others
I downloaded and installed the MB lib into my LabView 2010 SP1. and I have ioLogik NA4010 from MOXA, which uses ModBus. I can use MOXA's ioAdmin software to see and talk to the NA4010, see the attached. the NA4010 has default IP 192.168.127.254. However, when I tried MB Ethernet Example Master.vi with the 192.168.127.254, it did not work. I then just tried to open TCP/IP connection (see attached too) as mentioned in "Introduction to MODBUS", it timed out.
It looks that I can not make the connection at first place.
what did I miss here? any suggestion is appreciated
thanks for your time.
xiaofeng
06-13-2011 07:16 PM
06-14-2011 05:11 AM
Hello, Dennis
Many thanks. after I reset the subnet the same as NA4010, "TCP/IP open" works OK.
I wonder if you can post an example code for writing/reading MOXA device,
I am newbie to MOdBus and my trial of using MXIO.dll did not work. Calling MXIO_Connect() casued LV error:( see the attached for testVI)
==========
Error 1097 occurred at Call Library Function Node in test MB Ethernet DLL.vi
Possible reason(s):
LabVIEW: An exception occurred within the external code called by a Call Library Function Node. The exception might have corrupted the LabVIEW memory. Save any work to a new location and restart LabVIEW.
===============
Again. thanks for your time.
Xiaofeng
06-14-2011 10:03 AM
The MB Ethernet Example Master worked for me. For the MXIO.dll, I used Tools>Import>Shared Library to create a lvlib. Worked perfectly.
06-14-2011 10:31 AM
Thank you very much Dennis, I learnt something new.
cheers
xiaofeng