Index >> Technical support & download >> Application notes

AN23: Serial Tx Pause for Eth/RS-232 converter

This application note describes how to pause the remote transmition of data on Ethernet/RS-232/485 converters. This functionality is necessarry if you need to send the output data over RS-232 in precisely defined packets. This way you can ensure the precise timing on the serial port output.

When sending a character sequence to a remote serial port connected over Ethernet the packet can be splitted to several smaller packets and each of them can travel a different way, which messes up the timing on the RS-232 or RS-485 serial port.

Some devices controlled over the serial port can require precise timing of the data. This devices than cannot be controled over a common Virtual Serial Port, but you can control them using a special application, which uses the transmition timing of the remote serial port.

The following description is for devices with FirmWare version 2.S and higher:

 

The following functions can be used only under these conditions::

  • The communication runs over TCP/IP (T: IP mode TCP)
  • NVT commands are enabled (V: NetworkVirtualTerminal On)
  • The VIRTUAL PARITY commands support is enabled (&V: Variable Parity On)
  • The outgoing packet size for the serial line (Serial Tx) is less then cca 500 character (serial Tx Buffer size)

 

Commands syntax

The commands have a fixed size of 2 bytes and they use a Virtual Terminal (NVT) and functions for remote parity control (Variable Parity).

  • Stop Serial Tx - 0xFE 0x58
  • Run Serial Tx - 0xFF 0x58
  • Pause Serial Tx 10 ms - 0xFE 0x41
  • Pause Serial Tx 20 ms - 0xFE 0x42
  • Pause Serial Tx 50 ms - 0xFE 0x43
  • Pause Serial Tx 100 ms - 0xFE 0x44
  • Pause Serial Tx 200 ms - 0xFE 0x45

 

Pay attention to the 0xFF and 0xFE characters

Beacause of the "NVT" and "Variable Parity" modes support, you need to respect 0xFF and 0xFE characters in the data flow as a prefix for NVT (0xFF) and Variable Parity (0xFE) control. This means, that if you want to send the "0xFF" character to the serial port, you need to send it doubled over TCP/IP.

Example: you are sending "0xFF 0xFF 0x41 0xFE 0xFE" over TCP/IP, but the Charon module will send only 3 characters: "0xFF 0x41 0xFE". If you do not double the FF and FE, they will be processed as a commands!

 

Remote parity control - 9. bit communication

The "Variable Parity" mode is primarily designed for controlling the 9th parity bit for 9-bit communication.

There are two ways of controlling the parity:

  • The remote serial port configuration change over NVT
    This way is not very useful, because it does not sychronize the parameter change with the serial port data.
  • The parity change for the following character using "Variable Parity"
    This will modify the parity for one following character.

If the VIRTUAL PARITY (&V: Variable Parity On) mode is allowed, you will change the parity for the following character if you insert a 2 byte sequence 0xFE 0x50 before the character.

 

Examples of "Serial Tx delay" usage

We used the Charon 1 module in the "Charon 1 DK" for testing. This is the configuration:

******* WEB51 remote setup ******
*** HW-group.com HW 6.0 SW 2.S #01 ***
*** PortBox I/O ***
MAC Address 00:0A:59:00:9D:AF
=========== IP Setup ============
I: Address 192.168.1.24
J: Port 23
M: Mask 255.255.255.0
G: Gateway 192.168.0.1
===== In IP access filter ======
W: Address 0.0.0.0
N: Mask 0.0.0.0
X: Port 0.0
Y: Port Mask 0.0
== Active (Client/Server) mode ==
S: Send to IP PASSIVE mode
U: Port 23
T: IP mode TCP
V: NetworkVirtualTerminal On
K: Keep connection Off
E: Erase buffer on None

========= Serial Setup ==========
&B: Speed 9600
&D: Data bits 8
&P: Parity NONE
&V: Variable Parity On
&S: Stop bits 1
&C: Flow Control NONE
&R: RS485/RS422 control RTS = On [+8V]
&T: Serial Line Timeout 0 - Off
&G: Char. Transmit Delay 0 - Off
&H: Tx Control Tx FULL duplex
======== Security Setup =========
%A: TCP autorisation Off
%K: TEA key 0:01:02:03:04 1:05:06:07:08 2:09:0A:0B:0C 3:0D:0E:0F:10
%S: TCP/IP setup On
======= I/O Control Setup =======
#T: Trigger AND mask 255
#A: Power Up INIT 189
#B: Power Up AND mask 255
#C: Power Up OR mask 0
#D: Power Up XOR mask 0
#X: KEEP mask 0
#Y: AND mask 255
#Z: OR mask 0
#W: XOR mask 0
============ Other ============
D: Load/Save Settings from/to Flash
R: Reboot

WEB51>

 

The image (original size screenshot is here) shows timing of 3 different macros sent from the Hercules software over TCP connection of the serial port.

Click for big screenshot

  • Macro 1 - "123456"
    There has been a delay of 30 seconds and 415ms since SAL232 was launched till the "123456" message was received. This is written on the first line, just before the "123456", which was received as a whole.
  • Macro 2 - "1$FE$442$FE$443$FE$444$FE$445$FE$446"
    There has been a delay of 918ms since the previous "123456" message was received, till the "1" character was received (time to click the second macro button). But you can see the obvious space of 100ms between the numbers. Slight diversions are caused by windows timer, which has accuracy of cca 10 ms.
  • Macro 3 - "U$FE$45V$FE$45W$FE$45X$FE$45Y$FE$45Z"
    There has been a delay of 1024ms between receiving the "6" and the "U" characters (time to click the third macro button). But you can see the obvious space of 200ms between the numbers. Slight diversions are caused by windows timer, which has accuracy of cca 10 ms.

 

DOWNLOAD & Links

 

Related Products and pages