新闻中心

EEPW首页>模拟技术>设计应用> 电脑键盘工作原理

电脑键盘工作原理

作者: 时间:2012-01-25 来源:网络 收藏
ine. If the line is inactive, output from the device is not allowed.
辅助设备(指) 检查 时钟线 ,如果时低电平,禁止发送数据


The auxiliary device checks the 'data' line. If the line is inactive, the controller receives data from the system.
设备检查数据线,如果是 低电平,那么控制器从系统接收数据

The auxiliary device checks the 'clock' line during the transmission at intervals not exceeding 100 microseconds. If the device finds the system holding the 'clock' line inactive, the transmission is terminated. The system can terminate transmission anytime during the first 10 clock cycles.
设备在传输过程中 检查 时钟 线 间隔不超过100us。 如果设备发现 主机系统 将电平拉低,就终止传输。 在传输过程的前10个时钟周期的任何时候,主机系统可以中止传输。


A final check for terminated transmission is performed at least 5 microseconds after the 10th clock.
终止传输的最后一个检查 要持续至少5us




The system can hold the 'clock' signal inactive to inhibit the next transmission.
系统拉低时钟线,将禁止下一次传输


The system can set the 'data' line inactive if it has a byte to transmit to the device. The 'data' line is set inactive when the start bit (always 0) is placed on the 'data' line.
系统如果有一个字节要传输给设备,可以拉低数据线。当开始位(总是0)放置到数据线时,数据线被拉低。


The system raises the 'clock' line to allow the next transmission.
系统拉高时钟将允许下一次传输


Host-to-Device主机到设备的通信
First of all, the PS/2 device always generates the clock signal.
首先,PS/2设备总是产生时钟信号

If the host wants to send data, it must first put the Clock and Data lines in a "Request-to-send" state as follows:
如果主机想发送数据,它必须先将时钟线和数据线设置成"Request-to-send"状态:
1) Inhibit communication by pulling Clock low for at least 100 microseconds.
拉低时钟线至少100us来禁止通信
2) Apply "Request-to-send" by pulling Data low, then release Clock.
拉低数据线,请求 "Request-to-send", 然后释放时钟 .


The device should check for this state at intervals not to exceed 10 milliseconds.
设备应该在不超过10ms(注意,是毫秒)的间隔内就要检查一次这个状态。

When the device detects this state, it will begin generating Clock signals and clock in eight data bits and one stop bit.
当设备检测到这个状态,它将开始产生时钟信号,


The host changes the Data line only when the Clock line is low, and data is read by the device when Clock is high.
只有当时钟线 为低的时候,主机才可以改变数据线(也就是将数据写入到数据线)。数据将在时钟为高电平的时候 被 设备读取。


After the stop bit is received, the device will acknowledge the received byte by bringing the Data line low and generating one last clock pulse.
在收到停止位之后,设备将通过拉低数据线,生成最后一个时钟脉冲 来 应答收到的字节


If the host does not release the Data line after the 11th clock pulse, the device will continue to generate clock pulses until the the Data line is released (the device will then generate an error.)
在第11个时钟脉冲之后,如果主机并没有释放数据线,设备将继续产生时钟脉冲,直到数据线被释放(然后 设备将产生一个错误)


The host may abort transmission at time before the 11th clock pulse (acknowledge bit) by holding Clock low for at least 100 microseconds.
在第11个脉冲之前(回应位),主机可以随时中止传输,只要拉低时钟持续100us即可


时间参数 最大值/最小值
T7 时钟低电平 30-50 us
T8 时钟高电平 30-50 us
T9 30-50 us



T9 == Time from inactive to active CLK transition, used to time when the auxiliary device samples DATA

电脑键盘工作原理

FreeScale(Moto)提供的时序图
主机到的数据传输



1.主机 通过拉低 时钟线 来 启动一个主机到的数据传输。大约35us后,主机拉低数据线
。这个事件序列 就是 通知 键盘,主机要传输一个命令了。在数据信号的下降沿大约 125us 后 时钟信号释放,就被键盘内部的上拉电阻拉为高电平 。

