Xem mẫu
- Chương 6: Bàn phím
Keypad
n
Keyboard
n
6.1 Keypad – bàn phím 4x4
S901 S902 S903 S904
K0 K1 K2 K3
K4
S911 S912 S913 S914
K5
S921 S922 S923 S924
K6
S931 S932 S933 S934
K7
1
- 6.1 Keypad – bàn phím 4x4
Đọc bàn phím
n
Quét vòng?
n
n Sử dụng ngắt?
Chống rung
n
Kiểm tra thời gian của bit trạng thái (0 or 1) đủ “dài”
n
n Dùng t ụ để lọc nhiễu đầu vào
6.1 Keypad – bàn phím 4x4
2
- 6.1 Keypad – bàn phím 4x4
#define keypad_out PORTA
#define keypad_in PINA
flash char row[4] = {0xEF, 0xDF, 0xBF, 0x7F};
DDRA = 0xF0;
for(i=0; i
- 6.1 Keypad – Resistor matrix & ADC
If the key "5" is pressed, a voltage
divider gets active:
* 1 k + 820 Ω = 1,82k to ground,
* 3,3 k + 680 Ω + 180 Ω = 4,16k to
plus.
At an operating voltage of 5 Volt a
divided voltage of:
5 * 1,82 / (1,82 + 4,16) = 1,522 Volt
6.2 Keyboard – PC Keyboard
AT keyboard goàm moät ma traän lôùn caùc phím, taát caû
ñöôïc giaùm saùt bôûi moät boä xöû lyù on-board. Boä xöû lyù
khaùc bieät nhau töø baøn phím naøy ñeán baøn phím
khaùc( chip thoâng duïng goàm 8048, 8049, 6868 vaø
6805) nhöng taát chuùng cô baûn laøm gioáng moät vieäc :
Giaùm saùt nhöõng phím ñöôïc nhaán / thaû vaø gôûi döõ
lieäu töông xöùng tôùi maùy chuû. Boä xöû lyù naøy chaêm
soùc taát caû döõ lieäu ra vaø ñeäm baát cöù döõ lieäu naøo vaøo
boä ñeäm 16-byte cuûa noù neáu caàn. Taát caû vieäc giao
tieáp giöõa maùy chuû vaø baøn phím duøng PS/2 protocol.
4
- 6.2 Keyboard – PC Keyboard
6.2 Keyboard – PC Keyboard
The keyboard sends data to the host in 11-bit words
n
Contain a ‘0’ start bit, followed by 8-bits of scan
n
code (LSB first), followed by an odd parity bit and
terminated with a ‘1’ stop bit.
The keyboard generates 11 clock transitions (at
n
around 20 - 30KHz) when the data is sent, and data
is valid on the falling edge of the clock.
5
- 6.2 Keyboard – PC Keyboard
Keyboard to Host
Host to Keyboard
6
nguon tai.lieu . vn