

Serial port, short for serial port interface, is also known as serial communication interface or COM interface.
Serial communication refers to a communication mode that uses a serial communication protocol to transmit data bit by bit over a single signal line. Serial ports are classified according to electrical standards and protocols, including RS-232-C, RS-422, RS485, etc.
In serial communication, data is transmitted on a single line that is 1 bit wide, and a byte of data is divided into 8 transmissions, sent in order from low bit to high bit.
Data in serial communication is transmitted bit by bit, with each bit sent by the sender having a fixed time interval, which requires the receiver to receive each bit at the same time interval as the sender. Furthermore, the receiver must be able to determine the start and end of a data frame.
Two commonly used basic serial communication methods include synchronous communication and asynchronous communication.
01: Synchronous Serial Communication
Synchronous communication means that at a predetermined communication rate, the clock signal frequency and phase of the sender and receiver remain consistent (synchronized), ensuring that both parties have a completely consistent timing relationship when sending and receiving data.
Synchronous communication groups many characters into a data frame, with a sync character indicating the start of each frame, and only one frame of information is transmitted at a time. During data transmission, a clock signal must also be sent so that the receiver can determine each information bit using the clock signal.
The advantage of synchronous communication is that the number of bits transmitted is almost unlimited, allowing for the transmission of dozens to thousands of bytes of data in a single communication, leading to higher communication efficiency. The disadvantage of synchronous communication is that it requires precise synchronization of the clock throughout the communication, meaning the sending clock and receiving clock must be strictly synchronized (a common practice is for both devices to use the same clock source).
02: Asynchronous Serial Communication
Asynchronous communication, also known as start-stop asynchronous communication, transmits data on a character basis, with no fixed time interval requirements between characters, while each bit within a character is transmitted at a fixed time.
In asynchronous communication, synchronization between sender and receiver is achieved by setting start bits and stop bits in the character format.
Specifically, before a valid character is sent, the sender first sends a start bit, then sends the valid character bits, and finally sends a stop bit at the end of the character. The start bit to stop bit constitutes a frame. The space between the stop bit and the next start bit is an indeterminate length idle bit, with the start bit defined as low level (logical value 0), while the stop bit and idle bit are both high level (logical value 1), ensuring that there will always be a falling edge at the start of the start bit; this marks the beginning of a character transmission. Based on the start and stop bits, it is easy to achieve character delimitation and synchronization.
Clearly, when using asynchronous communication, the sender and receiver can control the sending and receiving of data with their respective clocks, and these two clock sources can be independent and unsynchronized.


▶ Data Format
Before introducing the data sending and receiving process in asynchronous communication, it is necessary to clarify the data format in asynchronous communication.
Asynchronous communication specifies that the transmitted data format consists of a start bit, data bits, parity bit, and stop bit, as shown in the diagram (the parity bit is not depicted in this diagram since it is optional; if present, it should be after the data bits and before the stop bit).
Asynchronous Communication Data Format
(1) Start Bit:The start bit must be a logic 0 level lasting for one bit time, marking the beginning of the transmission of a character, allowing the receiver to synchronize its receiving clock with the sender’s data.
(2) Data Bits:The data bits immediately follow the start bit and are the actual valid information in the communication. The number of data bits can be agreed upon by both parties, usually 5, 7, or 8 bits; standard ASCII code is 0~127 (7 bits), and extended ASCII code is 0~255 (8 bits). During data transmission, the low bits of the character are sent first, followed by the high bits.
(3) Parity Bit:The parity bit only occupies one bit and is used for odd or even parity; it is not mandatory. If odd parity is used, the total number of logic high bits must be odd; if even parity is used, the total number of logic high bits must be even.
For example, if the transmitted data bits are 01001100, the odd parity bit would be 0 (to ensure an odd number of 1s), while the even parity bit would be 1 (to ensure an even number of 1s).
Thus, the parity bit is merely a simple logical high or low state for the data, without making substantial judgments about the data. This allows the receiving device to know the state of a bit and potentially determine if noise has interfered with communication and whether the transmitted data is synchronized.
(4) Stop Bit:The stop bit can be 1 bit, 1.5 bits, or 2 bits and can be set by software. It must be a logic 1 level, marking the end of the transmission of a character.
(5) Idle Bit:The idle bit refers to the period from the end of one character’s stop bit to the start of the next character’s start bit, indicating that the line is idle and must be filled with a high level.
▶ Data Sending Process
Once the data format for asynchronous communication is clear, data can be sent according to the specified format. The specific steps for sending data are as follows:
(1) After initialization or when there is no data to send, the sender outputs logic 1, which can have any number of idle bits.
(2) When data needs to be sent, the sender first outputs logic 0 as the start bit.
(3) The sender then begins to output the data bits, starting with the lowest bit D0, followed by D1, and finally the highest bit of the data.
(4) If there is a parity bit, the sender outputs the parity bit.
(5) Finally, the sender outputs the stop bit (logic 1).
(6) If there is no information to send, the sender outputs logic 1 (idle bit); if there is information to send, it proceeds to step (2).
▶ Data Receiving Process
In asynchronous communication, the receiver determines the time length of each bit based on the receiving clock and baud rate factor. Below is an example with a baud rate factor of 16 (the receiving clock shifts the input signal once every 16 clock cycles).
(1) Communication begins, and the signal line is idle (logic 1). When a transition from 1 to 0 is detected, the receiving clock starts counting.
(2) When the count reaches 8 clock cycles, the input signal is detected. If it is still low, it confirms that this is the start bit and not an interference signal.
(3) After detecting the start bit, the receiver checks the input signal every 16 receiving clock cycles and takes the corresponding value as the D0 bit data.
(4) After another 16 receiving clock cycles, the receiver checks the input signal again and takes the corresponding value as the D1 bit data, continuing until all data bits are input.
(5) Check the parity bit.
(6) After receiving the specified number of data bits and the parity bit, the communication interface circuit expects to receive the stop bit (logic 1). If the logic 1 is not received at this time, it indicates an error, and a “frame error” flag is set in the status register; if there is no error, all data bits are checked for parity, and if there is no parity error, the data bits are taken from the shift register to the data input register; if there is a parity error, a “parity error” flag is set in the status register.
(7) Once all information in the frame has been received, the high level on the line is treated as an idle bit.
(8) When the signal changes back to low, the next frame detection begins.
This is the entire process of data sending and receiving in asynchronous communication.


