Programming Flow
Accessing an ioLogik I/O device is almost the same for both Ethernet and Serial interfaces. Five different scenarios are described below.
2.1 Connecting a Single Ethernet I/O device
The MXIO DLL library running on the host computer establishes a data tunnel using Modbus commands to communicate with the Ethernet I/O device. The TCP port number used to connect the ioLogik 4000 Server, ioLogik 2000 module, ioLogik 4200 Server, ioLogik 5000 module and ioLogik 1000 module is usually 502.
|
Using the MXIO DLL library to access data from the I/O device requires 5 steps. First, use MXEIO_Init to initialize Windows TCP/IP service. Then, use MXEIO_Connect to connect to the Ethernet I/O device using an IPTCP Port pair (e.g., 192.168.8.1:502). MXEIO_Connect should return a handle. You can use the handle to access any of the I/O points by Modbus Command Sets or Direct I/O Command Sets. To finish the operation, use MXEIO_Disconnect and MXEIO_Exit to release the Windows system resources.
|
2.2 Connecting Multiple Ethernet I/O devices
To use multiple Ethernet I/O devices over the network, each Ethernet I/O device should have a unique IP address.
|
We explained above how to access a single Ethernet I/O device. But what about accessing additional Ethernet I/O devices? Each Ethernet I/O device needs a unique handle. The only difference is that you get the handle using MXEIO_Connect for each Ethernet I/O device.
|
2.3 Connecting a Single Serial I/O device
ioLogik 4000 and ioLogik 2000 also support the traditional Serial I/O device to cope with old-fashioned RS-485, RS-232 control networks. When accessing the Serial I/O device via RS-485 or RS-232, please pay attention to the following:
1. Your computer must be equipped with an RS-232 or RS-485 communication port.
2. Make sure the baud rate and communication parameters for the computer and the Serial I/O device are identical.
3. Make sure the Serial I/O device is running under Modbus/RTU
|
.
Using MXIO DLL library to access data from the Serial I/O device requires 5 steps. First, use MX_OpenCommport to open the COM port and connect to the Serial I/O device. Then, use MXSIO_Connect to connect to the Serial I/O device using the UNIT ID (e.g., 10). MXSIO_Connect should return a handle. You may use the handle to access any of the I/O points by Modbus Command Sets or Direct I/O Command Sets. To finish the operation, use MXSIO_Disconnect and MXSIO_CloseCommport to release the Windows system resources.
|
2.4 Connecting Multiple RS-485 I/O devices
In most real world applications, multiple RS-485 I/O devices are often connected to the same network. One RS-485 network can support up to 32 nodes.
|
Each Serial I/O device requires a unique handle. Make sure each Serial I/O device already has its own handle before accessing the I/O points.
|
2.6 Modbus Command Sets vs. Direct I/O Command Sets
MXIO Library supports two ways of letting you access the I/O data from ioLogik 4000 I/O Server and ioLogik 2000 I/O module.
Modbus Command Sets
ioLogik 4000 I/O Server and ioLogik 2000 I/O module use Modbus/TCP, Modbus/RTU to communicate with the host computer. Modbus Command Sets is a simplified API that uses the Modbus protocol data format to get I/O data. This is a good choice if you are already familiar with the Modbus protocol and prefer using the Modbus data structure.
Direct I/O Command Sets
If you don't like the complex data structure of Modbus, the MXIO Library provides an intuitive way to achieve the same result. Each I/O point or channel can be accessed by a physical slot number and channel number. This is a good choice for accessing the I/O quickly and easily.