Table of Contents

Controlling devices with RS232/RS485 serial data

While network control, using the TCP or UDP IP standards is preferable for best performance and reliability, some devices may only support control over a serial data (COM) port. Such devices can be controlled eirther through a USB-to-Serial device connected to a USB port on a PIXILAB Player or through a TCP-to-serial data bridge, such as the MOXA NPort series of interface modules.

Prerequisites

Before proceeding, make sure you know the answers to the following quesions:

Some of the answers above have a bearing on the physical connection. E.g., if handshake signals are required, those must be properly connected in the cable. Most options correspond to settings in the interface device's configuration (such as baud-rate, stop bits, handshake modes, etc).

Verifying Device Operation

Once you have the above details at hand, you should verify the command protocol using a terminal emulator. Such a program can talk directly to the device (if your computer is equipped with a serial port, or one can be easily added using a USB adapter). Note that most USB-to-serial adaptors handle RS232 only. For such direct-from-computer tests, use one of the following programs:

The above programs are mainly useful when your device uses a text based protocol. If the device uses a binary protocol, it can't be easily tested using a terminal emulator.

MOXA NPort Configuration

After confirming the protocol details and configuration options, move on to the Network-to-serial adapter device. Here you'll need to set the same serial communications parameters. Before doing so, you need to configure the MOXA NPort adapter using its "Web Console".

This illustration shows how you set the IP address of the NPort 5110 (a single RS232 port interface).

Setting the Operating Mode

After applying the above settings, the IP address of the NPort device will change, so you will have to change the IP address of your computer accordingly in order to reconnect to the NPort device.

This illustration shows how to set the operation mode of the NPort 5110.

Setting the Serial Communications Parameters

Now you're ready to connect the serial device to the serial port on the NPort interface, using the proper cable for the device at hand. Once this is done, set the serial communications parameters as described under "Serial Settings" in the NPort manual. This includes the data rate ("baud rate"), parity, stop bits, and handshake ("flow control").

Some NPort devices have multiple serial ports, in which case those parameters are set individually per port. In this case, you should also select a different "Local TCP Port" in the configuration of each serial port, allowing the ports to be addressed individually from Blocks.

Using the Device from Blocks

Assuming your Blocks server is on the same network as the NPort interface, you can now add the NPort to Blocks.

Controlling the Device

The device can be controlled in either of two ways:

The former method is usually preferred, as it allows panel buttons tasks and other similar functions to be directly bound to high-level states of the device being controlled. The latter may be useful for some very simple cases, where all you want to do is "send a string" to the device.

Using a Device Specific Driver

When using device driver specifically written to manage the device at hand, this driver exposes high level functions, such as input selection, power on/off, volume, etc, as appropriate for the device. Such properties can be directly connected to buttons and sliders, manipulated using a Task, or even be used to trigger a Task. The set of parameters and functions available is entirely dictated by the device driver.

Furthermore, a device driver can handle bi-directional communication with the device. This can be used to verify proper device response to command, pick up the device's initial state, or simply to expose some state of the device as read-only properties.

Using Direct Commands from a Task

if no dedicated device driver is available, you may still be able to control it by sending it raw character strings according to its control protocol.