Tài liệu Thiết bị ngoại vi và ghép nối . chương 2 - Pdf 10

1
P&I-Ch2: Protocols 1
ch. 2 giao thức ghép nối
(Interfacing Protocols)
Bao gồm:
- Giao thức ghép nối
- Đặc điểm lập trình I/O
P&I-Ch2: Protocols 2
2.1. Interface Protocols:
K/n: Là các qui định:
Signals, cable, port, connector
Data format
Rate
Error detection & correction
Command & Response set
Scenario (kịch bản)
ISO 7 layer Model (Ref. Computer networks)
Có thể phân chia thành 2 nhóm chính:
Transport-Oriented Protocols (1 4) (!!!)
PhysicAL (wire, cable, connector, port), DataLink (CRC,
CS, Token), NetWork (Comm. 2 networks ), Transport
(Err-protected raw infor),
Application-Oriented Protocols (5 7) :
Session (Opening, End), Presentation (Common
Language) và Application (Read/Write, Start/Stop,
FileTransfer)
2
P&I-Ch2: Protocols 3
2.1. Interface Protocols: 2.1.1. Signals:
Khi thiết kế, xây dựng ghép nối máy tính, cần chú ý
đặc biệt tới tín hiệu theo các yêu cầu:

P&I-Ch2: Protocols 6
2.1. Interface Protocols: 2.1.1. Signals:
• VÝ dô 1: PC-LPT handshaking:
PC
LPT port
Line Printer
SLCT SLTC_in
H×nh 2.1.a. LPT handshake
Signal
4
P&I-Ch2: Protocols 7
2.1. Interface Protocols: 2.1.1. Signals:
• VÝ dô 2: PC Comm-Modem handshaking - ch.5. Tuy
nhiªn cã thÓ b¾t tay b»ng ký tù, kh«ng dïng t/h
RTS CTS
DTR DSR
PC 1
Comm
Port
Modem
or
PC 2
Comm
Port
H×nh 2.1.b. CommPort Handshake Signals
•Ph−¬ng ph¸p biÕn ®æi tÝn hiÖu: biªn, tÇn, pha,
dßng, quang (c¸p quang, Ir)
P&I-Ch2: Protocols 8
2.1. Interface Protocols: 2.1.1. Signals:
•T/c vật lý của tín hiệu: là hàm của thời gian, mức áp/dòng

•Ví dụ đối chứng:
– RS232: đơn cực, 9600bps chỉ dẫn xa được 100
feet (33m)
• Mouse, … ghép nối các thiết bị trong PTN, test…
• Profibus, USB, Ethernet dùng biến áp xung…
•Có thể dùng dây không bọc kim
6
P&I-Ch2: Protocols 11
• Khả năng phối hợp tải - dòng điện ra: (Fan Out,
Loading):
+ Number of Standard/LS TTL loads, chú ý chiều
dòng điện
+ Sink: dòng vào – LowLevel, (cỡ mA), +
Source: dòng ra – HighLevel, mA/uA.(H. 2.1.c)
• Nối chung/ghép nối bus đơn giản: 3 state (Hi Z), open
collector (Open Drain), Mux – dồn kênh, Switch - khóa.
• Hot swap – hot plugible: Y/c Vcc và t/h ( www.atmel.com
)
• Cách ly (isolation): Relay, Opto Coupler, IrLED
• Bus Slot, Connector, chuẩn, số chân (pin)
P&I-Ch2: Protocols 12
7
P&I-Ch2: Protocols 13
H. 2.1d. Open Collector. Nếu là FET, so called
Open Drain
P&I-Ch2: Protocols 14
S¬ ®å c¸ch ly quang häc ®/v tÝn hiÖu In/Out:
Hình 2.2. Opto Coupler
8
P&I-Ch2: Protocols 15

