Machine to Machine – ENSEIRB 2014-2015
Total Page:16
File Type:pdf, Size:1020Kb
Machine to Machine – ENSEIRB 2014-2015 Machine to Machine 1) Introduction This document describes communication buses between microcontroller units and other devices (extensions, sensors, actuators, display...). These buses use serial communication. Serial transmission of digital information (bits) through a single wire (or other medium) is less costly than parallel transmission through multiple wires (number of pins, chip size, PCB size, routing time...). State of the art technology also provides more flexibility on serial transmission for equivalent throughput. 2) Definitions a) Duplex A duplex communication is a point-to-point system composed of two connected parties or devices that can communicate with one another in both directions. Systems that do not need the duplex capability use instead simplex communication in which one device transmits and the others can only "listen" and can not be heard (one transmits/talks and the other can only receive/listen at a time). A half-duplex (HDX) system provides communication in both directions, but only one direction at a time (not simultaneously). Typically, once a party begins receiving a signal, it must wait for the transmitter to stop transmitting, before replying. In automatically run communications systems, such as two-way data-links, the time allocations for communications in a half-duplex system can be firmly controlled by the hardware. Thus, there is no waste of the channel for switching A full-duplex (FDX) system, or sometimes called double-duplex, allows communication in both directions, and, unlike half-duplex, allows this to happen simultaneously. b) Synchronous/Asynchronous Communications As we consider communications between clocked digital systems, all data exchanges are based on a clock (bits are sent on the wires at a periodic interval). Although clocking is involved in these communications, they may be referenced as synchronous or asynchronous communications. The distinction between synchronous and asynchronous communications is related to the presence of a clock signal in the communication itself. A comunication is called synchronous each time it is possible to distinguish two following bits only by observing the signals. For example, if one of the communication wires is dedicated to provide edges that will trigger a bit change, then the communication is synchronous. On the other end, if the commnication is only based on timing references and the receiver has to build its own time reference, then the Machine to Machine – ENSEIRB 2014-2015 comunication is asynchronous (it is not possible to make the difference between one bit at a low rate and several identical bits at a higher rate). Some complex communication interfaces do not use specific clock wires but modulate clock and data on the same channel. These interfaces are synchronous since demodulation is possible to rebuild the original clock. c) Transfer Rates All communication means are associated with units to precise their transmission capabilities. Most of these units are roughly equivalent but it is safer to clearly precise the meaning of each of them. All values are theoric values, they describe a maximal instantaneaous transmission capacity regardless of some necessary additional control bit or silent phases. The actual transfer rate is the amount of data that can be transfered in a real situation. Such a transfer rate is physically possible but generally requires strict conditions. Units : Hertz (kHz, MHz, …) : This unit is not precisely a transfer rate unit, but a clock frequency. It is generally understandable that each dataline transfers one bit per clock period (This is a general assumption with exceptions, like DDR lines, see part 7). Baud (kbaud, Mbaud...) : This unit is more particularly used in academic contexts or in RF transmission. It represents the number of symbols sent in 1 second. For basic digital communication, a symbol correspond to one bit. For more complex communications, a symbol may represent several bits. This unit is deprecated because it requires knowledge about the communication itself to be usable. Bit per second (bps, bit/s …) : This unit reflects the quantity of data sent for each unit of time. It is the unit which physically reflects a transfer rate. For commercial reasons, half duplex communications rates are sometimes described as the sum of the two communication ways. In such cases, a 2Mbps link actually provides 1Mbps communications in both ways. 3) UART (Universal Asynchronous Receive Transmit) A universal asynchronous receiver/transmitter, (UART) is a component that translates data between parallel and serial forms. UARTs are commonly used in conjunction with communication standards such as RS-232, or RS-485. The name UART is abusively used to describe a serial communcation that follows these specifications. Many modern Integrated Circuits now come with a UART that can also communicate synchronously; these devices are called USARTs (universal synchronous/asynchronous receiver/transmitter). The UART usually does not directly generate or receive the external signals used between different items of equipment. Separate interface devices are used to convert the logic level signals of the UART to and from the external signalling levels.For example, in RS-232, a '1' is coded by a voltage between -15V and -3V and a '0' is coded by a voltage between +3V and +15V. The link may also be 'non electrical' (Ir, …). Comunications based on UART are Full duplex and symetrical, so when two components are connected using this link, none of them has more priority than the other). Machine to Machine – ENSEIRB 2014-2015 a) Interface : UART comunication only requires 2 unidirectional lines : 1 line to transmit data (TX) and 1 line to receive data (RX). It is necessary to add a ground signal if transmitter and receiver do not use the same power supply. The transmit line of each device (TX) is an output and is connected to the receive line of the other device(RX) which is an input. b) Operation : The idle, no data state is high-voltage, or powered. Each character is sent as a logic low start bit, a configurable number of data bits (usually 8, but users can choose 5 to 8 or 9 bits depending on which UART is in use), an optional parity bit if the number of bits per character chosen is not 9 bits, and one or more logic high stop bits (see table below). The start bit signals the receiver that a new character is coming. The next five to nine bits, depending on the code set employed, represent the character. If a parity bit is used, it would be placed after all of the data bits. The next one or two bits are always in the mark (logic high, i.e., '1') condition and called the stop bit(s). They signal the receiver that the character is completed. Since the start bit is logic low (0) and the stop bit is logic high (1) there are always at least two guaranteed signal changes between characters. Bit number 1 2 3 4 5 6 7 8 9 10 11 Start bit 5–8 data bits Stop bit(s) Start (0) Data 0 Data 1 Data 2 Data 3 Data 4 Data 5 Data 6 Data 7 Stop (1) c)Parity A parity bit, or check bit, is a bit added to the end of a string of binary code that indicates whether the number of bits in the string with the value one is even or odd. Parity bits are used as the simplest form of error detecting code. There are two variants of parity bits: even parity bit and odd parity bit. In case of even parity, the parity bit is set to 1 if the count of ones in a given set of bits (not including the parity bit) is odd, making the count of ones in the entire set of bits (including the parity bit) even. If the count of ones in a given set of bits is already even, it is set to a 0. When using odd parity, the parity bit is set to 1 if the count of ones in a given set of bits (not including the parity bit) is even, making the count of ones in the entire set of bits (including the parity bit) odd. When the count of set bits is odd, then the odd parity bit is set to 0. d)Flow control As any point of the UART link may send data whenever it needs, flow control considerations are necessary. Hardware : In older versions of the specification, RS-232's use of the RTS and CTS lines is asymmetric: The sender asserts RTS to indicate a desire to transmit to the receiver, and the receiver asserts CTS in response to grant permission. This scheme is deprecated in most modern systems that only use UART as a console interface. Software : Software flow control uses special codes, transmitted in-band, over the primary communications channel. These codes are generally called XOFF and XON (from "transmit off" and "transmit on", respectively). Thus, "software flow control" is sometimes called "XON/XOFF Machine to Machine – ENSEIRB 2014-2015 flow control". For systems using the ASCII character code, XOFF is generally represented using a character or byte with value 19; XON with value 17. When one end of a data link is unable to accept any more data (or approaching that point), it sends XOFF to the other end. The other end receives the XOFF code, and suspends transmission. Once the first end is ready to accept data again, it sends XON, and the other end resumes transmission. The principal advantage of software flow control is the reduction in the number of wires between sender and receiver. However, software flow control is not without its problems. Sending XOFF requires at least one character time to transmit, and may be queued behind already-transmitted data still in buffers.