In the previous article, we shared several ways to determine the start and end of messages when receiving instructions and messages in the free port communication of the S7-200 series PLC . We also shared how to use start and end symbols to determine the start and end of messages. Today, we will share the second method (idle line) in free port communication for determining the start of messages.
Free line concept:
The idle line condition is defined as the quiet or idle time on the transmission line (i.e., the time when there is no signal change in the transmission line).
In serial asynchronous communication, information is transmitted bit by bit, with each bit being either "0" or "1". For the transmission line, transmitting "0" or "1" results in different voltage levels. A change in voltage level indicates that the transmission line is not in a quiet or idle state. If data is being transmitted, this quiet or idle state will not last long enough or may not occur. Even if all transmitted data is 0 or 1, there will still be a voltage level change because a character's start bit is represented by "0" and stop bit by "1". However, when no data is being transmitted, there is no voltage level change in the transmission line, thus creating a quiet or idle state.
In serial asynchronous communication, data transmission occurs one character at a time, with the second character sent after the first. Each character is transmitted bit by bit. Therefore, the quiet or idle periods on the transmission line are relatively short, but when no data is being transmitted, these periods can be quite long. So, after initiating the receive command, we can start monitoring the idle or quiet periods on the transmission line. If no data is received within the specified time, it means there is no data transmission during that period. If data is received after the idle period, it indicates that data transmission has begun. Therefore, the first received character can be considered the start of the message, a valid character, and stored in the receive buffer.
If, after enabling the receive command, the PLC starts checking the idle time of the transmission line, but receives a character within the set idle time, it will consider this not a complete message. It may have received a segment of data from a message, so it will discard the received character and re-enable the idle line detection. The process is shown in the following diagram:
Setting the idle time:
To use the idle time as the start of a message, the following two settings must be configured:
(1) Set the control byte for the receiving function to tell the PLC to use the idle line as the start of the message judgment.
(2) Set the idle time length.
The control byte settings are shown in the figure:
When using the idle line, the SM87.4 / Sm187.4 in the control byte needs to be set to 1, indicating that the idle line is used to detect the start.
Set the length of the idle line time:
Idle line time setting: The idle line time can be set using a transmission command to SMW90 (port0) or SMW190 (port1). The idle line time setting is typically 3.5 characters .
Assuming the communication format is set to 1 start bit, 8 data bits, no parity, 1 stop bit, and 9600bps , the transmission time for one character is slightly more than 1ms . Therefore, for the transmission time of 3.5 characters, we can set the idle line time to 4ms.
The following example uses an idle line as the start of a message and the end character (16#26) as the end of the message to illustrate the setting process: