Presentation is loading. Please wait.

Presentation is loading. Please wait.

Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data.

Similar presentations


Presentation on theme: "Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data."— Presentation transcript:

1

2 Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data

3 Guarantees in Communications The communication link exists. The communication link is safe and sound. The sender and receiver are the correct nodes. The sender is sending the correct data. The receiver is able to correctly interpret the incoming data.

4 Protocols in Communication In order to have robust communication, the guarantees needs to be realized. To do so, we need an elaborate and standardized mechanism. These standard rules that defines the parameters of communications and ensures these guarantees are called protocol.

5 Advantages of Protocols Standardized, so interoperability is ensured. Usually include error-detection and error-correction mechanisms. Available as implemented chips that can be directly used.

6 Types of Communication Protocols There are different ways of categorizing protocols First Categorization: Second Categorization: Serial Mode Transfer Parallel Mode Transfer Synchronous Mode Transfer Asynchronous Mode Transfer

7 Serial and Parallel Mode SENDER RECEIVER SERIAL MODE PARALLEL MODE

8 Serial vs Parallel Mode Parameter Reliability Speed Power Cost Complexity Range Serial Mode Parallel Mode ReliableUnreliable SlowFast LowHigh HighLow LongShort

9 Need of Synchronization SENDER 1 0 1 0 1 0 1 T RECEIVER T/2 1 1 0 1 0 1 0 1 Suppose Sender sends data with a Time Period of T What if Receiver doesn’t know the speed and assume it to be say T/2 The Data received will be

10 Synchronous Mode Sender sends a clock signal along with data at every rising / falling edge of the clock, the data value is read by the receiver. SENDER SENDER CLOCK RECEIVER 0 1 0 1 0 101

11 Asynchronous Mode There is no clock signal. The receiver and the sender communicate at a predetermined speed (bauds or bits per second). Baud Rate: Baud Rate is a measurement of transmission speed in asynchronous communication. The devices that allows communication must all agree on a single speed of information - 'bits per second'.

12 Synchronous vs Asynchronous Mode Parameter Reliability Cost Complexity Synchronous Asynchronous Reliable Error Prone Expensive Inexpensive Complicated Simple

13 Transmission Modes SENDERRECEIVER Simplex Only one way transmission takes place

14 Transmission Modes SENDERRECEIVER Half-Duplex Two way transmission takes place but only one end can communicate at a time

15 Transmission Modes SENDERRECEIVER Full-Duplex Two way transmission takes place and both end can communicate simultaneously

16 UART Universal Asynchronous Receiver Transmitter

17 Asynchronous Serial Communication With asynchronous communication, the transmitter and receiver do not share a common clock Transmitter Receiver + 1 byte-wide Data Data – 1 byte-wide Data The Receiver  Extracts the data using its own clock  Converts the serial data back to the parallel form after stripping off the start, stop and parity bits The Transmitter  Shifts the parallel data onto the serial line using its own clock  Also adds the start, stop and parity check bits Add: Start, Stop, Parity Bits Remove: Start, Stop, Parity Bits

18 Asynchronous Serial Communication Start bit—indicates the beginning of the data word Stop bit—indicates the end of the data word Parity bit—added for error detection (optional) Data bits—the actual data to be transmitted Baud rate—the bit rate of the serial port Throughput—actual data transmitted per sec (total bits transmitted— overhead) Example: 115200 baud = 115200 bits/sec If using 8-bit data, 1 start, 1 stop, and no parity bits, the effective throughput is: 115200 * 8 / 10 = 92160 bits/sec

19 Asynchronous Serial Communication Asynchronous transmission is easy to implement but less efficient as it requires an extra 2-3 control bits for every 8 data bits This method is usually used for low volume transmission

20 Synchronous Serial Communication In the synchronous mode, the transmitter and receiver share a common clock The transmitter typically provides the clock as a separate signal in addition to the serial data Transmitter Receiver Data Clock The Receiver  Extracts the data using the clock provided by the transmitter  Converts the serial data back to the parallel form The Transmitter  Shifts the data onto the serial line using its own clock  Provides the clock as a separate signal  No start, stop, or parity bits added to data 1 byte-wide Data

21 UART in Atmega328P

22 Arduino Serial Library int incomingByte = 0; // for incoming serial data void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() { // send data only when you receive data: if (Serial.available() > 0) { // read the incoming byte: incomingByte = Serial.read(); // say what you got: Serial.print("I received: "); Serial.println(incomingByte, DEC); } }

23 SPI Serial Peripheral Interface

24 SPI SPI is an interface bus commonly used to send data between microcontrollers and small peripherals such as shift registers, sensors and SD cards. It uses separate clock and data lines, along with a select line to choose the device you wish to talk to. SPI was originally developed by Motorola (now Freescale) It works on serial mode of transfer. It is also synchronous and full duplex. It has the capability of communicate with many nodes.

