跳至內容

使用者:A33886003

本頁使用了標題或全文手工轉換
維基百科,自由的百科全書
PS/2介面
PS/2鍵盤及滑鼠連接埠,分別以紫色及綠色標示。
類別 鍵盤及滑鼠數據介面
產品歷史
設計者 IBM
設計時間 1987年,​38年前​(1987
前身 DIN connector, DE-9 connector and Mini-DIN-9 InPort
取代 USB (USB human interface device class)
一般規格
熱插拔 No
外接 Yes
纜線 4 wires plus shield
引腳 6
連接器 Mini-DIN-6
電力
訊號 5 V DC
接地 Dedicated pin and shield
最大電壓 5.0±0.5 V
最大電流 275 mA
資料
資料訊號 Serial data at 10.0–16.7 kHz with 1 start bit, 8 data bits (LSB first), 1 parity bit (odd), 1 stop bit, [1 ack bit (if host-to-device)]
位元率 7–12 kbit/s
最多裝置數 1 or 2[a]
協定 Serial
引腳輸出
PS/2接腳示意圖
引腳1 +DATA 資料
引腳2 保留[b]
引腳3 GND 地線
引腳4 Vcc +5伏特直流電,可供應275mA的電流
引腳5 +CLK 時脈頻率
引腳6 保留[c]
  1. ^ 鍵盤和滑鼠埠可能合併為一個埠,可透過分線器電纜用於連接兩者。
  2. ^ 一些筆記型電腦用分接線接到滑鼠的訊號線。
  3. ^ 一些筆記型電腦用分接線接到滑鼠的時脈頻率線。

PS/2埠是一種PC相容型電腦系統上的介面,用來連結鍵盤滑鼠。其名稱來源於1987年IBM推出的個人電腦PS/2系列電腦。PS/2滑鼠連接通常取代舊式的序列滑鼠介面(DB-9 RS-232),而PS/2鍵盤連接則取代為IBM PC/AT設計的大型5針/180° DIN介面。PS/2的鍵盤及滑鼠介面在電氣特性上非常類似,採用了相同的通訊協定,但鍵盤介面需要雙向溝通。

PS/2平台引入了一個與鍵盤埠設計相同的第二個埠來連接滑鼠,然而某些系統的鍵盤和滑鼠埠可能無法互換,因為兩種裝置使用不同的指令集,且裝置驅動程式通常被硬編碼來分別在鍵盤與滑鼠的埠位址上與這些裝置通訊。在早期,如果對調鍵盤和滑鼠的插槽,大部份的桌上型電腦主機板無法正確識別。現在已經出現共享介面,能夠隨意插入鍵盤或滑鼠並正確識別處理。

目前,PS/2介面已逐漸被USB取代,僅少部分桌上型電腦仍提供完整的PS/2鍵盤滑鼠介面,部分機器甚至已無PS/2介面,大多數機器僅提供一組鍵盤及滑鼠共享的PS/2介面或僅供鍵盤使用。有些滑鼠及鍵盤可以使用轉換器將USB介面轉為PS/2,或者利用轉接線從USB分接成鍵盤和滑鼠的PS/2介面。不過,由於USB介面在未經特殊調整下僅能支援6鍵無衝突,而PS/2鍵盤介面則可支援所有按鍵同時無衝突。[來源請求]因此大多數主機板上的PS/2鍵盤介面仍被保留,但僅保留一組鍵盤滑鼠共享的PS/2介面的主機板日益普遍,鍵盤及滑鼠分別擁有單獨PS/2介面的主機板已相當少見。

需要注意的是,PS/2介面在設計上不支援熱插拔,儘管大多數PS/2鍵盤在實踐中可以熱插拔使用,但仍應避免這種行為。即使裝置支援混用鍵盤和滑鼠介面,跨介面類型的熱插拔通常無法實現,需要重啟裝置後才能正常工作,這是由控制器和作業系統的限制共同導致的。

Communication protocol

[編輯]

Each port implements a bidirectional synchronous serial channel.[1] The channel is slightly asymmetrical: it favors transmission from the input device to the computer, which is the majority case. The bidirectional IBM AT and PS/2 keyboard interface is a development of the unidirectional IBM PC keyboard interface, using the same signal lines but adding capability to send data back to the keyboard from the computer; this explains the asymmetry.[2]

The interface has two main signal lines, Data and Clock. These are single-ended signals driven by open-collector drivers at each end. Normally, the transmission is from the device to the host. To transmit a byte, the device simply outputs a serial frame of data (including 8 bits of data and a parity bit) on the Data line serially as it toggles the Clock line once for each bit. The host controls the direction of communication using the Clock line; when the host pulls it low, communication from the attached device is inhibited. The host can interrupt the device by pulling Clock low while the device is transmitting; the device can detect this by Clock staying low when the device releases it to go high as the device-generated clock signal toggles. When the host pulls Clock low, the device must immediately stop transmitting and release Clock and Data to both float high. (So far, all of this is the same as the unidirectional communication protocol of the IBM PC keyboard port, though the serial frame formats differ.) The host can use this state of the interface simply to inhibit the device from transmitting when the host is not ready to receive. (For the IBM PC keyboard port, this was the only normal use of signalling from the computer to the keyboard. The keyboard could not be commanded to retransmit a keyboard scan code after it had been sent, since there was no reverse data channel to carry commands to the keyboard, so the only way to avoid losing scan codes when the computer was too busy to receive them was to inhibit the keyboard from sending them until the computer was ready. This mode of operation is still an option on the IBM AT and PS/2 keyboard port.)[3]

To send a byte of data back to the device, the host pulls Clock low, waits briefly, pulls Data low and releases the Clock line again. The device then generates a Clock signal while the host outputs a frame of bits on the Data line, one bit per Clock pulse, similar to what the attached device would do to transmit in the other direction. However, while device-to-host transmission reads bits on falling Clock edges, transmission in the other direction reads bits on rising edges. After the data byte, the host releases the Data line, and the device will pull the Data line low for one clock period to indicate successful reception. A keyboard normally interprets the received byte as a command or a parameter for a preceding command. The device will not attempt to transmit to the host until both Clock and Data have been high for a minimum period of time.[4]

Transmission from the device to the host is favored because from the normal idle state, the device does not have to seize the channel before it can transmit—the device just begins transmitting immediately. In contrast, the host must seize the channel by pulling first the Clock line and then the Data line low and waiting for the device to have time to release the channel and prepare to receive; only then can the host begin to transmit data.

Port availability

[編輯]
PS/2 dualport, corresponding splitter (Y-cable) and pinout (female)

Older laptops and some contemporary motherboards have a single port that supports either a keyboard or a mouse. Sometimes the port also allows one of the devices to be connected to the two normally unused pins in the connector to allow both to be connected at once through a special splitter cable.[5] This configuration is common on IBM/Lenovo Thinkpad notebooks among many others.

The PS/2 keyboard interface is electrically the same as the 5-pin DIN connector on earlier AT keyboards, and keyboards designed for one can be connected to the other with a simple wiring adapter. Such wiring adapters and adapter cables were once commonly available for sale. Note that IBM PC and PC XT keyboards use a different unidirectional protocol with the same DIN connector as AT keyboards, so though a PC or XT keyboard can be connected to PS/2 port using a wiring adapter intended for an AT keyboard, the earlier keyboard will not work with the PS/2 port. (At least, it cannot work with normal PS/2 keyboard driver software, including the system BIOS keyboard driver.)

In contrast to this, the PS/2 mouse interface is substantially different from RS-232 (which was generally used for mice on PCs without PS/2 ports), but nonetheless many mice were made that could operate on both with a simple passive wiring adapter, where the mice would detect the presence of the adapter based on its wiring and then switch protocols accordingly.

PS/2 mouse and keyboard connectors have also been used in non-IBM PC-compatible computer systems, such as the DEC AlphaStation line, early IBM RS/6000 CHRP machines and SGI Indy, Indigo 2, and newer (Octane, etc.) computers.[6] Macintosh clone computers based on the "LPX-40" logic board design featured PS/2 mouse and keyboard ports, including the Motorola StarMax and the Power Computing PowerBase.[7]

Legacy port status and USB

[編輯]

PS/2 is now considered a legacy port, with USB ports now normally preferred for connecting keyboards and mice. This dates back at least as far as the Intel/Microsoft PC 2001 specification of 2000.

However, as of 2023, although PS/2 ports are rarely included in off the shelf computer systems, they continue to be included on some computer motherboards and are favored by some users for various reasons including the following:

  • PS/2 ports may be favored for security reasons in a corporate environment as they allow USB ports to be totally disabled, preventing the connection of any USB removable disks and malicious USB devices.[8]
  • The PS/2 interface provides no restriction on key rollover, although USB keyboards have no such restriction either, unless operated in BOOT mode, which is the exception.
  • To free USB ports for other uses like removable USB devices.
  • Some USB keyboards may not be able to operate the BIOS on certain motherboards due to driver issues or lack of support. The PS/2 interface has near-universal compatibility with BIOS.
  • The simplicity of PS/2 makes it useful for embedded systems and retro computers that may lack USB host peripheral. This also takes advantage of the wide availability of USB keyboard and mouses with PS/2 compatibility mode. [9]

Latency of mice

[編輯]

USB mice send data more quickly than PS/2 mice because standard USB mice are polled at a default rate of 125 Hz while standard PS/2 mice send interrupts at a default rate of 100 Hz when they have data to send to the computer.[10][11]

Also, USB mice do not cause the USB controller to interrupt the system when they have no status change to report according to the USB HID specification's default profile for mice.[12] Both PS/2 and USB allow the sample rate to be overridden, with PS/2 supporting a sampling rate of up to 200 Hz[1] and USB supporting a polling rate up to 1 kHz[10] as long as the mouse runs at full-speed USB speeds or higher, while USB 2.0 capable devices can support up to 8 kHz polling rates.

USB key rollover limitations

[編輯]

The USB HID keyboard interface requires that it explicitly handle key rollover, with the full HID keyboard class supporting n-key rollover. However, the USB boot keyboard class (designed to allow the BIOS to easily provide a keyboard in the absence of OS USB HID support) only allows 6-key rollover. Some keyboard peripherals support only the latter class, and some OSes may fail to switch to using the full HID keyboard class with a device after boot.[13]

Conversion between PS/2 and USB

[編輯]
Passive PS/2 to USB adapters
Active USB to PS/2 converter

Many keyboards and mice were specifically designed to support both the USB and the PS/2 interfaces and protocols, selecting the appropriate connection type at power-on. Such devices are generally equipped with a USB connector and ship with a passive wiring adapter to allow connection to a PS/2 port. Such passive adapters may be specific to the devices they came with; however, the most common configuration involves sharing the GND and Vcc (+5 V) pins of both protocols, connecting the USB D+ pin to the PS/2 +CLK pin, and connecting the USB D- pin to the PS/2 +DATA pin. Using such adapters requires a dual-mode controller on the keyboard or mouse side.[14][15][16]

USB to PS/2 passive adapter pinout[14]
USB pin Number USB pin Name PS/2 pin Number PS/2 pin Name
1 VBUS 4 Vcc
2 D− 1 +DATA
3 D+ 5 +CLK
4 GND 3 GND

Older PS/2-only peripherals can be connected to a USB port via an active converter, which generally provides a pair of PS/2 ports (which may be designated as one keyboard and one mouse, even though both ports may support both protocols) at the cost of one USB port on the host computer.[17]

Color code

[編輯]
Color / Pantone Function Connector on PC
  Green / 3395C PS/2 mouse / pointing device 6-pin mini-DIN female
  Purple / 2715C PS/2 keyboard

Original PS/2 connectors were black or had the same color as the connecting cable (mainly white). Later, the PC 97 standard introduced a color code: the keyboard port, and the plugs on compliant keyboards, were purple; mouse ports and plugs were green. (Some vendors initially used a different color code; Logitech used the color orange for the keyboard connector for a short period, but soon switched to purple.) Today this code is still used on most PCs. The pinouts of the connectors are the same, but most computers will not recognize devices connected to the wrong port.

Hardware issues

[編輯]

Hotplugging

[編輯]

PS/2 ports are designed to connect the digital I/O lines of the microcontroller in the external device directly to the digital lines of the microcontroller on the motherboard. They are not designed to be hot swappable. Hot swapping PS/2 devices usually does not cause damage because more modern microcontrollers tend to have more robust I/O lines built into them which are harder to damage than those of older controllers;[18] however, hot swapping can still potentially cause damage on older machines, or machines with less robust port implementations.

If they are hot swapped, the devices must be similar enough that the driver running on the host system recognizes and can be used with the new device. Otherwise, the new device will not function properly. While this is seldom an issue with standard keyboard devices, the host system rarely recognizes the new device attached to the PS/2 mouse port. In practice most keyboards can be hot swapped but this should be avoided.

Durability

[編輯]

PS/2 connectors are not designed to be plugged in and out very often, which can lead to bent or broken pins. Additionally, PS/2 connectors only insert in one direction and must be rotated correctly before attempting connection. (If a user attempts to insert the connector in the wrong orientation and then tries to rotate it to the correct orientation without first pulling it out, then bent pins could result.)

Most but not all connectors include an arrow or flat section which is usually aligned to the right or top of the jack before being plugged in. The exact direction may vary on older or non-ATX computers and care should be taken to avoid damaged or bent pins when connecting devices. This issue is slightly alleviated in modern times with the advent of the PS/2-to-USB adapter: users can just leave a PS/2 connector plugged into the PS/2-to-USB adapter at all times and not risk damaging the pins this way. A USB-to-PS/2 adapter does not have this problem.

Fault isolation

[編輯]

In a standard implementation both PS/2 ports are usually controlled by a single microcontroller on the motherboard. This makes design and manufacturing extremely simple and cheap. However, a rare side effect of this design is that a malfunctioning device can cause the controller to become confused, resulting in both devices acting erratically. (A well designed and programmed controller will not behave in this way.) The resulting problems can be difficult to troubleshoot (e.g., a bad mouse can cause problems that appear to be the fault of the keyboard and vice versa).

References

[編輯]
  1. ^ 1.0 1.1 The PS/2 Mouse Interface. 1 April 2003. (原始內容存檔於16 September 2008). 
  2. ^ Compare the logic diagrams in the IBM Personal Computer Technical Reference manual with those in the IBM Personal Computer AT Technical Reference manual.
  3. ^ IBM Personal Computer Technical Reference, IBM Personal Computer AT Technical Reference
  4. ^ IBM Personal Computer AT Technical Reference
  5. ^ PS/2 Keyboard (IBM Thinkpad) Y adapter. RU: Pinouts. [2011-06-14]. 
  6. ^ Lenerz, Gerhard. Common Input Devices. Hardware. SGIstuff. 7 November 2006 [2007-03-14]. (原始內容存檔於2007-06-26). 
  7. ^ Power Computing PowerBase. Low end Mac. [2011-04-04]. 
  8. ^ Anthony, Sebastian. Massive, undetectable security flaw found in USB: It's time to get your PS/2 keyboard out of the cupboard. ExtremeTech. Ziff Davis, LLC. 31 July 2014 [26 October 2015]. 
  9. ^ Eater, Ben. So how does a PS/2 keyboard interface work?. www.youtube.com. YouTube. [14 December 2024]. 
  10. ^ 10.0 10.1 Mouse Optimization Guide: Acceleration Fix and Polling Rate. eu.cybergamer.com. 2011-07-26 [2024-10-16]. 
  11. ^ LCOM 2012/2013: Lab5. web.fe.up.pt. [2024-10-16]. 
  12. ^ Device Class Definition for HID 1.11 (PDF). (原始內容 (PDF)存檔於11 August 2014). 
  13. ^ N-key Rollover via PS/2 and USB. Geek hack. (原始內容存檔於2010-12-25). 
  14. ^ 14.0 14.1 USB to PS/2 mouse or keyboard adapter pinout signals @ PinoutGuide.com. pinoutguide.com. [2024-10-28]. 
  15. ^ enCoRe™ USB Combination Low-Speed USB and PS/2 Peripheral Controller. CY7C63722, CY7C63723, CY7C63743 (PDF). Cypress Semiconductor. 2004-09-27: 3. 
  16. ^ USB and PS/2 Multimedia Keyboard Interface. Designer Reference Manual. M68HC08 Microcontrollers (PDF). Freescale Semiconductor. 2006: 8. 
  17. ^ The pros and cons of PS-2 to USB adapters and converters需要免費註冊. TechTarget. 
  18. ^ Adam Chapweske. The PS/2 Mouse/Keyboard Protocol. 2003-09-05 [2016-11-26]. (原始內容存檔於2016-11-16). 
[編輯]