techkriti lecture series communication by: ashutosh kumar

68
TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

Upload: mattie-wetherbee

Post on 30-Mar-2015

227 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

TECHKRITI LECTURE SERIES

CommunicationBY:

Ashutosh Kumar

Page 2: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

COMMUNICATION

Page 3: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SCOPE OF COMMUNICATION

Telephones and Cell Phones

Page 4: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SCOPE OF COMMUNICATION

Internet

Page 5: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

Wireless networks

SCOPE OF COMMUNICATION

Page 6: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SCOPE OF COMMUNICATION

Satellite Networks

Page 7: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

ESSENTIALS OF COMMUNICATION

But this simple model requires many guarantees.

Sender Receiver

Communication Link

Data

Page 8: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

GUARANTEES IN COMMUNICATIONS

The communication link exists. The communication link is 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.

Page 9: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

PROTOCOLS IN COMMUNICATION

The standard rules that defines the

parameters of communications and ensures these guarantees are called protocol.

Page 10: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

ADVANTAGES OF PROTOCOLS

Standardized, so interoperability is ensured. Usually include error-detection and error-

correction mechanisms. Are available as implemented chips that can

be directly used.

Page 11: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

TYPES OF PROTOCOLS

There are different ways of categorizing protocols

First Categorization :

Second Categorization :

Serial Mode Transfer

Parallel Mode Transfer

Synchronous Mode

Transfer

Asynchronous Mode Transfer

Page 12: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SERIAL AND PARALLEL MODE

SENDER

RECIEVER

SERIAL MODE

PARALLEL MODE

Page 13: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SERIAL VS PARALLEL MODE

Parameter

ReliabilitySpeedPowerCostComplexityRange

Serial Mode Parallel Mode

Reliable UnreliableSlow FastLow High

Low High High LowLong Short

Serialiser/Deserialiser

Page 14: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SYNCHRONOUS AND ASYNCHRONOUS MODE

Pertains to sender-receiver synchronization. Sender sends data at a certain speed. For

flexibility, protocols allow for multiple speeds.

Page 15: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

NEED OF SYNCHRONIZATION

SENDER1

0

1

0

1

0

1T

RECEIVER

T/2

1 1

0 0

1 1

0 0

1 1

0 0

1 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

Page 16: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

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

RECIEVER 0 1 0 1

0 1 0 1

Page 17: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

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'.

Page 18: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SYNCHRONOUS VS ASYNCHRONOUS MODE

Parameter

ReliabilityCostComplexity

Synchronous Asynchronous

Reliable Error ProneExpensive InexpensiveComplicated Simple

Page 19: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

TRANSMISSION MODES

SENDER RECIEVER

Simplex

Only one way transmission takes place

Page 20: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

TRANSMISSION MODES

SENDER RECIEVER

Half-Duplex

Two way transmission takes place but only one end can communicate at a

time

Page 21: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

TRANSMISSION MODES

SENDER RECIEVER

Full-Duplex

Two way transmission takes place and both end can communicate

simultaneously

Page 22: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

WIRED

Page 23: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

WIRELESS

Page 24: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SERIAL COMMUNICATION

Page 25: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

POPULAR SERIAL COMMUNICATION STANDARDS

RS-232 (using UART) Serial peripheral interface (SPI) System management bus (SMBus) Serial ATA (SATA) UART: Universal asynchronous receiver/transmitter

Page 26: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

ASYNCHRONOUS SERIAL COMMUNICATION TERMS

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

Page 27: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

ASYNCHRONOUS SERIAL COMMUNICATION

Serial communication implies sending data bit by bit over a single wire

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

Page 28: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

CONNECTIONS

Device1 RX TX GND

TX Device2RXGND

Page 29: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

ERROR DETECTION

•Parity bit is HIGH when number of 1’s in the Data is odd.

•Respectively, it is LOW when number of 1’s in the Data is even

Page 30: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar
Page 31: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

CODING

Two simple commands : putchar(char); sends 8-bit characters through UART getchar(); receives 8-bit characters via UART

Page 32: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

WHERE TO CODE

Page 33: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

TRANSMITTER CODE

Page 34: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

RECIEVER CODE

Page 35: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

ANY QUESTIONS THIS FAR?

Page 36: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

WHAT IS A X-BEE

XBee is the brand name from Digi International for a family of form factor

compatible radio modules.

Page 37: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

HOW DOES THE XBEE WORK / HOW TO CONTROL IT?

Every XBee works as a wireless serial connection (or -network) and can be used like a normal COM port.

You can easily hook up the XBee to a laptop or an arduino and you can send and receive data over long range. In fact, the only thing you need to do is connect power and connect one wire to the XBee for data receive or data send (or two if you want both).

Page 38: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

HOW TO CONFIGURE XBEE USING X-CTU?

XCTU is a small utility program written by Digi/Maxstream.

You can download this utility from the Digi website, www.Digi.com , under Supports/Drivers.

Download the latest drivers onto you PC.

Page 39: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar
Page 40: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

HOW TO PROGRAM A XBEE

Connect the Xbee to the usb wireless module or the breakout board or Xbee Explorer.

Connect the board to the PC/laptop. Open X-CTU. And select PC Settings Tab from the Tabs

Menu on the top of the page.

