To connect to a Modbus device we need to create a DAQFactory serial or Ethernet device. This is a combination of a serial or Ethernet port and a protocol, in this case one of the flavors of Modbus. This often corresponds to a physical piece of hardware, however when doing multidrop 422 or 485, you will use the same DAQFactory device to connect to all your devices in the chain.
DAQFactory handles serial communications by splitting the transport layer: RS-232, RS-422, RS-485, Ethernet, etc, from the protocol used on that layer: Modbus, DF1, NMEA. In less technical speak you can think of the transport layer as a telephone. There are many different types of telephones: ones that plug into a wall, cordless phones, cellular phones, and even VOIP. We then communicate on the phone. The protocol is the language that we speak: English, Swahili, Klingon, modem speak. By splitting the telephone from the language, we can use any language on any phone type. DAQFactory provides all the tools to communicate over the various phone types. DAQFactory also provides several different languages (protocols) to communicate with common devices, but also provides the tools for you to specify your own special languages. In order for you to communicate with your device, you have to select and configure the proper telephone type, and you have to speak the proper language over the phone.
1. Select Quick – Device Configuration from the DAQFactory main menu, then select New Serial (RS232/485) / Ethernet (TCP/IP) Device. This will open up the serial device configuration window. For now we’ll ignore most of it since we just want to talk to our device a little.
2. Click on either New Serial (RS232/422/485) or New Ethernet (TCP) Client depending on how you device connects to your PC and proceed to either step 3 or step 4 below.
All three forms of serial connections, RS232, RS422, and RS485 are the same as far as DAQFactory is concerned. A USB to serial converter will appear as a standard serial comm port on a PC. Ethernet Server is usually only used when using the Modbus Slave protocol (i.e. when another device or software is polling DAQFactory for values). If you using a serial to Ethernet converter, you can typically avoid installing any virtual comm port software and simply select New Ethernet Client and connect directly to the converter's raw port. This is because DAQFactory can use any protocol on any transport layer and thus can do ModbusRTU over Ethernet. You may need to configure the converter to use raw data, meaning the converter does not add anything to what DAQFactory sends. Typically you will also need to connect to a non-standard Modbus port (meaning not 502). It will be whatever the converter uses for its raw communications.
3. If you are doing a serial (RS-232, RS-422 or RS-485) connection: in the window that appears, give your comm port a name, then specify the comm port number and its parameters. This information is usually available from your device’s manual. The default timeout value of 1000 is fine. Most likely flow control will be off. Click Save and proceed to step 5.
4. If you are doing an Ethernet connection: in the window that appears, give your connection a name, then enter the IP address of the device. You will need to configure your device with a valid IP on your subnet and not the URL. The device manual should explain how to do this. If you don’t know what a valid IP is, or for that matter what subnet means, you should ask an IT person or get help from the device manufacturer.
Next, you will need to enter the IP port. The standard port for ModbusTCP is 502, so unless you are using a serial to Ethernet converter, it will almost certainly be 502. Finally, a timeout of 1000 is more then adequate for most cases. Click Save and proceed to step 5.
Ethernet is really a big bundle of different communication lines. Each one is assigned a port number. You can think of it like a skyscraper. The IP address is the postal address, say 123 Main Street. The port is the office number. Without both you won't find your device. Certain ports have standard uses. For example, port 80 is typically used by the web for HTTP requests. ModbusTCP is typically on port 502. Once again, you will need to check with your device for the proper Ethernet port. If you don’t enter the correct port, you will not be able to communicate with your device. You might have the correct building address, but you'll be connected to the wrong office in the building.
Once you've created your serial or Ethernet port, you can finish creating your device:
5. Select the port you just created by clicking on it. A checkbox will appear next to it.
6. Select the desired protocol by clicking on it. A checkbox will appear next to it. You do NOT want any of the Modbus Slave protocols.
DAQFactory supports all three flavors of Modbus: RTU, TCP and ASCII. Refer to your hardware documentation to determine which you need. Typically RTU is used for serial devices, TCP for Ethernet, and ASCII only on older serial devices.
7. Give your device a name. You will use this name when you create your I/O channels. For now, name it simply ModbusDevice, but if you have, or expect to have multiple devices connected, you may wish to give a more descriptive name. When you are done, click OK.
The rest of this guide will assume you named the device "ModbusDevice". Like almost all DAQFactory names, device names must start with a letter and contain only letters, numbers or the underscore.
You now know how to select a communications port and protocol to create a DAQFactory device. Next we will use this device to create our I/O channels.
Creating a Serial Device
Creating an Ethernet Device
For more information on serial communications, see the chapter entitled Serial and Ethernet Communications.