Presentation is loading. Please wait.

Presentation is loading. Please wait.

Robocon 2007, Hong Kong University of Science & Technology Robocon 2007 Electronics Quickstart! Session 4 Communication Prepared by KI Chi Keung [chikeung.

Similar presentations


Presentation on theme: "Robocon 2007, Hong Kong University of Science & Technology Robocon 2007 Electronics Quickstart! Session 4 Communication Prepared by KI Chi Keung [chikeung."— Presentation transcript:

1 Robocon 2007, Hong Kong University of Science & Technology Robocon 2007 Electronics Quickstart! Session 4 Communication Prepared by KI Chi Keung [chikeung @ ust.hk] WONG Long Sing (Sam) [sam @ hellosam.net]

2 Robocon 2007, HKUST Today ’ s Timeline 1.Communication Process 2.Layers of Communication 3.Implementation 4.RS232 / UART in-depth

3 Robocon 2007, HKUST Communication Process How communication can be done?

4 Robocon 2007, HKUST Parallel Communication At least, consist of a Data bus and a clock line Data line is mapped bit by bit. A Natural expansion of CPU/MCU design. Example –LCD –Parallel Port –(Parallel) ATA –Floppy –SDRAM (Synchronous Dynamic Random Access Memory) –PCI Bus

5 Robocon 2007, HKUST Parallel Communication Timing Diagram Data Clock Synchronization Data Stable Data

6 Robocon 2007, HKUST Serial Communication Only need one data line only No explicit clock. Either embedded or synchronized from time to time Example –UART –PS/2 Keyboard, Playstation Controller –USB –Ethernet –PCI Express Bus

7 Robocon 2007, HKUST Serial Communication Timing Diagram Data SynchronizationBus Idle Data Transmitted at agreed rate

8 Robocon 2007, HKUST Comparison Serial bus is more complex and harder to implement in nature CMSSCSRE Parallel bus require synchronization to slowest data line Electrical parallel bus suffers from crosstalk Parallel bus occupies more real estate

9 Robocon 2007, HKUST Layers of Communication Communication, or data exchange, is a complicated process. It is usually taught and understood in layers. OSI model describes 7 Layers We will focus on 3 of the 7 layers which do us good –Physical Layer (Layer 1) –Data Link Layer (Layer 2) –Application Layer (Layer 7)

10 Robocon 2007, HKUST Layers of Communication A layer can rely on the functionality of immediate bottom layer to facility data exchange A layer is only responsible to service the immediate upper layer If everything is well defined –application can communication with application almost without any knowledge of any bottom layer –Layers can be interchanged

11 Robocon 2007, HKUST Layers of Communication Application Layer (7) –Human, Computer Application (Web, FTP, Email…) Many other layers (6..3) –Human Language –TCP / UDP / IP / Part of USB / Part of I2C… Data Link Layer (2) –Human Speaking usual practice –Ethernet’s Carrier sense multiple access with collision avoidance (CSMA-CA) / detection (CSMA-CD) Physical Layer (1) –Wired (Telephone, Modem, LAN) –Wireless (Cell phone, Wifi) –Sound wave (Talking, Voice Playback and Recognition)

12 Robocon 2007, HKUST Physical Layer Describe the physical property of the communication channel. –Media Copper / Optical Fiber / Ultrasound / IR –Meaning of Voltage / Brightness –Modulation Base band / FM / AM / UHF / TDMA / OFDM –Serial or Parallel –Connectors

13 Robocon 2007, HKUST Physical Layer Human voiced communication –Media Air –Meaning of Voltage / Brightness Loudness –Modulation Longitudinal sound wave –Serial or Parallel Serial –“Connector” Ear and mouth

14 Robocon 2007, HKUST Physical Layer Serial Port / RS-232 –Media Copper Wire –Meaning of Voltage / Brightness -5V to -12V for 1 (Space), +5V to +12V for 0 (Mark) –Modulation Base band –Serial or Parallel Serial –“Connector” Commonly seen as DB 9 Male / Female

15 Robocon 2007, HKUST Data link Layer How the data link is established, understood and maintain –Master (Transmitter) / Slave (Receiver) relationship Or multi-hops? –Bus sharing / arbitration Shared? Who has higher priority? CSMA/CD, CSMA/CA –Clock rate / Order –Acknowledgement / Error detection / Error correction

16 Robocon 2007, HKUST Data link Layer Human voiced communication –Master (Transmitter) / Slave (Receiver) relationship Single master, many slaves –Bus sharing / arbitration Generally speaking, only one person talking each time. Also, the one who speaks louder win. Also handled by upper layer (in-band or out- of-band) –Clock rate / Order “Reasonable” speaking speed, could be adjusted by urgency, required attention Order? That really depends. –Acknowledgement / Error detection / Error correction Not defined in this layer

17 Robocon 2007, HKUST Data link Layer RS232 / UART –Master (Transmitter) / Slave (Receiver) relationship Single master, many slaves –Bus sharing / arbitration For each data link, the master will always be master. No sharing and arbitration is needed. –Clock rate / Order Agreed Baud rate. Commonly seen from 9600 to 115200 Transmit LSB first, then MSB –Acknowledgement / Error detection / Error correction Start / Stop bit for time frame checking. Optional parity bit for error detection. Others are not defined in this layer.

18 Robocon 2007, HKUST Application Layer Implement what you want! It’s application dependent. It may implement some functions not implemented by lower layer.

19 Robocon 2007, HKUST Application Layer Human voiced communication –Protocol is application dependent Boss ordering employees Conference with project partners Chitchat with friends –Acknowledgement, Error checking, Error Correction In-band - “Would you repeat that please?”, “Did you mean XXX?” Out-of-band - Waving the head, body gestures Undefined - As in teaching. I never know if you can receive what I am talking about or not.

20 Robocon 2007, HKUST Application Layer RS232 / UART –Protocol is application dependent Binary? Text? –Acknowledgement, Error checking, Error Correction In-band - Dedicate special characters as control character. e.g. ASCII, XON/XOFF. Out-of-band - Use GPIO lines as control line Undefined - Simple ignore it! e.g. Data transmission occurs in continuous fashion frequently anyway, like temperature monitoring. (Or think video streaming from the Internet / webcam)

21 Robocon 2007, HKUST Implementation – Physical Layer If the definition is to use the basic 0-5V, GPIO capable, then you probably don’t need extra hardware. –Exception: when you want to have electrical separation with a noisy hostile circuit Otherwise you need transceiver –Like phone-receiver for voiced communication –Laser and Diode for optical fiber

22 Robocon 2007, HKUST Implementation – Data Link Layer Either use specialized hardware interfacing module –Provided by microcontroller –Or an external hardware, usually an IC with transceiver embedded. Think of USB controller chip Or software defined (code it in application) –In fact everything not fall onto physical layer can be implemented by application code, given your CPU processing power is fast enough. If you go extreme, see GNU Radio project, which demodulate (No tuner, just Fourier transform!) the HDTV signal with CPU. –Using software defined communication technique on serial communication is called Bit-Banging

23 Robocon 2007, HKUST Implementation – Application Layer Show me your code!

24 Robocon 2007, HKUST RS232 / UART in-depth Physical Layer - Transceiver –MAX232 by Maxim IC (Unrelated to Maxim's Catering) Data link –Handled by the UART module on ATMega128 Application –By using the registers and optionally interrupt

25 Robocon 2007, HKUST RS232 / UART in-depth Cable and Connector – Use your USB-to- COM cable Voltage conversion is taken care by MAX232 UART voltage is 5V (1, Space, Idle) and 0V (0, Mark, Engaged) RS232 voltage is ~-8V (1, Space, Idle) and ~+8V (0, Mark, Engaged)

26 Robocon 2007, HKUST RS232 / UART in-depth Required setting –Baud rate –Data size And read the specification for more!

27 Robocon 2007, HKUST RS232 / UART in-depth Task 1 –Send some character to your computer Task 2 –Store a line echo back to the computer


Download ppt "Robocon 2007, Hong Kong University of Science & Technology Robocon 2007 Electronics Quickstart! Session 4 Communication Prepared by KI Chi Keung [chikeung."

Similar presentations


Ads by Google