04-02-2020 05:22 AM
Hi,
I've nearly got this working by looking at NI's information pages and checking the forums but I'm having one final issue. I'm communicating with three instruments via MODBUS through a serial port. However, the rig needs to be upgraded so that the connection is via an ethernet cable. I'm now using a Moxa MGate MB3480 serial-to-ethernet gateway to connect three RS485 sockets to a single ethernet socket.
The program currently uses the SAPHIR 'GModbus over Serial' library which just requires a COM port. Now I'm switching to ethernet I've done a few tests using the 'GModbus over TCP' library, which requires an IP address', and the communication works. However, upgrading the whole program would be easier if I didn't have to switch the libraries, if I could just convert the TCP-IP connection into a com port that the existing subVIs could use.
Is there any way to take a TCP-IP resource and convert it into a COM port that the original MODBUS VIs can use? I've created a resource in MAX according to this page: http://www.ni.com/tutorial/3325/en/
When I try to run the preferred method I get error -1073807331 from 'Property Node (arg 2) in VISA Configure Serial Port (Instr).vi'. Any ideas how to get this working?
Thanks for having a look,
Dan
Solved! Go to Solution.
04-03-2020 01:55 AM
Hi,
Thee Moxa communicates by ModBus TCP. To access one of the serial ports you have to use the ModBus slave address to connect to one of the Moxa serial ports. You can configure the Moxa to convert this to another address.
With the ModBus library from NI you can communicate over TCP. Did you have a look at the library?
Kees
04-03-2020 03:13 AM
Hi Kees,
Thanks for your reply. I've been using the SAPHIR GModbus library to do this. I enter the IP address of the Moxa into the VI as well as the port number of the serial port. Then when I send a ModBus command I use the slave address as well, like in the screenshot below. This is working and I can communicate like this.
What I'm trying to do now is set it up so that once I've created the task with the address 192.168.127.254:2001, I can convert it to a serial port like COM1 and wire it to the ModBus read VI. Do you know how I can configure the Moxa to do this?
Thanks,
Dan
04-03-2020 03:24 AM
Not sure what you are trying to accomplish. Convert it to COM1 ?
The Moxa can be configured with the MGate manager from Moxa.
Kees
04-03-2020 06:10 AM
Currently I'm using ModBus over TCP-IP VIs to communicate with the transmitter. What I'd like to do is use ModBus over Serial VIs instead but still communicate through the Moxa. So essentially, I need some way of converting the TCP-IP connection (IP address and port number) into the VISA com port data type.
04-03-2020 06:24 AM
You use two different VI's to communicate with the ModBus slave. The ModBus TCP is not just use another VISA source but more has te be done to communicate with the slave.
You could create a new VI with both Open VI's in it and where you decide for TCP or serial depending on the input data.
04-03-2020 07:03 AM
Thanks KC,
I'll try creating the new VI.
04-03-2020 08:18 AM - edited 04-03-2020 08:20 AM
@dml13 wrote:
Currently I'm using ModBus over TCP-IP VIs to communicate with the transmitter. What I'd like to do is use ModBus over Serial VIs instead but still communicate through the Moxa. So essentially, I need some way of converting the TCP-IP connection (IP address and port number) into the VISA com port data type.
That's not possible. While VISA supports use of TCP/IP and ASRL (serial) this only works if the device has the same protocol in both communiction modes. For instance VXI-11 measurement devices are designed to use the same SCPI/IEEE-488.2 commands independent if you communicate through the serial link, GPIB, USB or TCP/IP.
Modbus however is not like that. Modbus over serial uses a checksum at the end for both RTU and ASCII modes. On Modbus TCP they dropped that checksum since the underlaying TCP/IP protocol already does a full CRC check on each dataframe and if the frame arrived at all at the application level it is certain to be CRC checked, otherwise the TCP/IP protocol layer will automatically request retransmission of that frame and only return it after the CRC check is good. But that is not the only difference. Basically a data frame in Modbus TCP is pretty different than either for Modbus RTU or ASCII.
So your library that provides Modbus RTU and ASCII transmission over a serial link couldn't handle the correct Modbus TCP protocol at all, no matter if you pass it a valid VISA reference to a TCP/IP connection, which in itself would be simply a VISA Open function with some formatting of the TCP/IP address and port into a proper TCP VISA resource identifier.