ký tự đồng bộ, số ký tự/ byte trong gói tin ], không mang tin.
Content: nội dung tin - mang thông tin.
Tailer: M bắt tay kết thúc, [m kiểm tra lỗi] - không mang tin.
Ví dụ: HDC, FDC: Full Sector: gap - 5 byte ID field - 2 byte ID
CRC - gap - data field: 512 byte - 2 byte CRC.
FTP, Kermit, X-Modem Protocols: 128[256] B/pack.
10
P&I-Ch2: Protocols 19
• Byte sè liÖu/character/frame: (truyÒn kh«ng ®ång bé,
RS-232, RS-485, RS-422 ): ký tù hay byte ®−îc ®Þnh
d¹ng thµnh 1 frame:
• 1 start bit = 0,
• 5/6/7/8 data bit, D0 first,
• [parity: Even/ Odd],
• 1 / [1.5 / 2] stop bit = 1(s).
H×nh 2.3.d. USB data packet format
P&I-Ch2: Protocols 20
2.1. Interface Protocols:
2.1.3. Tèc ®é và kho¶ng c¸ch trao ®æi th«ng tin:
•Xuất phát từ: Nhu cầu trao đổi thông tin của hệ (tốc độ và khoảng
cách) => chọn kiểu truyền thích hợp, có liên quan tới t/h:
•Chỉ ra ”bottle-neck”, khắc phục được => xuất hiện hiện bottle
neck, ở mức độ thấp hơn,
•Phụ thuộc Khoảng cách - tích số (k/c và tốc độ)
•Nhiễu: theo công thức Shannon: bps = BW log2 (1+P/N). Với
BW: bandwidth, P/N tỷ số công suất tín hiệu/ nhiễu (not a dB
ratio)
• Đường truyền: (công nghiệp), đường truyền (cáp
đồng, quang,
wireless: radio, infrared),

- A(National): VN 893, CN 690-692, JP 45-49, GE 400-440,
RU 460-469
- B: com/ org
- C: Product
- D - Check sum, right most: (right to left):
- 10 - [(D2*3 + D3*1 + D4*3 + D5*1 + D13*1)mod10]
Ví dụ: 893 12345 1234 7
• CODE 128, Zebra, check sum modulo 103
12
P&I-Ch2: Protocols 23
2.1. Interface Protocols:
2.1.5. Command & Response (Result/Reaction) set:
• Khi ghép Intelligent Devices (Computerized devices -
mouse, KB, Printer, modem, FDC, HDC, RTU ) có
nhiều tham số, chế độ hoạt động => xây dựng bộ lệnh
(command set) và thông tin trả về (response set).
• Các câu lệnh phần mềm => bớt tín hiệu và cổng phần
cứng.
•Tập hợp các yêu cầu từ CS - command set,
•Tập hợp các trả lời, trạng thái - result/response/
reaction set.
• Data down/up
• Syntax of command and response (structure and
grammar).
P&I-Ch2: Protocols 24
2.1. Interface Protocols:
2.1.5. Command & Response (Result) set:
Case Studies: lệnh AT và Response Hayes MODEMs:
Lệnh: ATDT 1260 ? ' Với nhiều Options
Trả lời (reaction) OK [Error] . . . Connect @19200 (result)

Master ENQ Slave
ACK
NAK
nothing
14
P&I-Ch2: Protocols 27
H×nh 2.5. USB Interlayer Interconnection Model
P&I-Ch2: Protocols 28
2.2. Ph©n miÒn vµ lÖnh I/O: 2.2.1. IO Mapping:
H×nh 2.6. Ph©n miÒn c¸c cæng I/O
15
P&I-Ch2: Protocols 29
Memory Mapped IOs:
o IOs chung với Mem trong MemSpace => chiếm vùng
nhớ, tn vựng nh
o CPU xử lý các cổng IO bằng các lệnh nh đ/v mem.
IO Mapped IOs: (Z80, x86 ):
o Không chiếm không gian nhớ,
o CPU chỉ thực hiện 2 lệnh: IN và OUT

x86 CPUs IO map: IO mapped IOs, 16 Addr bit IO
=> 64Kilo IO locations.
PCs IO map:
o IO Mapped IOs,
P&I-Ch2: Protocols 30
2.2.2. Lệnh In/Out: (x86) :
Lệnh IN và OUT: chỉ dùng các thanh ghi Accumulator:
8 bit: AL, 16 bit: AX và 32 bit: EAX.
Chế độ địa chỉ:
o Direct: for IO space: 0 0FFh

8
–IRQ
15
0C0-0CF DMAC #2, 3 kênh DRQ 16
bit
0E0-0EF reserved, để dành
110-16F AVAILABLE, để dành
170-17F Hard Drive 1 (AT)
180-1EF AVAILABLE
1F0-1FF Hard Drive 0 (AT)
200-20F Game Adapter
17
P&I-Ch2: Protocols 33
210-217 Expansion Card Ports
220-26F AVAILABLE
278-27F Parallel Port 2/ LPT2
280-2A1 AVAILABLE
2A2-2A3 clock
2B0-2DF EGA/Video
2E2-2E3 Data Acquisition Adapter (AT)
2E8-2EF Serial Port COM4
2F0-2F7 Reserved
2F8-2FF Serial Port COM2
300-31F Prototype Adapter, cho người dùng
phát triển
320-32F AVAILABLE
P&I-Ch2: Protocols 34
340-35F AVAILABLE
360-36F Network, LAN adaptor
370-377 Floppy Disk Controller


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status