Detailed RS232 serial communication (pin definitions, electrical characteristics, a transmission format, the receiving process)

 

[Circle] concern the development of electronic public micro-channel number, learning together!

Electronic DIY, Arduino, 51 microcontroller, STM32 microcontroller, FPGA ......
electronic encyclopedia, technology development, professional experience, interesting knowledge, technology headlines, disassemble equipment ......

Click on the link, free download 100G + electronic design learning materials!

http://mp.weixin.qq.com/mp/homepage?__biz=MzU3OTczMzk5Mg==&hid=7&sn=ad5d5d0f15df84f4a92ebf72f88d4ee8&scene=18#wechat_redirect

 

 

Serial port on the computer is a very versatile device communication protocol.

---------------------------------
serial port pin definitions :


 

 

9-cell Signal direction from abbreviation description
1 modem CD Carrier Detect
2 modem RXD Receive data
3 PC TXD send data
4 PC DTR Data Terminal Ready
5   GND Signal ground
6 modem DSR Communications equipment ready
7 PC RTS Request to Send
8 modem CTS Allowed to send
9 modem RI Ring Indicator

When two serial connection receives the data transmission and data pins connected to pins, cross each other, the signal corresponds to contact.

---------------------------------
electrical characteristics of the serial port :
. 1) the RS-232 serial communication maximum distance 50 ft 15m =
2) the RS232 bi-directional transmission can be achieved, full-duplex communication, the maximum transfer rate of 20kbps
digital transmitted on 3) RS-232C using negative logic, and symmetrically with
logic 1: -3 ~ -15V   
logic 0: + 3 ~ + 15V 
when it is connected to the microcontroller it is often necessary to add level conversion chip:


-------------------------------- -
serial communication parameters :
a) baud rate: predetermined RS-232-C standard data transfer rate of 50, 75 sec, 100,150,300,600,1200,2400,4800,9600,19200 Potter.
b) Data bits: 5, 7, and the standard value is 8 bits, depending on how to set the information you want to transfer. For example, the standard ASCII code from 0 to 127 (7); Extended ASCII codes 0 to 255 (8 bits).
c) stop bits: means for representing a single final package, the typical value of 1, 1.5 and 2. Since the number of transmission lines in timing, and each device has its own clock, probably in communication between the two devices is not a minor synchronization. Thus not only a stop bit indicating the end of transmission, and provide opportunities for computer clock synchronization correction.
d) parity bits: the serial communication error detection in a simple manner. In the case of even and odd parity, the parity bit is set the serial port (a data bit later), with a value of data transmission has to ensure an even or odd number of logical high. For example, if the data is 011, then for even parity, the parity bit is 0, the number of bits of logic high to ensure an even number. If the parity is odd, a parity bit, so that there are three logic high.

---------------------------------
serial pass channel transmission formats :
serial communication, when the line is idle, the line TTL level is always high, the inverted RS232 level is always low. A data line RS232 start is high, a low level at the end of Rs232. Data is always transmitted bit by bit from the low to the high. When reading an oscilloscope, the left is the high data.

For example, a hexadecimal data 55AAh, when 8-bit data bits, 1 stop bit transfer, it waveform signal line 1 (TTL level) and 2 (RS-232 level) shown in FIG. . 
55H = 01010101B, 10101010B after negated, was added a 1 start bit, one stop bit data format is 0,55H

 

0101010101,55H
AAH = 10101010B, 01010101B after negated, was added a 1 start bit, one stop bit data format is 0,55H

0010101011, aaH



---------------------------------
reception serial communication:
(asynchronous communication: a receiver and transmitter have their own the transmitter and receiver are controlled by the same clock source is asynchronous communication .RS232): synchronous communication; clock
when (1) the start of communication, the signal line is idle (logic 1), when it is detected by the transition from 1 to 0 , began to "receive clock" counts. 
(2) When the count to eight clocks, the input signal is detected, if still low, it is confirmed that this is a "start bit", instead of the interference signal.
(3) the receiver detects the start bit, every reception clock 16, a detection signal is input, as a value corresponding to the data bits D0. If it is a logic 1, a data bit 1; if it is a logic 0, 0 as the data bits.
(4) further receives the clock separator 16, a detection signal is input, as a value corresponding to the bit data D1. ...., Until all the data bits are input.
(5) detecting a parity bit P (if any).
(6) receives the predetermined number of data bits and check bits, communication interface circuitry would like to receive the stop bit S (logic 1), if the case does not receive a logic 1, indicating that an error has occurred, is set in the status register "Framing error" flag. If there is no error, all the data parity bits, no parity error, the data bit transmit data input register from the shift register. If parity error, the status register is set in the parity error flag.
(7) The frame information have been received, the high level as appearing on line idle position.
(8) When the signal goes low again, the next frame is entered.


---------------------------------
SCM common crystal 11.0592M is , there is this strange figure is history: the
wave Patent 9600BPS rate per bit width t1 = 1 / 9600s
Oscillator periods t2 = 1 / 11.0592 / 1000000S
microcontroller 12 is * = machine cycle T2 T3
T1 / T3 = 96
i.e. for 9600BPS serial port, the microcontroller 96 is sampled at double speed.
If the microcontroller crystal used incorrectly, it will accept the serial bit errors.
See select and register settings on the microcontroller crystal:
www.cainiao8.com/embedded/51danpianji/danpianji06_chuankou.html

-------------------------- -------
RS485 and RS422
RS485 bus, when the required communication distance is tens of meters to thousands of meters, RS485 serial bus standard widely used. RS485 balanced differential transmission and reception, and therefore has the ability to suppress common-mode interference. Bus transceiver coupled with high sensitivity, the detection voltage can be as low as 200mV, so the transmitted signal can be restored outside kilometers. RS485 half-duplex mode, at any time only a little in the transmission state, the transmission enable signal circuit shall be controlled. Very convenient for multi-RS485 interconnect, the number of signal lines can be omitted. RS485 can be networked distributed application configuration system which allows up to 32 parallel driver and 32 receivers.

Bus RS422, RS485 and RS422 circuit is basically the same principle, and are transmitted differentially receiving no digital ground. The differential working distance is the root cause of the transmission rate under the same conditions, which is the fundamental difference between the two and RS232, RS232 as a single-ended input and output, when the required number of at least duplexed transmission line and the ground line receiving three lines (asynchronous transfer), you may also add other control lines to complete synchronization. By two pairs of twisted pair RS422 full duplex transceiver independently of each other, and only half-duplex RS485, to send and receive not be performed simultaneously, but it only needs a twisted pair. RS422 and RS485 19kpbs power transmission at 1200 meters. Devices can be connected with a new transceiver circuit. 

Difference between the three
① RS232 is full duplex, RS485 is half-duplex, RS422 is full duplex.
② RS485 and RS232 are only the physical protocol (ie, interface standard) communications are different, RS485 differential transmission, RS232 single-ended transmission, but there is not much difference in the communication program. The PC is already equipped with RS232, directly on the line, the use of RS485 communication, as long as the RS232 port is connected with a RS232 to RS485 converter head on it, do not need to modify the program.

Guess you like

Origin blog.csdn.net/weixin_42625444/article/details/93469111