Titan – AN4: Implementing a datalogger for RS232/RS485/USB devices

¿Buscas alguna otra cosa?

Scenario Details

The Titan routers include all the typical features of a 2G/3G/4G router. However, they also include a series of additional features that help make it one of the leading market routers based on the number of features it includes.

One of these additional features is the ability to store data from a serial device connected to an RS232, RS485 or USB port. This will be illustrated with a simple example.

Description of the Example

In this example we will configure a Titan router to collect, store and send via FTP to a server a collection of serial data from a PLC. Every hour, this PLC will send via its RS232 serial port an ASCII data string similar to the following example:

<data>relays:7,temperature:32,humidity:80,counter:1225</data>

Furthermore, when an alert is produced, a similar data frame is sent via the serial port, indicating the alarm and the reason it was produced, like the following example:

<alarm>alarm:1,subject:intrussion</data>

(Image: automatic sending to an FTP server; PLC device with an RS232 port)

Configuring the Assigned Serial Port

First we must decide which of the four ports on the Titan router will be used to connect the device. Remember that Serial Port 1 can be configured as an RS232 or RS485 port; Serial Port 2 and Serial Port 3 can only be configured as an RS232 port; and Serial Port 5 can only be configured as a USB port (for FDTI devices).

Let’s suppose that the PLC will connect to the Titan router’s COM2 (RS232) port. The PLC’s serial port configuration is 115200,8,n,1. Therefore, we have to input this configuration at the menu “Serial Settings/Serial Port2-232“ as shown in the following screen:

Configuring the Logging Type

The next step is to configure the type of logging used, i.e. the port to be used, the number of frames to be logged (all, 1 of 2, 1 of 3, etc.), or whether we only want to log altered strings.

For this example, we want to log all serial frames from the PLC and with a frequency of once every hour plus any alarms that are produced. To do this, we must click “External Devices/Generic Serial Device” and enter the following configuration:

Configuring the Logging Type

The final step is to configure the logger. For this example, we will configure the name of the FTP server, username, password, path etc. For alternative methods (sending data using JSON/HTTP GET, the method may differ).

The IP (or DNS) of the FTP server is ftp.myserver.com. We want the data to be sorted at the directory “/data/plc”. The username will be “plc” and the password “12345678”. The last thing to specify is the frequency with which we wish to upload a data file (every minute, hour or day). We will choose every hour. Therefore, the configuration to be entered at the menu “External Devices/Logger Configuration” is as follows:

Points to Consider

  • After configuring the Titan router, the device must be reset for the new configuration to be effective.
  • The names of the files sent to the FTP server will have the format:
    358709050113764-2015-09-20-13-44.txt
    Where:
    358709050113764 the Titan’s IMEI, unique for each router
    2015-09-20-13-44 date the file was created
  • The file content comprises JSON objects, similar to the following:
{"TYPE":"SERIAL","TS":"20/09/2015 17:19:44","IMEI":"358709050113764","P": "","DATA":"3c646174613e72656c6179733a372c74656d70657261747572653a33322c68756d69646974793a38302c636f756e7465723a313232353c2 f646174613e0d0a"}

The data uses hexadecimal coding given the Titan router logs binary characters (non-ASCII). For example “3c64617461…” = “<data …”