Giao thức ghép nối

Bao gồm: - Giao thức ghép nối - các nhóm lập trình I/O 1. Interface Protocols: ãK/n: quy định: Signals - Data format - Rate - Error detection & correction - Command & Response - Scenario ISO 7 layer Model (Ref. Computer networks) Các thành phần chia thành 2 nhóm chính: ãTransport-Oriented Protocols (1 4) (!!!) –PhysicAL (wire, cable, connector), 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) ã

ppt25 trang | Chia sẻ: tlsuongmuoi | Lượt xem: 1980 | Lượt tải: 1download
Bạn đang xem trước 20 trang tài liệu Giao thức ghép nối, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
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 2.1. Interface Protocols: K/n: Lµ c¸c qui ®Þnh: Signals - Data format - Rate - Error detection & correction - Command & Response - 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), 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.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: bus hay kh«ng? => cã dïng bit (tr­êng) ®Þa chØ Standard bus? ?: IDE vµ LPT cable cã ph¶i lµ bus? t¹i sao? Data: Serial vs Parallel Interface, format? Daisy chain cho t/h hoÆc nguån cÊp... C¸c tÝn hiÖu ®iÒu khiÓn vµ tr¹ng th¸i: Control signals Status signals Handshaking signals 2.1. Interface Protocols: 2.1.1. Signals: VÝ dô 1: PC-LPT handshaking: Ph­¬ng ph¸p ®iÒu chÕ tÝn hiÖu: ®iÒu biªn , tÇn, pha, dßng ®iÖn. quang (c¸p quang, Ir) 2.1. Interface Protocols: 2.1.1. Signals: VÝ dô 2: PC Comm-Modem handshaking: 2.1. Interface Protocols: 2.1.1. Signals: T/c vËt lý cña tÝn hiÖu: - Møc ®iÖn ¸p: Voltage (TTL, 12V/ 24V/48V...) In/Out, Single End vs Differential (vi sai) - Møc dßng ®iÖn: (Fan Out, Loading): - Number of Standard TTL/ LS TTL loads, - Sink: dßng chảy vµo – LowLevel, mA, - Source: dßng chảy ra – HighLevel, mA/A. (H. 2.1.c) - Nèi chung c¸c tÝn hiÖu ra: 3 state, open collector, (Open Drain), Mux, Switch. Hot swap – hot plugible: Y/c Vcc và t/h C¸ch ly (isolation): Relay, Opto Coupler, IrLED... Bus Slot, Connector, sè ch©n (pin) S¬ ®å c¸ch ly quang häc ®/v tÝn hiÖu In/Out: In/Out Out/In Vcc1 Vcc2 Connectors: D shell: DB9, DB25,... DIN, Cable & Connectors: H×nh 2.3.a. Connectors Cable: Flat, Coaxial, Shield, Twisted Pair Optical Fiber... H×nh 2.3.b. Optical Connector & S¬ ®å: H×nh 2.3.c. Sîi c¸p quang: 2.1. Interface Protocols: 2.1.2. Format sè liÖu: ®èi víi file/text: sè liÖu nhiÒu => khi trao ®æi (với DAS, PLC, Digi-Oscilloscope, GPS, TelSat...)  ‘®ãng gãi’ sè liÖu (packaging). Mçi gãi tin (packet) gåm 3 phÇn: ·     Header: [tªn b¶n tin, tªn gãi, sè thø tù, ký tù b¾t tay, ký tù ®ång bé, sè ký tù/byte trong gãi tin...], kh«ng mang tin. ·     Content: néi dung tin. ·     Tailer: M· b¾t tay kÕt thóc, [m· kiÓm tra lçi] 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. H×nh 2.3.d. USB data packet format 2.1. Interface Protocols: 2.1.2. Format sè liÖu: Byte sè liÖu/character:(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 bits, D0 first, ·  [parity: Even/ Odd], · 1 / [1.5 / 2] stop bit = 1s. 2.1. Interface Protocols: 2.1.3. Tèc ®é trao ®æi th«ng tin: XuÊt ph¸t tõ: Nhu cÇu trao ®æi th«ng tin cña T/b ngo¹i vi (LED Board, ADC..), => chän m«i tr­êng truyÒn thÝch hîp, cã liªn quan tíi t/h: Song song(B)/ nèi tiÕp(b) Kho¶ng c¸ch M«i tr­êng, ®­êng truyÒn Synchronous/Asynchronous Modulation/Demodulation   ... => tèc ®é bao nhiªu kbps/kBps, tèc ®é chuÈn? 2.1. Interface Protocols: 2.1.4. KiÓm tra, söa lçi, n©ng cao ®é tin cËy: Khi trao ®æi th«ng tin th­êng hay g©y ra lçi, ®Æc biÖt truyÒn xa. NhiÒu FF (Hardware, Software) hç trî ®Ó kiÓm tra: [Block] check sum - BCC, phÇn mÒm, CRC, ECC, IC/ subroutine Parity, Redundancy (RAID) Barcode:Ph­¬ng ph¸p m· hãa, gi¶i m· vµ kiÓm tra lçi 2.1. Interface Protocols: 2.1.4. KiÓm tra, söa lçi, n©ng cao ®é tin cËy: Bar Code: EAN 13, CODE 39, CODE 128, UPC ... EAN 13 (European article numbering) Encoding: AAA BBBBB CCCC D - 4 ®é dµy v¹ch, 6 v¹ch/digit (b&w) A(National): VN 893, CN 690-692, JP 45-49, GE 400-440, RU460-469 B: com/ org C: Product D - Check sum, right most: (right to left) 10 - [(D2*3 + D3*1 + D4*3 + D5*1...+ D12*1)mod10] VÝ dô: 893 12345 1234 7 CODE 128, Zebra, check sum modulo 103 2.1. Interface Protocols: 2.1.5. Command & Response (Result) set: Intelligent Devices cã nhiÒu tham sè, chÕ ®é ho¹t ®éng => x©y dùng bé lÖnh (command set) vµ tr¶ lêi (response set). Dïng phÇn mÒm ®Ó xö lý => bít tÝn hiÖu. ·     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 set. C¸c c©u lÖnh vµ tr¶ lêi ®Òu cã syntax (cÊu tróc vµ ng÷ ph¸p). 2.1. Interface Protocols: 2.1.5. Command & Response (Result) set: Case Study:  lÖnh AT vµ Response cña Hayes MODEMs: LÖnh: ATDT 8530555  ' Víi nhiÒu Options Tr¶ lêi OK [Error] . . . Connect @19200 LÖnh FX Printer: Esc * m, n1, n2; Sel Graph Mode Bé lÖnh cña c¸c thiÕt bÞ chuyªn dïng: GPS, Gyro- Compass, Digi-Oscilloscope, SAGEM, TelSat... 2.1. Interface Protocols: 2.1.5. Command & Response (Result) set: 1 command/response th­êng cã cÊu tróc: o  m· b¾t ®Çu (m· ®Æc biÖt nh­ @ / # / $... o m· lÖnh, 1..3 bytes, o tham sè lÖnh, 1... n bytes, o m· check sum, CRC (dÔ xö lý) o m· kÕt thóc, ký tù ®Æc biÖt. Cã thªm c¸c m· (ký tù) ®èi tho¹i nh­: ENQ, ACK, NACK, !, Bell, OK, ERR ... 2.1. Interface Protocols: 2.1.6. KÞch b¶n ®èi tho¹i – Scenario: LiÖt kª c¸c tr­êng hîp cã thÓ råi ¸p c¸c phÐp xö lý t­¬ng øng ®Ó ®¶m b¶o viÖc ghÐp nèi: kh«ng mÊt tin, thõa tin, quÈn, treo... Th­êng x©y dùng: Step List hoÆc Chart: Time Out ! Master ENQ Slave ACK NAK nothing H×nh 2.5. USB Interlayer Interconnection Model 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 ·  Memory Mapped IOs: o Chung víi Mem trong MemSpace => chiÕm 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 CPU’s IO map: IO mapped IOs, 16 Addr bit IO => 64Kilo IO locations. ·      PC’s IO map: o   IO Mapped IOs, o  ChØ dïng 10 lowest addr bit => 1 kilo IO locations Mirrored víi 63 kilo cßn l¹i, Mçi IO port chiÕm nhiÒu ®Þa chØ (nh­ PIC, PIT, PPI..) => thiÕu IO space. SÏ dïng thªm kiÓu Mem Mapped IOs. 2.2.2. LÖnh In/Out: (x86) : ·      LÖnh IN vµ OUT: chØ dïng c¸c thanh ghi Accu: AL, AX vµ EAX ·      ChÕ ®é ®Þa chØ: o   Direct: for IO space: 0..0FFh § VÝ dô: in al,60h ; ... out 23Eh, ax ; lÖnh sai out 61h,al ; ... o   Indirect: for IO space 0..0FFFFh, via dx register §      VÝ dô: mov dx,378h ; mov al, ‘A’ ; out dx,al ; mov dx,3F8h ; in al,dx ; Bµi tËp ch­¬ng 2 2.1. Tham kh¶o mét sè giao thøc: MODBUS (AEG), ProfiBus, ASI (Siemens), RTU ASCII (ABB), I2C... tõ ®ã thiÕt kÕ ®å ¸n m«n häc: hÖ thu thËp - ®iÒu khiÓn ph©n t¸n (Mini SCADA) 2.2. USB Protocol 2.3. ThiÕt kÕ giao thøc truyÒn file gi÷a 2 m¸y tÝnh (LPT/ Comm).

Các file đính kèm theo tài liệu này:

  • pptGiao thức ghép nối.ppt
Tài liệu liên quan