RS-232, is a standard introduced in 1960 for serial communication transmission of data. It formally defines the signals connecting between a DTE (data terminal equipment) such as a computer terminal, and a DCE (data communication equipment), such as a modem. The RS-232 standard had been commonly used in computer serial ports. The standard defines the electrical characteristics and timing of signals, the meaning of signals, and the physical size and pinout of connectors. PC serial port is based on RS-232 standard, you may find signals details in the RS-232 interface pinout.
RS-232, when compared to later interfaces such as RS-422, RS-485 and Ethernet, has lower transmission speed, short maximum cable length, large voltage swing, large standard connectors, no multipoint capability and limited multidrop capability. In modern personal computers, USB has displaced RS-232 from most of its peripheral interface roles. Many computers no longer come equipped with RS-232 ports (although some motherboards come equipped with a ) and must use either an external USB-to-RS-232 converter325经典版游戏 or an internal expansion card with one or more serial ports to connect to RS-232 peripherals. Nevertheless, thanks to their simplicity and past ubiquity, RS-232 interfaces are still used — particularly in industrial machines, networking equipment, and scientific instruments where a short-range, point-to-point, low-speed wired data connection is adequate.
This PC serial port interface is single ended (interconnect two devices only, via RS232 serial cable325经典版游戏), the data rate is less than 20 kbps. RS232 is the voltage loop serial interface with full-duplex communication represented by voltage levels with respect to system ground. A common ground between the PC and the associated device is necessary. Hot-plug isn't supported, but sometimes allowed. Nowdays only 9-pin connector is still in use for PCs.
|DE-9 Pin||Signal Name||Dir||Description
|1||DCD||Data Carrier Detect|
|4||DTR||Data Terminal Ready|
|5||0V/COM||0V or System Ground|
|6||DSR||Data Set Ready|
|7||RTS||Request to Send|
|8||CTS||Clear to Send|
Note: Direction is DTE (Computer) relative DCE (Modem)
Standard RS232 data packet
RS232 data is usually sent as a packet with 7 or 8 bit words, start, stop, parity bits (may be varied). Sample transmission shown on picture: Start bit (active low, usually between +3v and +15v) followed by data bits, parity bit (depends on protocol used) and finished by stop bit (used to bring logic high, usually between -3v and -15v).
Sample RS232 serial port device. How serial mouse works
typical pc mouse controlling system has the following parts: sensors -> mouse controller -> communication link -> data interface -> driver -> software. sensors are the movement detectors which sense the mouse movement and button swiches which sense the button states. mouse controller reads the state of those sensors and takes acount of current mouse position. when this information changes the mouse controller sends a packet of data to the computer serial data interface controller. the mouse driver in the computer received that data packet and decodes the information from it and does actions based on the information.
PC RS232 serial mouse voltage levels:
325经典版游戏mouse takes standard rs-232c output signals (+-12v) as its input signals. those outputs are in +12v when mouse is operated. mouse takes some current from each of the rs-232c port output lines it is connected (about 10ma). mouse send data to computer in levels that rs-232c receiver chip in the computer can uderstand as rs-232c input levels. mouse outputs are normally something like +-5v, 0..5v or sometimes +-12v. mouse electronics normally use +5v voltage.
Serial device hardware implementation
pc serial mouse uses typically dtr and rts lines for generating +5v power for microcontroller circuit in the mouse. because typical optomechanical mouse also needs power for 4 leds in the optocoupler movevement detectors, there is not much power to loose. a typical approach is to use diodes to take current from dtr and rts lines and then feed it through resistor to all of the (infrared) leds in the movement detectors. the positive power supply usually taken from rts and dtr lines (just after the diodes and before the resistor going to leds). the negative supply for transmitter is taken from td pin. typical pc serial port mouse takes 10 ma total current and operates at voltage range of 6-15v. the data itself in sent using standard asynchronous rs-232c serial format:
Start D0 D1 D2 D3 D4 D5 D6 D7 Stop Logic 0 ___ ___ ___ ___ ___ ___ ___ ___ ___ +3..+15V | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Logic 1 | | | | | | | | | | -3..-15V ___| |___|___|___|___|___|___|___|___|____
|3||TD||Serial data from host to mouse (only for power)|
|2||RD||Serial data from mouse to host|
|7||RTS||Positive voltage to mouse|
|4||DTR||Positive voltage to mouse and reset/detection|
rts = request to send cts = clear to send dsr = data set ready dtr = data terminal ready
when dtr line is toggled, mouse should send one data byte containing letter m (ascii 77) to identify itself. to function correctly, both the rts and dtr lines must be positive. the lines dtr-dsr and rts-cts must not be shorted. implement the rts toggle function by setting the rts line negative and positive again. the negative pulse width is at least 100ms. after a cold boot, the rts line is usually set to a negative level. in this case, setting the rts line to a positive level is also considered an rts toggle.
RS232 serial data parameters and packet format
1200bps, 7 databits, 1 stop-bit
data packet is 3 byte packet. it is send to the computer every time mouse state changes (mouse moves or keys are pressed/released).
D7 D6 D5 D4 D3 D2 D1 D0 1. X 1 LB RB Y7 Y6 X7 X6 2. X 0 X5 X4 X3 X2 X1 X0 3. X 0 Y5 Y4 Y3 Y2 Y1 Y0
325经典版游戏note: the bit marked with x is 0 if the mouse received with 7 databits and 2 stop bits format. it is also possible to use 8 databits and 1 stop bit format for receiving. in this case x gets value 1. the safest thing to get everything working is to use 7 databits and 1 stopbit when receiving mouse information (and if you are making mouse then send out 7 databits and 2 stop bits).
the byte marked with 1. is send first, then the others. the bit d6 in the first byte is used for syncronizing the software to mouse packets if it goes out of sync.
LB is the state of the left button (1 means pressed down); RB is the state of the right button (1 means pressed down); X7-X0 movement in X direction since last packet (signed byte); Y7-Y0 movement in Y direction since last packet (signed byte)