25 SPI In SPI, the sender and receiver follows a master-slave relationship. There may be multiple nodes in the network. One node is master, the rest are slaves. The communication is always initiated by the master. The slaves can communicate only with the master. How do master selects the slave??

26 SPI Pins SCK is generated by Master and is used as the mode is synchronous. MOSI is Master Out Slave In: Data sent by Master to Slave. MISO is Master In Slave Out: Data sent by Slave to Master. S ̅ S ̅ is Slave Select: Slave communicates with Master only if this pin’s value is set as LOW. (Active Low)

27 SPI Schematics: Single Slave The SPI bus uses two data lines, a clock line, and a slave select line. An additional slave select line is added for each slave device, but the other three lines are shared on the bus.

28 SPI Schematics: Multiple Slaves

29 A - No data (SS is high, SCK is low) B - SS taken low to enable the slave (peripheral). At this point the slave should prepare to transfer data by setting the MOSI and the SCK lines as inputs, and the MISO line as an output. The slave can now prepare to notice clock pulses on the SCK line. C - First character arrives (the letter "F" or 0x46 or 0b01000110). For each of the 8 bits the SCK line is briefly brought high, and then low again. This tells the slave to read the data on the MOSI line. Also the slave can place data on the MISO line for the master to simultaneously read in. D - The letter "a" arrives E - The letter "b" arrives F - "No data" after "Fab" - however the SS is still enabled. G - SS taken high to indicate end of the sequence of data.

30 Notice how for each bit (starting with the most significant bit), the MOSI line is first changed to the correct state (0 or 1) and then the SCK line is pulsed to indicate that the data should be read. Sending the Character 'F' (0x46 or 0b01000110) (MSB First)

31 SPI in Atmega328P

32 Arduino SPI Library ( ) The Arduino development kit comes with an SPI library. To use it you just need to include it: #include To control the hardware you call SPI.begin() which configures the SPI pins (SCK, MOSI, SS) as outputs and MISO as input. It also sets SCK and MOSI low, and SS high. The function SPI.transfer() does the actual transferring of bytes. It is up to you to set SS low at an appropriate time. When finished call SPI.end() to turn the SPI hardware off.

33 I2C Inter-Integrated Circuit I-Squared-C

34 I2C (pronounced I-squared-C) created by Philips Semiconductors (now NXP) and commonly written as "I2C" stands for Inter- Integrated Circuit and allows communication of data between I2C devices over two wires. It sends information serially using one line for data (SDA – Serial DAta) and one for clock (SCL – Serial CLock). I2C Basics

35 The I2C protocol defines the concept of master and slave devices. A master device is the device that is in charge of the bus. This device controls the clock and generates the START and STOP signals. Slave devices listen to the commands sent by the Master and respond to them. Basic details: Transfer rate: 10 Kb/s (low speed) - 100Kb/s (high speed) SDA - Serial DAta line SCL - Serial CLock line 128 possible addresses (7 bits) 16 reserved addresses 112 devices max Devices have to share both 5V (Power) and GND (Ground) I2C Basics

36 Theory of Operation Regardless of how many slave units are attached to the I2C bus, there are only two signals connected to all of them. Consequently, there is an additional overhead because:  an addressing mechanism is required for the master device to communicate with a specific slave device.  an acknowledgement mechanism is required for such a communication.

37 Theory of Operation I2C has a master/slave protocol. The master initiates the communication. The sequence of events are: 1. The Master device issues a start condition. This condition informs all the slave devices to listen on the serial data line for instructions. (SDA goes from HIGH to LOW when SCL is HIGH) 2. The Master device sends the address of the target slave device and a read/write flag. (Flag is 1 for read and 0 for write) 3. The Slave device with the matching address responds with an acknowledgement signal. 4. Communication proceeds between the Master and the Slave on the data bus. Both the master and slave can receive or transmit data depending on whether the communication is a read or write. The transmitter sends 8-bits of data to the receiver which replies with a 1-bit acknowledgement. 5. When the communication is complete, the master issues a stop condition indicating that everything is done. (SDA goes from LOW to HIGH when SCL is HIGH)

38 Theory of Operation

39 TWI (Two Wire Interface) TWI stands for Two Wire Interface and it is identical to I²C. The name TWI was introduced by Atmel and other companies to avoid conflicts with trademark issues with Philips related to I²C.

40 TWI in Atmega328P I2C Requires Analog Pins 4 (SDA) and 5 (SCL) and two pull-up resistors. You can connect more than 100 Arduino's on the same 2 pins. It's simple, reliable and easy-to-use.

41 Arduino TWI Library ( )


Download ppt "Essentials of Communication This simple model requires many guarantees. Sender Receiver Communication Link Data."

Similar presentations


Ads by Google