To better understand serial communication, we need to understand several basic concepts in serial communication.
(1) Sending Clock: When sending data, the data to be sent is first placed into the shift register, and then under the control of the sending clock, the parallel data is shifted out bit by bit.
(2) Receiving Clock: When receiving serial data, the rising edge of the receiving clock samples the received data, detects the data bits, and shifts them into the receiving shift register, ultimately forming the parallel data output.
(3) Baud Rate Factor: The baud rate factor refers to the number of clock pulses required to send or receive 1 data bit.


Common serial connectors include two types: one is the 9-pin serial port (DB-9), and the other is the 25-pin serial port (DB-25). Each type of connector has male and female versions, with the pin-shaped connector being the male and the hole-shaped connector being the female.
Appearance of DB-9
As shown in the diagram, in the 9-pin serial connector, the pin definitions for the male and female are different, which is something to pay special attention to. So, what are the functions of these pins?
The functions of the commonly used pins for the 9-pin and 25-pin serial ports are shown in the diagram.
Functions of Common Pins for 9-pin and 25-pin Serial Ports


Common serial communication interface standards include RS-232C, RS-422, RS-423, and RS-485.
Among them, RS-232C defines the electrical standard for serial communication interfaces, specifying the interface information for bit-wise serial transmission between data terminal equipment and data communication equipment, and reasonably arranging the electrical signals and mechanical requirements of the interface, which has been widely applied worldwide.
Electrical Characteristics
RS-232C specifies the electrical characteristics, logical levels, and various signal functions.
On the TXD and RXD data lines:
Logic 1 is a voltage of -3~-15V.
Logic 0 is a voltage of 3~15V.
On control lines such as RTS, CTS, DSR, DTR, and DCD:
Signal active (ON state) is a voltage of 3~15V.
Signal inactive (OFF state) is a voltage of -3~-15V.
Thus, RS-232C uses positive and negative voltages to represent logical states, which is exactly the opposite of the transistor-transistor logic (TTL) that uses high and low levels to represent logical states.
Signal Line Distribution
The RS-232C standard interface has 25 lines, including 4 data lines, 11 control lines, 3 timing lines, and 7 spare and undefined lines.
So, how are these signal lines distributed on the pins of the 9-pin and 25-pin serial ports? The signal line distribution for the 9-pin and 25-pin serial ports is shown in the diagram.
Signal Line Distribution Diagram for 9-pin and 25-pin Serial Ports
Below is a brief introduction to these signal lines.
(1) Data Set Ready (DSR), active state (ON) indicates that the data communication equipment is available.
(2) Data Terminal Ready (DTR), active state (ON) indicates that the data terminal equipment is available. These two device status signals only indicate that the devices themselves are available and do not imply that the communication link can begin; whether communication can start depends on some control signals below.
(3) Request to Send (RTS), used to indicate that the data terminal equipment (DTE) requests the data communication equipment (DCE) to send data.
(4) Clear to Send (CTS), indicates that the data communication equipment (DCE) is ready to send data to the data terminal equipment (DTE), responding to the RTS signal. The RTS and CTS signals are used in half-duplex communication systems; in full-duplex systems, these signals can be set to ON directly.
(5) Data Carrier Detect (DCD), indicates that the data communication equipment (DCE) has established a communication link and informs the data terminal equipment (DTE) to prepare to receive data.
(6) Ring Indicator (RI), activates (ON) when the data communication equipment receives a ringing call signal from the exchange, notifying the terminal that it has been called.
(7) Transmit Data (TXD), this signal line is used by the data terminal equipment (DTE) to send serial data to the data communication equipment (DCE).
(8) Receive Data (RXD), this signal line is used by the data terminal equipment (DTE) to receive serial data sent from the data communication equipment (DCE).
(9) Ground (SG, PG), representing signal ground and protective ground signal lines.


Complete question bank for the 2022 Electrician Junior Examination (including answers)
Three essential tools for electricians, easily accessible via WeChat!
Collection The path of a veteran electrician for ten years, the secret to earning over ten thousand a month!
Which of the five major electrical drafting software (CAD, Eplan, CADe_simu…) do you prefer?
Latest electrical CAD drawing software, with a detailed installation tutorial!
Latest electrical drawing software EPLAN, with a detailed installation tutorial!
Common issues for beginners using S7-200 SMART programming software (includes download link)
Complete electrical calculation EXCEL sheets, automatically generated! No need to ask for electrical calculations!
Bluetooth headphones, electrician/PLC introductory books available? Come and claim your electrical gifts!
Basic skills in PLC programming: Ladder diagrams and control circuits (includes 1164 practical cases for Mitsubishi PLC)
Still can’t understand electrical diagrams? Take away the basics of electrician diagram reading and simulation software, theory and practice quickly!
12 free electrician video courses, 10GB software/e-books, and 30 days of free electrician live classes are being given away!
