Digital Electronic Systems (1) Lectures 5, 6, 7 PDF
Document Details
Uploaded by BestKnownGraffiti8805
Higher Institute of Engineering, El Shorouk
Dr. Mostafa Elhussien
Tags
Summary
This document contains lecture notes from a course on digital electronic systems, focusing specifically on serial communication interfaces. The material includes details on various types of serial interfaces (including RS-232, RS-422, RS-485, SPI, I2C, CAN, LIN, FlexRay, and USB) and their characteristics and applications. It can be a useful resource for understanding and studying serial communication.
Full Transcript
Higher Institute of Engineering, El Shorouk Biomedical and Systems Engineering Department BIS 471 and BIS 461 Digital Electronic Systems (1) Lecture 5 Dr. Mostafa Elhussien Dr. Mostafa Elhussien Digital Electronic Sy...
Higher Institute of Engineering, El Shorouk Biomedical and Systems Engineering Department BIS 471 and BIS 461 Digital Electronic Systems (1) Lecture 5 Dr. Mostafa Elhussien Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 1 Serial Digital Interfaces Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 2 Content An overview of serial data transfer methods. Data rate vs. bandwidth and related topics. Summary of the most common serial interfaces and technology: RS-232/422/485, SPI, SCI, I2C, I2S, CAN, LIN, Flexray, and USB. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 3 Introduction There are standard ways for getting data into and out of digital circuits and equipment and computers. Most of these input/output (I/O) methods involve serial data transfers. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 4 Prerequisites DC and AC electrical fundamentals. Basic digital logic circuit operation. Binary codes and coding. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 5 Data transfer principles Parallel and Serial Data Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 6 The need for data movement One of the most common operations in a computer or digital system is sending data from one place to another. From chip to chip on a printed circuit board (PCB) From one PCB to another in a system From one piece of equipment to another (PC to printer) From one computer to another distant computer over a network Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 7 Data transmission is a Communications System Figure shows a generic example of a simple data transmission system. The source of data may be a computer, embedded controller, or other digital source. The data is usually organized as in bytes or larger words of 16, 32 or 64 bits. The receiver of the data may be a computer, embedded controller or some other digital circuit. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 8 The Communications Medium The communications path for the data may be any one of many different connections. Examples: Copper traces on a PC board. Ribbon cable. Cable such as coax or twisted pair. Fiber optic cable. Radio or wireless. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 9 Parallel and Serial Data Transfers There are two ways to transfer digital data between two points: parallel and serial. Parallel data transfers cause all bits of a binary word or number to be transmitted simultaneously over multiple parallel connections, one wire or connection per bit. Serial data transfers transmit a binary word or number one bit at a time over a single data connection. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 10 Parallel Transmission Parallel transmission is used primarily when very high speed is needed. All bits move together at the same time. The transmission path or medium is usually referred to as a bus made up of one wire or conductor for each binary bit. referenced to ground. Very high speed buses use differential transmission requiring two wires per bit. Differential transmission is preferred for very high speeds and longer conductors where noise pickup is a problem. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 11 Single-Ended vs. Differential Transfers A single-ended transfer is made when the bit voltage appears on a single wire referenced to ground. See Fig A. Tx is the transmitting circuit or driver, Rx is the receiving circuit or receiver. Some transfers use a single ground connection for all parallel lines. Others use a separate ground wire for each bit line. See Fig B. In differential transfers, two lines are used. No ground reference is used. Fig C. Differential transfers are more immune to noise than single- ended transfers over longer distances. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 12 Parallel Transfer Advantages Parallel data transfers are extremely fast since all bits are transmitted simultaneously. Transfer rates of hundreds of MHz are possible. A presentation of eSyst.org Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 13 Parallel Limitations Parallel transmissions are subject to high levels of signal distortion from the path capacitance and inductance if the distance of transmission is great. Transmission distances are limited to several inches if data rates exceed several hundred megahertz (MHz). For this reason, fast parallel transfers are usually limited to bus connections on a PC board, very short cables, or register transfers inside an IC. Parallel connections require more wires in a cable or more pins on an IC, take up more space on a PCB or require a larger connector. Parallel connections are more expensive than serial connections because of the multiple paths (copper lines, wires, etc.) and the multiple digital circuits needed to transmit and receive the data. (One transmitter and one receiver per bit.) Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 14 Parallel Applications Parallel buses are widely used in computers (PCI bus) for connecting chips together like microprocessor to memory or I/O chips on a PCB. Chips on a PC motherboard are an example. Parallel buses in the form of short ribbon cables are used to connect disk drives to mother boards in a PC. In the past, longer parallel cables were the most common way to connect a PC to a printer. At low data transfer rates longer cables (many feet) can be used. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 15 Serial is the answer. In serial data transfers, a binary word is transmitted one bit at a time over a single connection. Either the LSB or MSB can occur first. In Figure LSB is first. Each bit is sent during a fixed time interval (t) one bit after the other. Serial transfers are simpler and less expensive. Only one transmitter and one receiver is needed. Only 2 wires are needed in a cable (the bit line and ground). Differential transmission can also be used in which case 2 wires are needed. The only practical way to transmit data over a fiber optical cable or a wireless link is by the serial method. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 16 Serial Data Rate Serial transmissions are slower because the bits are transmitted one at a time. Yet very high speed connections eliminate this apparent disadvantage. The date rate is expressed in bits per second (bps). The data rate in bps is determined from the bit time interval as shown in Figure. Bit rate in bps is 1/t where t is the bit time. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 17 Serial data calculations If a serial data stream has a bit time of 100 nanoseconds (ns), the data rate is: bps = 1/100 x 10-9 = 10,000,000 bps or 10 Mbps The bit time can be calculated from the data rate or t = 1/bps. If the data rate is 19200 bps, the bit time is 1/19200 = 52 microseconds. It takes 52 x 8 = 416 µs to transmit one byte of data at a 19.2 kbps rate. Practical serial data rates up to 10 Gbps are common in electronic and computer equipment. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 18 Serial dominates Most digital data transfers are by serial methods today. There are literally dozens of different serial methods in use each with its own data protocol, electrical characteristics, and mechanical connections. The serial method is usually selected by its application and the required data speed. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 19 Common Serial Interfaces The following serial data interfaces are covered: RS-232, RS-422/423, RS-485 Universal serial bus (USB) Serial peripheral interface (SPI) Serial communications interface (SCI) I2C bus CAN bus LIN bus Flexray Most of these interfaces are built into microcomputers, embedded controllers, memory or other chips. However, some interfaces are offered separately as integrated circuits. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 20 RS-232, RS-422/423, RS-485 One of the oldest but still widely used serial interface families. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 21 The Oldest Serial Data Interface The oldest serial data interface is the original telegraph invented in the 1840s. A telegraph key used as a switch to connect or disconnect a battery at the transmitting end to a magnetic “clicker” or sounder at the receiving end over a very long wire. The bits are the key on and off connections. The duration of the on times were varied to create dots and dashes of the Morse code. Modern serial interfaces are essentially the same today. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 22 RS-232 The designation RS-232 is the expression used to describe one of the oldest serial interfaces still in use today. It was originally used in telegraph machines that transmitted binary codes and as the interfaces on computer modems. It is still widely used to connect peripheral devices to computers. RS-232 is one of a number of similar interfaces that have been standardized by the Electronics Industries Association (EIA), the Telecommunications Industries Association (TIA) and the International Telecommunications Union (ITU). Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 23 What the RS-232 standard defines. Voltage levels for binary 0 and binary 1. Data rate and slew rate. Transmission medium specifications. Connectors, The standard does not define: Data encoding and format. Protocol or data framing. Error detection. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 24 Logic Levels The RS-232 standard defines a binary 1 or “mark” as any voltage between -3 and -25 volts. A binary 0 or “space” is any voltage between +3 and + 25 volts. The signals are single-ended. Commonly used levels are ± 5 and ±12 V. Receivers do not respond to voltages between ± 3 V making this standard essentially immune to noise in this range. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 25 Data Rate and Range No specific data rate is specified but the standard states a maximum of 20 kbps up to a range of 50 feet (15 meters). The data rate is limited by cable capacitance that increases with length. The maximum capacitance is defined as 2500 pF. This sets the maximum slew rate (rise/fall times) at 30 V/µs. Lower cable capacitances or shorter cables allow faster rates beyond 100 kbps. Common data rates used with RS-232 are: 300, 1200, 2400, 4800, 9600, 19200 and 115,200 bps. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 26 Data Format While no data format is specified in the standard, the most widely used approach is shown in Figure. The data (numbers, letters, punctuation marks, special symbols) are defined by the widely used ASCII code. 8-bit data words (bytes) are transmitted. A start bit (high to low transition) signals the beginning of a character. LSB or data word is sent first. A parity bit may or may not be used to aid in bit error detection. It could be 0 or 1 if used. One or two stop bits signal the end of a byte. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 27 Data Format This method of data transmission is called asynchronous since it does not use a master clock signal for timing. The circuits used to transmit and receive the data are usually contained in a single IC that is commonly referred to as universal asynchronous receiver transmitter or UART. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 28 RS-232 Connectors The original standard defined a 24-pin D-shaped connector. It is no longer widely used. The most common connector is a 9-pin connector with the designation DB9S with the signals as given in Figure. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 29 RS-232 Signals Pin Signal Description I/O 1 DCD Data carrier detect Input 2 RXD Received data Input 3 TXD Transmitted data Output 4 DTR Data terminal ready Output 5 Gnd Ground Ground 6 DSR Data set ready Input 7 RTS Request to send Output 8 CTS Clear to send Input 9 RI Ring indicator Input Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 30 Signal Operations Data is transmitted on TXD pin 3. Data is received on RXD pin 2. The other lines are control or “handshaking” signals that control the flow of data. They are no longer widely used. The most common connections are shown in Figure. DTR is connected to DSR and RTS is connected to CTS. Transmission is totally controlled by the start and stop bits. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 31 RS-423 Standard Later EIA/TIA standards were revision to RS-232. These are RS-423 and RS-422. RS-423 is similar to RS-232 in that it is single- ended but uses lower logic voltage levels and was designed to extend the possible cable length and data speed. Maximum cable length is about 4000 feet at low (1 kbps) data rates. Speeds over 120 kbps are possible over shorter cables. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 32 RS-422 Standard The RS-422 standard is similar to RS-423 but uses a balanced transmission line. This means two wires referenced to ground. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 33 RS-422 Standard Logic levels are the same as RS-423. Cable lengths are similar to RS-423. Twisted pair cable like telephone cable or Ethernet LAN cable is common. RS-422 is also designed for multi-drop operation meaning that one transmitter can drive multiple receivers. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 34 RS-485 Standard The RS-485 standard is similar to RS-422 in that it uses differential signaling to minimize noise. Logic levels are - 0.2 to – 2 V (binary 1) and +0.2 to +2 V (binary 0). It can achieve a data rate up to 100 kbps at 4000 feet or 10 Mbps at 40 feet. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 35 RS-485 Standard The standard specifies that multiple transmitters (drivers) and receivers can be used on the single cable. A combined transmitter (driver) and receiver is called a transceiver. Only one transmitter can send at a time. RS-485 is widely used in industrial control/monitoring networks. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 5 36 Higher Institute of Engineering, El Shorouk Biomedical and Systems Engineering Department BIS 471 and BIS 461 Digital Electronic Systems (1) Lecture 6 Dr. Mostafa Elhussien Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 1 Serial Digital Interfaces Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 2 Content An overview of serial data transfer methods. Data rate vs. bandwidth and related topics. Summary of the most common serial interfaces and technology: RS-232/422/485, SPI, SCI, I2C, I2S, CAN, LIN, Flexray, and USB. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 3 Serial communications Interface (SCI) The SCI bus is similar to the RS-232 interface in that it uses asynchronous data transmission with start and stop bits. Data is transmitted in bytes and a parity bit is optional. Logic levels are usually TTL/CMOS compatible with a 5 volt or a 3.3 volt supply. Standard baud rates are 2400, 4800, 9600, 14,400, 19,200 and 38,400 bps are used. The SCI usually resides inside an embedded controller or peripheral IC like an EEPROM. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 4 Baud Rate Baud rate means data rate of serial data. Baud refers to the number of symbol changes per serial bit interval. A symbol is a voltage level or other characteristic of the signal like frequency or phase. In most serial data specifications, the baud rate is the same as the bits per second (bps) rate. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 5 SCI Architecture Figure shows the SCI circuitry. Data to be transmitted from a microprocessor unit (MPU) is placed in the data register by an MPU instruction. The byte in the data register is transferred to a buffer register where the start (ST), stop (SP) and parity (P) bits are added making an 11-bit word. The 11-bit word is transferred to a shift register and a clock signal at the desired baud rate clocks the data out over the TX line. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 6 SCI Architecture To receive data, the serial input from an external source on the RX line is shifted into the receive register then transferred to the data register. A read instruction from the MPU captures the data and stores it. Note that with individual TX and RX lines transmit and receive operations can occur simultaneously permitting full duplex operation. The control lines used in the RS-232 interface are not used in SCI. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 7 I2C Bus I2C stands for Inter-Integrated Circuit. It is a serial bus developed by Philips (now NXP) for use in transferring data between ICs especially microcontrollers. It is widely used with EEPROM/flash memory, ADC and DAC, timers, sensors, displays and other ICs. The I2C bus connects a master and two or more slave devices. Master and slave devices can both transmit and receive data, but the master controls the transfer. The transmission medium is usually copper paths on a PC board but can be a short twisted pair cable. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 8 I2C bus hardware The I2C bus has three lines: (See Figure) Serial clock (SCL) Serial data (SDA) Ground Figure 15 Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 9 I2C bus hardware The signal lines are of the open drain (or open collector in older systems) type with a pull up resistor to the supply voltage (+5 or +3.3 V). All master/slave outputs are high until a transmission is initiated by the master. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 10 I2C bus specifications The data speed is not specified but can be as low as 10 kbps or up to 100 kbps in standard systems. Higher speed versions of 400 kbps, 1 Mbps and 3.4 Mbps can be used if needed. The number of devices connected to the bus is usually only a few but can be as high as 20 or 30 as long as the total bus capacitance does not exceed 400 pF. Lower values of pull up resistors will be needed as more devices are added or as higher speeds are used. Total bus length rarely exceeds several feet. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 11 I2C bus protocol The transmission of data uses the protocol format in Figure. A start bit (SDA low, SCL high) signals the beginning of a transmission from a master. A 7-bit or 10-bit address is then sent identifying the device to be involved in the data transfer. A read/write (R/W) indicates the direction of the data (0 = master to slave, 1 = slave to master) Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 12 I2C bus protocol If the addressed slave is present, it sends a binary 0 acknowledge (ACK) bit on the bus. Data is transmitted a byte at a time with an ACK bit after each. The transmission ends with a STOP bit. The SDA line goes high while SCL is high. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 13 I2C bus variations There are two modified versions of the I2C bus: System management bus (SMB) Power management bus (PMB) The SMB is a more limited sub-set of I2C bus with speeds from 10 kbps to 100 kbps. It involves fewer nodes. The PMB is a more complex version that is designed for power management and control in power supplies. (Monitoring voltages, setting voltages, temperature, watching for overload, etc.) Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 14 I2C Example Figure show I2c connection between MPU9250 IMU sensor with arduino Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 15 I2C Example Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 16 I2S Bus A serial bus for digital audio signals. I2S means Inter-IC Sound bus. The I2S bus was developed by Philips Semiconductor (now NXP). Its primary use is the transmission of serial audio data between chips or between PC boards or other sub-assemblies. The I2S bus is used on many embedded microcontrollers or any digital audio device such as ADCs, DACs, or audio CODECs. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 17 I2S Features The I2S bus has three wires and a ground. Serial Data (SD) Serial Clock (SCK) Word Select (WS) Serial data is transmitted as sequential binary data words representing music or other audio data. Binary words may be 16/18/20/22 bits. Left and right stereo channel words are transmitted alternately. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 18 I2S Features (continued) The clock speed is one of the more common audio data rates such as 32, 44.1 or 48 kbps. Higher data rates can be used. 2.5 MHz is common in some systems and 3.125 MHz is maximum. The word select (WS) line indicates whether the left or right stereo word is being transmitted. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 19 I2S Example Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 20 Introduction to SPI An interface used in embedded systems. SPI is a high speed serial interface invented by Motorola (now Freescale) for use in providing a fast communications link between integrated circuits on a printed circuit board or between circuit boards. Because the interface uses serial transfers, it only uses a few extra pins on the IC or any PCB connector in contrast to the many connections required by a parallel interface. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 21 SPI Features SPI is a synchronous serial bus because all data transfers take place in synchronism with a master clock signal. Data transfers can be full duplex meaning that both send and receive operations may occur at the same time. Data transfer speeds are flexible but can be as high as 20 to 50 Mbps with some ICs. Many if not most microprocessors, embedded controllers and large scale ICs like FPGAs have an SPI bus built in so no additional circuitry is needed. Most large scale systems on a chip (SoC) incorporate the SPI bus. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 22 SPI Operation The basic SPI configuration is shown in Figure The two communicating devices are designated as the master and the slave. Multiple slaves can be used. The master controls all data transfers and generates the clock signal. The signals used in the interface are: Serial clock, from master (SCLK) Master output slave input (MOSI) Master input slave output (MISO) Slave select (SS) Data is transferred in 8-bit bytes. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 23 SPI Operation The byte to be sent appears in an 8- bit data register (DR) and then transferred to a shift register (SR). Data in the shift register is clocked out by the master clock signal (SCK). The same clock signal is also sent to the slave. The serial data is then shifted into another shift register in the slave then transferred to another data register where the data is used. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 24 SPI Operation Note that any data in the slave shift register is shifted out and sent into the master shift register. The master and slave shift registers form a complete rotating loop. In order for the data transfer to occur, the SS line must be low signaling the slave has been selected to receive the data. When multiple slaves are required, each will have its own SS line derived a decoder in the master circuitry. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 6 25 Higher Institute of Engineering, El Shorouk Biomedical and Systems Engineering Department BIS 471 and BIS 461 Digital Electronic Systems (1) Lecture 7 Dr. Mostafa Elhussien Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 1 Serial Digital Interfaces Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 2 Content An overview of serial data transfer methods. Data rate vs. bandwidth and related topics. Summary of the most common serial interfaces and technology: RS-232/422/485, SPI, SCI, I2C, I2S, CAN, LIN, Flexray, and USB. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 3 Introduction to CAN A secure and reliable bus for automotive and industrial applications. The controller-area network (CAN) is a data communications bus designed to provide highly reliable data transfers in hostile environments. The CAN bus was developed by Robert Bosch GmhB in 1983 and was initially used in Mercedes cars. The CAN bus is optimized for very high noise level environments of which the automobile is typical. Common uses include control of power seats, windows, ignition, emissions control, fuel management, ABS, diagnostic ports, etc. While the most common use is in vehicles, it is also used in industrial monitoring and control applications and in aerospace, marine, and medical equipment. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 4 CAN Bus Basics The transmission medium is unshielded twisted pair (UTP) or shielded twisted pair (STP). See Figure Maximum line length is 1 km and data speed depends on line length. (1 Mbps max. for 40 meters). Shorter distances are more common. Data transmission is differential with logic signals: Binary 1 = 2.75 to 4.5 V Binary 0 = 0.5 to 2.25 V Data rate is from 10 kbps to 1 Mbps with 20 kbps the main standard. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 5 CAN Bus Basics Each device on the bus can send or receive data. Transmission is asynchronous rather than clocked synchronous. A 9-pin D connector is defined as part of the standard. Most CAN bus interfaces are built into the microcontroller or other devices although separate external CAN bus ICs are available. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 6 CAN Bus Protocol The CAN protocol data frame format is illustrated in Figure. The total number of bits in each field is noted. The arbitration field contains an 11 address. The control field indicates the number of bytes to be transmitted. The data length may be from 0 to 8 bytes. A cyclic redundancy check (CRC) word is used for error detection and correction, a key factor in maintaining data reliability in noisy environments. A 2-bit acknowledge (ACK) word indicates status of received packet. A 7 bit end of frame indication terminates the transmission. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 7 CAN Bus Protocol Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 8 Local interconnect network (LIN) bus The LIN is a simpler, lower cost bus that can be used in place of the CAN bus. The CAN bus speed and complexity is over-kill for some applications. The LIN bus is used as an alternative to CAN in automotive applications for less critical functions like window controls, door locks, sensors, windshield wipers, and the climate control. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 9 LIN Bus Features The LIN bus is a single line (w/ground) bus. Data is transmitted as bytes along with start and stop bits (no parity) as used in the RS-232 interface. Only one data line is used. Data speeds are in the 1 kbps to 20 kbps range with standard baud rates from 1200 to 19,200 bps are the most common. Maximum cable length (twisted pair) is 40 meters. Logic levels are derived from the 12 volt auto battery/electrical system. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 10 LIN Protocol The LIN network defines one master controlling node and multiple slaves. The master always initiates the communications and the slave responds. Figure shows the LIN frame. There is the header transmitted by the master and the message response transmitted either by the master or the slave. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 11 LIN Protocol (continued) The protocol frame is made up of: 13-bit break field used to identify the start of a frame. 8-bit sync field made up of hex 55 or alternating 0s and 1s to help establish clock sync. Identifier field with 6-bit that define up to 64 slaves plus 2 parity bits for error detection. The data field can be anything from 1 to 8 bytes. An 8-bit checksum completes the frame. The checksum is simply the logical sum (XOR no carry) of all data bytes to provide an error detection capability. Like the CAN bus, most LIN circuitry is built into the processor or other peripheral chip. Separate interface Ics are also available. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 12 FlexRay Bus The FlexRay bus is used almost exclusively in automotive systems. It is used in place of CAN or LIN where very high speed response and high reliability are critical. Primary applications include drive-by-wire, steer-by-wire, brake-by-wire, stability control, adaptive cruise control, etc. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 13 Key Features of the FlexRay Bus FlexRay uses a single twisted pair cable either unshielded or shielded. (Z=90 to110Ω) Differential signaling is used with binary 1 = +2 V and binary 0 = -2 V. Data rate can be from 500 kbps up to 10 Mbps. Transmission is synchronous with a standard clock frequency. Two 10 Mbps lines may be used to implement redundancy for reliability or to double data rate to 20 Mbps. Topologies include multi-drop bus, star network, or a hybrid of the two. Maximum nodes: 22 Maximum line length is 24 meters. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 14 Time Division Mulitplexing Data to the multiple nodes is transmitted in a time division multiple access (TDMA) format. In TDMA, each data byte sent or received by a node occupies a specific time slot as illustrated in Figure. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 15 FlexRay Protocol The FlexRay protocol is very complex. The transmissions are by frames with a header, a payload and a trailer. The header contains identification information and other indicators. The payload can contain up to 254 bytes of time multiplexed data. The trailer is a 24-bit CRC for error detection and correction. FlexRay is integral to some MPUs but is also available as separate interface ICs. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 16 Universal Serial Bus (USB) The most popular serial interface is USB. It has replaced RS-232 and parallel interfaces as the most commonly used personal computer interface. Most PCs and laptops have multiple USB ports for connection to an enormous number of peripheral devices. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 17 USB Applications USB ports are commonly used for most PC peripheral devices including: Keyboards Mice Printers External drives USB ports are also used for many other devices that must connect to a PC including: Flash memory drives Digital cameras and camcorders Personal navigation devices Music players Cell phones Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 18 USB – Basic Features Serial data transfers are in packets. Transmission medium is a bus to which up to 127 devices may be connected to it. There are 3 versions of the USB standard with these maximum data speeds: USB 1.0 - 12 Mbps USB 2.0 - 480 Mbps USB 3.0 - 4.8 Gbps. The interface supplies DC power of 5 volts up to 500 mA. The interface is “hot-swappable” meaning you can plug things in or unplug them with power on and no damage or loss of data will occur. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 19 USB Operation All USB ports are controlled by a master host, usually a PC or laptop. All other devices are slaves and data transfers are controlled by the host. All operations are carried out in the form of packets. The packet types are: Handshake Token Data Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 20 USB Packets Handshake packets are exchanged between host and peripheral device to acknowledge data receipt or not, error and retransmission. Token packets carry the device address and indications of whether the transmission is an input or output to/from the host. Data packets may contain from 0 to 1023 bytes. All packets end in a 16-bit cyclical redundancy check (CRC) for error detection. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 21 USB Cables USB 1.0 and 2.0 use a four wire cable, a twisted pair for data and +5 volts and ground connections. The twisted pair has a characteristic impedance of 90 Ω. Logic levels are binary 0 0 =.0 to 0.3 volts and binary 1 = 2.8-3.6 volts for low speed mode and binary 0 -10 to +10 mV and binary 1 360 to 440 mV. Data transmission is by differential signaling. DC power current maximum is 500 mA, sufficient to power many peripheral devices. Maximum permitted cable length is 5 meters (16.2 feet). USB 3.0 uses two shielded twisted pair cables for full duplex operation. Maximum cable length is 3 meters. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 22 USB Connectors The most common USB connectors are the A and B types shown in Figure. The flat rectangular A connector is the most common and most PCs have four or more. This connector is defined for “downstream” (to the host) devices like keyboard or mouse. The B connector is square and designed for “upstream” (from the host) use such as on a printer. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 23 USB Connectors The USB 3.0 connector has extra connections for the two twisted pair and grounds as shown in Figure. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 24 Interfaces Everywhere Because serial I/O interfaces are the connections between any two electronic devices. Each interface here has detailed specifications and if you work with it often you should go to an Internet search for the appropriate standard and print it out for your reference. Besides common connection application, your other involvement with serial I/O interfaces will be in troubleshooting. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 26 Troubleshooting Serial Interfaces The most common problems with serial I/O interfaces is a mechanical failure. Broken or distorted cable. Broken or dirty connector. The quickest troubleshooting approach is to replace a suspected cable and connectors with another one as a substitute. Cables are generally low cost and replacing them is as simple as buying a new one. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 27 Dynamic Troubleshooting Troubleshooting the electronic chips or circuits of a serial interface requires an oscilloscope. With data transfers occurring, the signals are monitored with the scope at both transmitting and receiving ends of the link. Most digital oscilloscopes from Agilent, LeCroy and Tektronix offer special software to display the signals for specific interfaces. The scope digitizes the signals and uses software to display the signals and decode them (hex). Such scopes are also protocol analyzers so that they recognize protocol errors as well as display signal integrity. Dr. Mostafa Elhussien Digital Electronic Systems (1) Lec. 7 28