2. 在时钟信号的上升沿 约 1ms ,数据传输开始。这个期间,数据线保持低电平。键盘拉低时钟线,clocking in the low data line. 这个就做传输的起始位。

3. 键盘用时钟驱动 8个数据位从主机传输到自己这边。 这个时钟有50%的占空比(duty cycle).高电平和低电平的时间都在30~50us之间。主机在每个周期的低电平的时候改变数据线上的数据。在每个时钟的上升沿5~25us之后键盘 开始从数据线上取样,取出主机发来的数据。

4.数据位之后是一个奇偶校验位(采用奇校验)

5.最后是停止位

6.如果键盘读到一个高电平的停止位,键盘就在 取样停止位的那个时钟的下降沿 之后的低电平期间 拉低数据线。这个行为叫做 键盘给主机的应答信号。
键盘拉高时钟之后,也拉高数据线。


7.在收到一个字节后,键盘对接收的数据执行一个奇偶校验。如果奇偶校验错误,或者接收的数据无法识别为有效的命令,那么键盘请求重新发送(发送0xFE给主机)


电脑键盘工作原理

1. 键盘发送数据前,首先必须让时钟 和数据线都在键盘内部的上拉电阻作用下 拉成高电平。然后键盘拉低数据线,5-25us之后,键盘拉低时钟线。在时钟的下降沿,开始传输起始位The falling edge of the clock line clocks in the transfer’s start
bit.


2. 键盘用时钟驱动 8个数据位到主机。 这个时钟有50%的占空比(duty cycle).高电平和低电平的时间都在30~50us之间。键盘在每个周期的高电平的时候改变数据线上的数据。这个改变出现在时钟的上升沿的5us后 和 下降沿的5us前。键盘的数据在时钟的下降沿被锁存进主机。


3.数据位之后是一个奇校验位

4.最后是停止位。在时钟的下降沿 0~50us之间 主机拉低时钟 来锁存停止位。这就告诉键盘主机现在忙,不能在接收 其他的键盘传输数据。在处理完接收的数据,准备好接收下一个数据之前,主机释放时钟。


6.在键盘传输数据到主机的过程中,主机任何时候都可以中断这个传输,发送一个命令到键盘。主机拉低时钟和数据线 即可中止传输。所以,键盘在时钟为 低电平的时候必须取样数据线。(无论什么时候输出高数据位的时候)。在产生时钟的上升沿时,必须读取时钟。

在任何时候发现这两个条件不满足,就拉高时钟和数据线,放弃这次传输,并准备从 主机接收命令。

电脑键盘工作原理

Moto 香港公司的 Derek Lau

当时钟 高电平是,发送给主机的数据被主机读取。在空闲状态,时钟和数据线都被拉为高电平。主机 拉低 时钟最少100ms(?还是us)开始发送数据给键盘:

1.主机等待,直到没有外部设备传输被处理

2.主机 拉低时钟

3.主机拉低数据作为开始位

4 .主机释放时钟

5.设备拉低时钟

6.主机发送数据

7.设备释放时钟,读取数据

8.设备检查时钟线,如果时钟为低,中止传输

9.重复 5-7步,发送 数据1-到数据0,以及 奇校验位

10. 设备拉低时钟

11. 主机释放数据

12.设备时钟时钟

13.设备读取数据线,想得到停止位,如果数据线为低(不是停止位),产生错误

14.设备拉低 时钟和数据线

15.设备释放 时钟和数据线


电脑键盘工作原理

从设备发送到主机的数据,在时钟的下降沿被读取。在发送数据前,设备检查通过检测时钟信号为高来得知 主机是否贮备好:

1.键盘(设备)等待时钟为高(约50ms?us)

2.如果数据为 低,终止

3.键盘 发送数据

4.键盘拉低时钟为低

5.键盘释放时钟为高

6.键盘 读取时钟线,如果时钟为低,中止传输

7.重复 4-6步,传输数据0-数据7,

DIY机械键盘相关社区:机械键盘DIY




评论


相关推荐

技术专区

关闭