serial communication interfaces

27
Communication Hardware & Protocols Prof. Anish Goel Embedded Systems

Upload: anishgoel

Post on 16-Jul-2015

223 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: Serial Communication Interfaces

Communication Hardware & Protocols

Prof. Anish Goel

Embedded Systems

Page 2: Serial Communication Interfaces

Communications

Embedded Systems Prof. Anish Goel2

Page 3: Serial Communication Interfaces

Serial Communications

Embedded Systems Prof. Anish Goel3

Page 4: Serial Communication Interfaces

Asynchronous Serial (RS‐232)

Embedded Systems Prof. Anish Goel4

Page 5: Serial Communication Interfaces

RS232 Voltage levels

Embedded Systems Prof. Anish Goel5

Page 6: Serial Communication Interfaces

RS232 – Handshaking

Embedded Systems Prof. Anish Goel6

Page 7: Serial Communication Interfaces

Serial Peripheral Interface

Embedded Systems Prof. Anish Goel7

Page 8: Serial Communication Interfaces

SPI and the clock

Embedded Systems Prof. Anish Goel8

Page 9: Serial Communication Interfaces

SPI and the clock

Embedded Systems Prof. Anish Goel9

Page 10: Serial Communication Interfaces

I2C

Embedded Systems Prof. Anish Goel10

Page 11: Serial Communication Interfaces

I2C Write a Single Byte

Embedded Systems Prof. Anish Goel11

Page 12: Serial Communication Interfaces

Other Features

Embedded Systems Prof. Anish Goel12

Page 13: Serial Communication Interfaces

RS-485

Embedded Systems Prof. Anish Goel13

RS232 is an interface to connect one DTE, data terminal equipment to one DCE, datacommunication equipment at a maximum speed of 20 kbps with a maximum cablelength of 50 feet.This was sufficient in the old days where almost all computer equipment wereconnected using modems, but soon after people started to look for interfaces capableof one or more of the following:•Connect DTE's directly without the need of modems•Connect several DTE's in a network structure•Ability to communicate over longer distances•Ability to communicate at faster communication rates

RS485 is the most versatile communication standard in the standard series defined by the EIA, as it performs well on all four points. That is why RS485 is currently a widely used communication interface in data acquisition and control applications where multiple nodes communicate with each other.

Page 14: Serial Communication Interfaces

Differential signals with RS485:Longer distances and higher bit rates

Embedded Systems Prof. Anish Goel14

•Main problems with RS232 is the lack of immunity for noise on the signal lines.•The transmitter and receiver compare the voltages of the data- and handshake lineswith one common zero line.•Shifts in the ground level can have disastrous effects.•Therefore the trigger level of the RS232 interface is set relatively high at ±3Volt.•Noise is easily picked up and limits both the maximum distance and communicationspeed.•With RS485 on the contrary there is no such thing as a common zero as a signalreference.•Several volts difference in the ground level of the RS485 transmitter and receiverdoes not cause any problems.•The RS485 signals are floating and each signal is transmitted over a Sig+ line and a Sig-line.•The RS485 receiver compares the voltage difference between both lines, instead ofthe absolute voltage level on a signal line.•This works well and prevents the existence of ground loops, a common source ofcommunication problems.•The best results are achieved if the Sig+ and Sig- lines are twisted.

Page 15: Serial Communication Interfaces

Noise in straight and twisted pair cables

Embedded Systems Prof. Anish Goel15

•Noise is generated by magnetic fields from theenvironment.•The picture shows the magnetic field lines andthe noise current in the RS485 data lines that isthe result of that magnetic field.•In the straight cable, all noise current is flowing inthe same direction, practically generating a loopingcurrent just like in an ordinary transformer.•When the cable is twisted, we see that in someparts of the signal lines the direction of the noisecurrent is the opposite from the current in otherparts of the cable.•Because of this, the resulting noise current ismany factors lower than with an ordinary straightcable. Shielding—which is a common method toprevent noise in RS232 lines—tries to keep hostilemagnetic fields away from the signal lines.

Page 16: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel16

RS 485 Advantages•Twisted pairs in RS485 communication however adds immunity which is a muchbetter way to fight noise.•The magnetic fields are allowed to pass, but do no harm.•If high noise immunity is needed, often a combination of twisting and shielding isused as for example in STP, shielded twisted pair and FTP, foiled twisted pairnetworking cables.•Differential signals and twisting allows RS485 to communicate over much longercommunication distances than achievable with RS232. With RS485 communicationdistances of 1200 m are possible.•Differential signal lines also allow higher bit rates than possible with non-differentialconnections. Therefore RS485 can overcome the practical communication speed limitof RS232. Currently RS485 drivers are produced that can achieve a bit rate of35 mbps.