Page 41: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

QUERY

1. Select USB COMM. Port to the value of A-B Cable, display in the Device Manager setting.

2. Set the setting to the values of A-B Cable. 3. Click the Test/Query button 4. If the Com test / Query Modem dialogue appear with

an error message: Check if you have set the baud rate, flow control, data bits, parity and stops bits in the dialogue same as the Cable settings.

5. If everything goes well, you will see the dialogue displayed as in step 4 in the picture below. You should take note of the firmware version displayed in the dialogue. This is important for upgrading your firmware later. Then click OK.

Page 42: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar
Page 43: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

Now, let's move on to do the configuration on the XBee.

1. Select the Modem Configuration Tab on the Main Tab Menu. 2. Click Read button, if this is your first time running the XCTU software, you will see the Question dialogue appear, and it asks if you want to update the configuration files, which is recommended. 3. If you click Yes button, You will see the Get new versions dialogue pop up

Page 44: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar
Page 45: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

1. Then click the Web/file button. XCTU will start loading all the available firmware to your PC. 2. When XCTU is done with uploading, click the Done button. The Update Summary dialogue will pop up, displaying all the firmware for the XBee module. 3. Click OK.

Page 46: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

Baud Rate

1. With the Modem Configuration Tab Menu still selected, 2. click the Read button again. You will see all the current settings show up in the display area. 3. Scroll down to find Serial Interfacing folder. 4. Change the baudrate to 57600 bit/s. (This is the prefered value we are using .You can use any value you like.) 5. Click the Write button, (the one next to Read button), to save the setting.

Page 47: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar
Page 48: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

PAN ID

• To set the PAN ID or Personnal Area Network ID, which is the unique number to assign to XBee so XBee can talk to the right Xbee in the same Network Area.

• For example, if you are building a robot, and using only two XBees to communicate to each other, and you may want to avoid others that also using XBees for communication to be in the same Network Area.

• You can specify any number from 0000 to FFFF for your PANID. The factory PANID default value is 3332.

1. Still select the Modem Configuration Tab, 2. scroll up to the top of display area, 3. Click at the PAN ID to change the value. 4. Then click the Write button again to save the PAN ID setting to the XBee flash memory.

Page 49: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar
Page 50: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

Ready to use

• Now, you are set, the XBee modem is ready to use.

• If you have another XBee, you can repeat the steps to configure the modem.

• You are now ready to move to the next step for upgrading the firmware.

• In case, you want to update your XBee firmware without using the XCTU utility program, you can use the Terminal program to do that as well.

Page 51: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI – SERIAL PERIPHERAL INTERFACE

Page 52: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI

Serial ?? Because it works on serial mode of transfer.

It is also synchronous and full duplex. Peripheral Interface. Because it has the capability of communicate

with many nodes. How?? Let us see.

Page 53: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

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??

Page 54: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI SCHEMATICS: SINGLE SLAVE

Page 55: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI PINS

CLK 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.

SSSS is slave select: Slave communicates with Master only if this pin’s value is set as LOW.

Page 56: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI SCHEMATICS: SINGLE SLAVE

 Note one thing, if you use a single slave, you could save yourself a pin by hooking up the SS pin on the slave to GND and the SS on the master to VCC.

Page 57: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI SCHEMATICS: MULTIPLE SLAVES

Page 58: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

DATA TRANSFER IN SPI

M0

M1

M2

M3

M4

M5

M6

M7

S0

S1

S2

S3

S4

S5

S6

S7

MASTER SLAVE

MOSI MISO

Page 59: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

DATA TRANSFER IN SPI

M1

M2

M3

M4

M5

M6

M7

S0

S1

S2

S3

S4

S5

S6

S7

M0

MASTER SLAVE

MOSI MISO

Page 60: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

DATA TRANSFER IN SPI

M2

M3

M4

M5

M6

M7

S0

S1

S2

S3

S4

S5

S6

S7

M0

M1

MASTER SLAVE

MOSI MISO

Page 61: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

DATA TRANSFER IN SPI

S0

S1

S2

S3

S4

S5

S6

S7

M0

M1

M2

M3

M4

M5

M6

M7

MASTER SLAVE

MOSI MISO

Page 62: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI IN ATMEGA 8

Page 63: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SPI CODING

Page 64: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SIMPLE SPI CODE

char data = SPITransmit(‘a’);

In case of master, the data is written on the register and send to the slave.

In case of slave the data is written on the register and it waits for the master to transmit the data, when it also transmits its own data.

Page 65: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

MASTER CODE

DDRB = 0b10110000; // configure SPI Master Pins

ISR(INT0_vect){ // External Interrupt 0

data = SPITransmit(0x01); // when switch is pushed

// send data}

Page 66: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

SLAVE CODE

DDRB = 0b10000000; // configure SPI Slave Pins

ISR(SPI_STC_vect){ // SPI Transceiver Interrupt data = SPDR ; // read the data if(data == 0x01){ PORTA = ~PORTA; // if data is correct toggle

Led }}

Page 67: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

ANY QUESTIONS LEFT?

Page 68: TECHKRITI LECTURE SERIES Communication BY: Ashutosh Kumar

CONTACT DETAILS

Ashutosh [email protected]

261,hall-III9005907695