Titan – AN38: RS232, RS485 and USB serial port redirects

¿Buscas alguna otra cosa?

Scene Details

MTX-Titan-Router has all the typical features of a 2G/3G/4G router and also has additional features that make it one of the routers with the most features on the market.

This application note shows how to redirect the input data flow from a serial port (RS232/RS485/USB) of the Titan router to another of its serial ports, through a specific example.

Description of the Example

A USB temperature sensor (FTDI compatible) is available. Said temperature sensor automatically sends the ambient temperature value every 10 seconds through the USB bus. This temperature must be retransmitted to two PLCs with RS232 port and three PLCs connected to an RS485 bus.

For this, it is intended to connect the USB temperature sensor to the USB port of a Titan-II router and that it retransmits the value of the temperature received at its USB port through each of its RS232 and RS485 serial ports, that is, towards the PLCs.The confi guration to be implemented in each of the serial ports is simple. To confi gure the COM1 (RS232) port, access “Serial Settings” > “Serial Port1-232” and confi gure the properties of the serial port (baudrate, parity, etc.) depending on the external device to be connected to it.

MQTT Configuration, Redirection of One to Multiple Serial Ports

The redirection of data flow from a serial port (in this case USB) to multiple serial ports will be done through MQTT. Although it would be totally possible to use an external MQTT broker (for example in the cloud) to carry out this scenario, we will use the small MQTT broker that internally includes the Titan Router to avoid data consumption through the 2G/3G/4G network. That is, we will enable the MQTT broker within the Titan router itself and we will also enable the MQTT client of the Titan router, so that it connects to its own broker, so the redirection of the data fl ows will be done internally. For this, the Titan router is confi gured as detailed in the following fi gure. Note that the connection IP address is 127.0.0.1, that is, localhost (the local IP of the Titan router).

USB Router Configuration of the Titan

The confi guration to be set in the USB port confi guration options is very simple. To confi gure the USB port, simply access the “Serial Settings” > “Serial Port5-USB” menu. Then, confi gure the properties of the serial port (baudrate, parity, etc.) based on the temperature sensor connected to the USB serial port of the Titan router.

After that, in the lower area of the same confi guration screen, the “TX Mqtt Topic” and “RX Mqtt Topic” configuration parameters, which are the key parameters for this, must be completed. After that, the “Save Confi g” button must be pressed to save the confi guration.

What does it mean to introduce in this example some “USBTX” and “USBRX” values in the confi guration of the topics? Because any data received by the USB port of the Titan router (the temperature data of the USB probe) is transmitted (transparently) to the MQTT broker (internal to the Titan) to the “USBTX” TOPIC.

Regarding the USBRX topic, this example is not relevant. Nothing is going to be sent to the USB sensor.

Confi guration of the RS232 and RS485 Ports of the Titan Router

The confi guration for the RS232 and RS485 ports is very similar to that of the USB port. Simply access the “Serial Settings” > “Serial Port1-RS232”, “Serial Settings” > “Serial Port2-RS232”, “Serial Settings” > “Serial Port3-RS485” menu, and confi gure the corresponding serial port properties (baudrate, parity, etc.) depending on the external device to be connected in each of them.

In the confi guration of the topics of all the ports, the same confi guration will be established:

COM1 (RS232): USBRX | USBTX
COM2 (RS232): USBRX | USBTX
COM3 (RS485): USBRX | USBTX

In this way, when the USB temperature probe sends data, they will be redirected to the internal broker, specifi cally to the USBTX topic. On the other hand, COM1, COM2, COM3, being subscribed to the USBTX topic of the internal broker, all the data received in that topic (those sent by the temperature probe), will be retransmitted by COM1, COM2 and COM3, allowing All PLCs, receive temperature data.

Final Considerations

  • Only FTDI or ACM compatible devices can be connected to the USB port of the Titan router