Page 17: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel17

Characteristics of RS232, RS422, RS423 and RS485

Page 18: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel18

CAN A Controller Area Network (CAN) bus is a high-integrity serial bus system for networking intelligent devices. CAN busses and devices are common components in automotive and industrial systems.

Automotive Applications

Page 19: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel19

Benefits of CAN• Lower cost from reduced wiring compared to two wire, point-to-pointwiring• Highly robust protocol– Built-in determinism– Fault tolerance– Reliable—More than a decade of use in the automotive industry

CAN Specifications• CAN data (up to 8 bytes in a frame)• Maximum 1 Mbaud/s• 40 Meters at 1 Mbaud/s• 6 km at 10 kbaud/s• Theoretical maximum of 2,032 nodes per bus– Practical limit is approximately 100 nodes due to transceiver– Most buses use 3–10 nodes• Data fields—Arbitration ID (11 bit or 29 bit)– Indicates message priority

Page 20: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel20

CAN Frame•CAN devices send data across the CAN Network on packets called frames.•A typical CAN frame contains an arbitration ID, a data field, a remote frame, an error frame, and an overload frame.

Page 21: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel21

CAN Arbitration

The arbitration ID determines the priority of the messages on the bus. Ifmultiple nodes try to transmit a message onto the CAN bus at the same time,the node with the highest priority (lowest arbitration ID) automatically getsbus access. Nodes with a lower priority must wait until the bus becomesavailable before trying to transmit again. The waiting devices wait until theend of the frame section is detected.

Page 22: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel22

Data Field•The data field contains the actual data being transmitted.•The CAN protocol supports two data field formats as defined in the Bosch Version2.0 specifications, the essential difference being in the length of the arbitration•ID.•In the standard frame format (also known as 2.0A), the length of the ID is 11 bits.•In the extended frame format (also known as 2.0B), the length of the ID is 29 bits.

Page 23: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel23

Introduction to USB

General IntroductionThe Universal Serial Bus (USB) is a specificationdeveloped by Compaq, Intel, Microsoft and NEC,joined later by Hewlett-Packard, Lucent and Philips.These companies formed the USB ImplementersForum, Inc as a non-profit corporation to publish thespecifications and organise further development inUSB.

The aim of the USB-IF was to find a solution to themixture of connection methods to the PC, in useat the time. We had serial ports, parallel ports,keyboard and mouse connections, joystick ports,midi ports and so on. And none of these satisfiedthe basic requirements of plug-and-play.Additionally many of these ports made use of alimited pool of PC resources, such as HardwareInterrupts, and DMA channels.

Page 24: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel24

Data Speeds

The USB specification defines three dataspeeds, shown to the right. These speeds arethe fundamental clocking rates of the system,and as such do not represent possiblethroughput, which will always be lower as theresult of the protocol overheads.

Low SpeedThis was intended for cheap, low data rate devices like mice. The low speedcaptive cable is thinner and more flexible than that required for full and highspeed.Full SpeedThis was originally specified for all other devices.High SpeedThe high speed additions to the specification were introduced in USB 2.0 as aresponse to the higher speed of Firewire.

Page 25: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel25

Architecture

The USB is based on a so-called 'tiered star topology' in which there is a single host controller and up to 127 'slave' devices. The host controller is connected to a hub, integrated within the PC, which allows a number of attachment points (often loosely referred to as ports). A further hub may be plugged into each of these attachment points, and so on. However there are limitations on this expansion.As stated above a maximum of 127 devices (including hubs) may be connected. This is because the address field in a packet is 7 bits long, and the address 0 cannot be used as it has special significance. (In most systems the bus would be running out of bandwidth, or other resources, long before the 127 devices was reached.)A device can be plugged into a hub, and that hub can be plugged into another hub and so on. However the maximum number of tiers permitted is six.The length of any cable is limited to 5 metres. This limitation is expressed in the specification in terms of cable delays etc, but 5 metres can be taken as the practical consequence of the specification.

Page 26: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel26

USBThis means that a device cannot be further than 30 metres from the PC, and even to achieve that will involve 5 external hubs, of which at least 2 will need to be self-powered.So the USB is intended as a bus for devices near to the PC. For applications requiring distance from the PC, another form of connection is needed, such as Ethernet.

Page 27: Serial Communication Interfaces

Embedded Systems Prof. Anish Goel27

Host is Master

•All communications on this bus are initiated by the host.•This means, for example, that there can be no communication directly between USB devices.•A device cannot initiate a transfer, but must wait to be asked to transfer data by the host. The only exception to this is when a device has been put into 'suspend' (a low power state) by the host then the device can signal a 'remote wakeup'.