Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Serial Communication Interfaces


Published on

Serial communications used in Embedded Systems

Published in: Engineering
  • Be the first to comment

Serial Communication Interfaces

  1. 1. Communication Hardware & Protocols Prof. Anish Goel Embedded Systems
  2. 2. Communications Embedded Systems Prof.Anish Goel2
  3. 3. Serial Communications Embedded Systems Prof.Anish Goel3
  4. 4. Asynchronous Serial (RS‐232) Embedded Systems Prof.Anish Goel4
  5. 5. RS232 Voltage levels Embedded Systems Prof.Anish Goel5
  6. 6. RS232 – Handshaking Embedded Systems Prof.Anish Goel6
  7. 7. Serial Peripheral Interface Embedded Systems Prof.Anish Goel7
  8. 8. SPI and the clock Embedded Systems Prof.Anish Goel8
  9. 9. SPI and the clock Embedded Systems Prof.Anish Goel9
  10. 10. I2C Embedded Systems Prof.Anish Goel10
  11. 11. I2C Write a Single Byte Embedded Systems Prof.Anish Goel11
  12. 12. Other Features Embedded Systems Prof.Anish Goel12
  13. 13. RS-485 Embedded Systems Prof.Anish Goel13 RS232 is an interface to connect one DTE, data terminal equipment to one DCE, data communication equipment at a maximum speed of 20 kbps with a maximum cable length of 50 feet. This was sufficient in the old days where almost all computer equipment were connected using modems, but soon after people started to look for interfaces capable of 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.
  14. 14. 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 lines with 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 communication speed. •With RS485 on the contrary there is no such thing as a common zero as a signal reference. •Several volts difference in the ground level of the RS485 transmitter and receiver does 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 of the absolute voltage level on a signal line. •This works well and prevents the existence of ground loops, a common source of communication problems. •The best results are achieved if the Sig+ and Sig- lines are twisted.
  15. 15. Noise in straight and twisted pair cables Embedded Systems Prof.Anish Goel15 •Noise is generated by magnetic fields from the environment. •The picture shows the magnetic field lines and the noise current in the RS485 data lines that is the result of that magnetic field. •In the straight cable, all noise current is flowing in the same direction, practically generating a looping current just like in an ordinary transformer. •When the cable is twisted, we see that in some parts of the signal lines the direction of the noise current is the opposite from the current in other parts of the cable. •Because of this, the resulting noise current is many factors lower than with an ordinary straight cable. Shielding—which is a common method to prevent noise in RS232 lines—tries to keep hostile magnetic fields away from the signal lines.
  16. 16. Embedded Systems Prof.Anish Goel16 RS 485 Advantages •Twisted pairs in RS485 communication however adds immunity which is a much better 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 is used as for example in STP, shielded twisted pair and FTP, foiled twisted pair networking cables. •Differential signals and twisting allows RS485 to communicate over much longer communication distances than achievable with RS232. With RS485 communication distances of 1200 m are possible. •Differential signal lines also allow higher bit rates than possible with non-differential connections. Therefore RS485 can overcome the practical communication speed limit of RS232. Currently RS485 drivers are produced that can achieve a bit rate of 35 mbps.
  17. 17. Embedded Systems Prof.Anish Goel17 Characteristics of RS232, RS422, RS423 and RS485
  18. 18. 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
  19. 19. Embedded Systems Prof.Anish Goel19 Benefits of CAN • Lower cost from reduced wiring compared to two wire, point-to-point wiring • 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
  20. 20. 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.
  21. 21. Embedded Systems Prof.Anish Goel21 CAN Arbitration The arbitration ID determines the priority of the messages on the bus. If multiple nodes try to transmit a message onto the CAN bus at the same time, the node with the highest priority (lowest arbitration ID) automatically gets bus access. Nodes with a lower priority must wait until the bus becomes available before trying to transmit again.The waiting devices wait until the end of the frame section is detected.
  22. 22. 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 Version 2.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.
  23. 23. Embedded Systems Prof.Anish Goel23 Introduction to USB General Introduction The Universal Serial Bus (USB) is a specification developed by Compaq, Intel, Microsoft and NEC, joined later by Hewlett-Packard, Lucent and Philips. These companies formed the USB Implementers Forum, Inc as a non-profit corporation to publish the specifications and organise further development in USB. The aim of the USB-IF was to find a solution to the mixture of connection methods to the PC, in use at the time. We had serial ports, parallel ports, keyboard and mouse connections, joystick ports, midi ports and so on. And none of these satisfied the basic requirements of plug-and-play. Additionally many of these ports made use of a limited pool of PC resources, such as Hardware Interrupts,and DMA channels.
  24. 24. Embedded Systems Prof.Anish Goel24 Data Speeds The USB specification defines three data speeds, shown to the right. These speeds are the fundamental clocking rates of the system, and as such do not represent possible throughput, which will always be lower as the result of the protocol overheads. Low Speed This was intended for cheap, low data rate devices like mice. The low speed captive cable is thinner and more flexible than that required for full and high speed. Full Speed This was originally specified for all other devices. High Speed The high speed additions to the specification were introduced in USB 2.0 as a response to the higher speed of Firewire.
  25. 25. 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.
  26. 26. Embedded Systems Prof.Anish Goel26 USB This 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.
  27. 27. 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'.