— Blogs —
—Products—
WhatsApp:+8615367865107
Address:Room 102, District D, Houhu Industrial Park, Yuelu District, Changsha City, Hunan Province, China
Product knowledge
Time:2021-12-05 19:41:17 Popularity:638
What is serial communication? The principle of serial communication
The principle of serial communication
Serial communication is a very common serial communication method between devices. Because it is simple and convenient, most electronic devices support this communication method. Electronic engineers often use this communication method to output debugging information when debugging devices.
1. What is serial communication
Serial communication means that the serial port sends and receives bytes bit by bit.
Although byte serial communication is slow, the serial port can use one wire to send data while using another wire to receive data.
The serial communication protocol refers to the relevant specifications that specify the content of the data packet, which includes the start bit, body data, check bit and stop bit. Both parties need to agree on a consistent data packet format to normally send and receive data.
In serial communication, commonly used protocols include RS-232, RS-422 and RS-485.
2. The principle of serial communication
The serial port is an important data communication interface in embedded systems, and its essential function is to act as a code converter between the CPU and the serial device.
When data is sent from the CPU through the serial port, the byte data is converted to serial bits;
When receiving data, the serial bits are converted to byte data.
If the application wants to use the serial port for communication, it must submit a resource request to the operating system (open the serial port) before using it, and release the resource (close the serial port) after the communication is completed.
Typically, the serial port is used for the transmission of ASCII characters.
Communication is completed using 3 wires: (1) ground wire, (2) sending data wire, (3) receiving data wire.
The most important parameters of serial communication are baud rate, data bits, stop bits and parity.
For two communicating ports, these parameters must match: the baud rate is a parameter that measures the communication speed, and it represents the number of bits transmitted per second;
The data bit is a parameter that measures the actual data bit in communication. When the computer sends an information packet, the standard value is 5, 7 and 8 bits.
How to set it depends on your needs;
The stop bit is used to indicate the last bit of a single packet, and the typical values are 1, 1.5 and 2. The stop bit not only indicates the end of the transmission, but also provides an opportunity for the computer to correct the clock synchronization;
The parity bit is a simple error detection method in serial communication. There are four error detection methods-even, odd, high and low, or there is no check bit.
Tashi serial communication
3. Serial communication data parameter setting
Baud rate
Since there is no clock signal in serial asynchronous communication, both parties need to agree on the baud rate, that is, the length of each symbol, in order to decode the signal. Common baud rates are 4800, 9600, 115200, etc.
Start bit, stop bit
The data packet starts from the start bit and ends at the stop bit.
The start signal is represented by the data bit of logic 0, and the stop signal is represented by the data bit of 0.5, 1, 1.5 or 2 logic 1, as long as the two parties agree to agree.
valid data
After the start bit is the content of the transmitted main data, also called valid data, its length is generally agreed to be 5, 6, 7 or 8 bits long.
Data validation
Because the transmission data is susceptible to external interference during the communication process, the transmission data is deviated, so the check bit is added after the valid data to solve the problem.
The verification methods are odd, even, 0 space, 1 mark, and noparity.
Odd check requires an odd number of valid data and "1"s in the check digit. For example, an 8-bit valid data is 01101001. At this time, there are 4 "1"s. In order to achieve the odd check effect, check The bit is "1", and the last transmitted is 8 bits of valid data plus 1 parity bit, a total of 9 bits.
Even parity is just the opposite. The number of valid data and parity bit "1" is required to be an even number. At this time, in order to achieve the even parity effect, the parity bit is "0".
The zero check means that no matter what data content is in the valid data, the check bit is always "0", and the 1 check bit is always "1".
Related recommendations
Sensors & Weather Stations Catalog
Agriculture Sensors and Weather Stations Catalog-NiuBoL.pdf
Weather Stations Catalog-NiuBoL.pdf
Agriculture Sensors Catalog-NiuBoL.pdfRelated products
Screenshot, WhatsApp to identify the QR code
WhatsApp number:+8615367865107
(Click on WhatsApp to copy and add friends)