Embedded Systems Course- Module7: SERIAL COMMUNICATION - Part 1(Basics)
Serial communication is common method of transmitting data between a computer and a peripheral device such as a programmable instrument or even another computer. Serial communication transmits data one bit at a time, sequentially, over a single communication line to a receiver. Serial is also a most popular communication protocol that is used by many devices for instrumentation; numerous GPIB-compatible devices also come with an RS-232 based port. This method is used when data transfer rates are very low or the data must be transferred over long distances and also where the cost of cable and synchronization difficulties make parallel communication impractical. Serial communication is popular because most computers have one or more serial ports, so no extra hardware is needed other than a cable to connect the instrument to the computer or two computers together.
(II) Serial Vs Parallel:
Let us now try to have a comparative study on parallel and serial communications to understand the differences and advantages & disadvantages of both in detail.
We know that parallel ports are typically used to connect a PC to a printer and are rarely used for other connections. A parallel port sends and receives data eight bits at a time over eight separate wires or lines. This allows data to be transferred very quickly. However, the setup looks more bulky because of the number of individual wires it must contain. But, in the case of a serial communication, as stated earlier, a serial port sends and receives data, one bit at a time over one wire. While it takes eight times as long to transfer each byte of data this way, only a few wires are required. Although this is slower than parallel communication, which allows the transmission of an entire byte at once, it is simpler and can be used over longer distances. For example, the IEEE 488 specifications for parallel communication state that the cabling between equipment can be no more than 20 meters total, with no more than 2 meters between any two devices; serial, however, can extend as much as1200meters (with high-quality cable).
So, at first sight it would seem that a serial link must be inferior to a parallel one, because it can transmit less data on each clock tick. However, it is often the case that, in modern technology, serial links can be clocked considerably faster than parallel links, and achieve a higher data rate.
Even in shorter distance communications, serial computer buses are becoming more common because of a tipping point where the disadvantages of parallel busses (clock skew, interconnect density) outweigh their advantage of simplicity (no need for serializer and deserializer).
The serial port on your PC is a full-duplex device meaning that it can send and receive data at the same time. In order to be able to do this, it uses separate lines for transmitting and receiving data.
From the above discussion we could understand that serial communications have many advantages over parallel one like:
a) Requires fewer interconnecting cables and hence occupies less space.
B) "Cross talk" is less of an issue, because there are fewer conductors compared to that of parallel communication cables.
C) Many IC s and peripheral devices have serial interfaces.
D) Clock skew between different channels is not an issue.
E) No need of (SERDES).
F) Cheaper to implement.
Clock skew is a phenomenon in synchronous circuits in which the clock signal sent from the clock circuit arrives at different components at different times, which can be caused by many things, like: -
a) Wire-interconnect length,
b) Temperature variations,
c) Variation in intermediate devices,
d) Capacitive coupling,
e) Material imperfections,
As the clock rate of a circuit increases, timing becomes more critical and less variation can be tolerated if the circuit is to function properly.
There are two types of clock skew: Positive skew, which occurs when the clock reaches the receiving register later than it reaches the register sending data to the receiving register and negative skew which just opposite: the receiving register gets the clock earlier than the sending register.
Two types of violation can be caused by clock skew. One problem is caused when the clock travels more slowly than the path from one register to another - allowing data to penetrate two registers in the same clock pulse, or maybe destroying the integrity of the latched data. This is called a hold violation because the previous data is not held long enough at the destination flip-flop to be properly clocked through. Another problem is caused if the destination flip-flop receives the clock pulse earlier than the source flip-flop - the data signal has that much less time to reach the destination flip-flop before the next clock tick. If it fails to do so, a setup violation occurs, so-called because the new data was not set up and stable before the next clock tick arrived. A hold violation is more serious than a setup violation because it cannot be fixed by increasing the clock period. Positive skew and negative skew cannot negatively impact setup and hold timing constraints respectively
(III) Asynchronous Vs Synchronous data transmission:
Like any data transfer methods, Serial Communication also requires coordination between the sender and receiver. For example, when to start the transmission and when to end it, when one particular bit or byte ends and another begins, when the receiver's capacity has been exceeded, and so on. Here comes the need for synchronization between the sender and the receiver. A protocol defines the specific methods of coordinating transmission between a sender and receiver.
Let us take an example. A serial data signal between two PCs must have individual bits and bytes that the receiving PC can distinguish. If it doesn't, then the receiving PC can't tell where one byte ends and the next one begin or where one bit ends and begins. So the signal must be synchronized in such a way that the receiver can distinguish the bits and bytes as the transmitter intends them to be distinguished.
There are two ways to synchronize the two ends of the communication namely synchronous and asynchronous. The synchronous signaling methods use two different signals. A pulse on one signal line indicates when another bit of information is ready on the other signal line. The asynchronous signaling methods use only one signal. The receiver uses transitions on that signal to figure out the transmitter bit rate (known as auto baud) and timing, and set a local clock to the proper timing, typically using a PLL to synchronize with the transmission rate. A pulse from the local clock indicates when another bit is ready. That means synchronous transmissions use an external clock, while asynchronous transmissions are use special signals along the transmission medium.( Refer Fig1.a)
Asynchronous communication is the commonly prevailing communication method in the personal computer industry, due to the reason that it is easier to implement and has the unique advantage that bytes can be sent whenever they are ready, an no need to wait for blocks of data to accumulate.
Mode of connection: -
In a simple connection, the hardware configuration is such that only one-way communication is possible. For example, from a computer to printer that cannot send status signals back to the computer. In a half-duplex connection, two-way transfer of data is possible, but only in one direction at a time. But in a full-duplex configuration, both ends can send and receive data simultaneously, which technique is common in our PCs.
Synchronous transmission - a brief explanation:
In synchronous transmission, the stream of data to be transferred is encoded and sent on one line, and a periodic pulse of voltage which is often called the "clock" or "strobe" is put on another line, that tells the receiver about the beginning and the ending of each bit (or byte). In general, such synchronous transmission protocols are used for all the types of parallel communications. For example, in a computer, address information is transmitted synchronously, i.e.: the address bits over the address bus, and the read strobe in the control bus.
Synchronization can also be embedded into a signal on a single wire. In differential Manchester encoding, used in video-tape systems, each transition from a low to high or high to low represents a logical zero. A logical one is indicated when there are two transitions in the same time frame.
above) Synchronous Vs Asynchronous
The advantages & disadvantages:
The only advantage of synchronous data transfer is the Lower overhead and thus, greater throughput, compared to asynchronous one. But it has some disadvantages such as,
1) Slightly more complex and
2) Hardware is more expensive
One of the main Disadvantage of asynchronous technique is the large relative overhead, where a high proportion of the transmitted bits are uniquely for control purposes and thus carry no useful information. But it holds some advantages like,
1) Simple and doesn't require much synchronization on both communication sides
2) The timing is not as critical as for synchronous transmission; therefore hardware can be made cheaper.
3) Set-up is very fast, so well suited for applications where messages are generated at irregular intervals, for example data entry from the keyboard
The DCE & the DTE:
The terms DTE and DCE are very common in the data communications technologies. DTE is short for Data Terminal Equipment and DCE stands for Data Communications Equipment. But what do they really mean? As the full DTE name indicates, this is a piece of device that ends a communication line, whereas the DCE provides a path for communication.
Let us try to understand the functions of both these equipments through an example. Let's take the example of a computer on which wants to communicate with the Internet through a modem and a dial-up connection. To get to the Internet you tell your modem to dial the number of your provider. After your modems have dialed the number, the modem of the provider will answer your call. Then your connection is established. Now you have a connection with the server from your provider and you can use the Internet. In this example, your PC is a Data Terminal (DTE). The two modems (yours and that one of your provider's) are DCEs. They make the communication between you and your provider possible. But now we have to look at the server of your provider. Is that a DTE or DCE? The answer is a DTE. It ends the communication line between you and the server, although it gives you the possibility to surf around the globe. The reason why it is a DTE is that when you want to go from your provider's server to another place it uses another interface. So DTE and DCE are interface dependent. It means, for your connection to the server, the server is a DTE, but the same server is a DCE for the equipment that it is attached to the rest of the Net.
(IV) How does it (Serial date transfer) work:
Let us come back to serial communication and try to know how the data is transferred serially. Serial communication requires that you specify the following five parameters:
1) The speed or baud rate of the transmission
2) The number of data bits encoding a character
3) The sense of the optional parity bit (whether to be used or not, if yes then odd or even)
4) The number of stop bits
5) Full or half-duplex operation
Each transmitted character is packaged in a character frame that consists of a single start bit followed by the data bits, the optional parity bit, and the stop bit or bits, as shown in the Fig-1.a & Fig-1.b.
After the stop bit, the line may remain idle indefinitely, or another character may immediately be started. The minimum stop bit length required by the system can be larger than a "bit". In fact it can be 1.5 stop bits, or 2 stop bits, or even the new hardware that doesn't support fractional stop bits can be configured to send 2 stop bits when transmitting and requiring 1 stop bit when receiving.
Typically, serial communication is carried out using ASCII form of the data. Communication is completed using 3 transmission lines: Ground, Transmit, and Receive. Since serial is asynchronous (in many applications), the port is able to transmit data on one line while receiving data on another. Other lines are available for handshaking, but are not required. We already understood that the important serial characteristics are baud rate, data bits, stop bits, and parity and for two ports to communicate, these parameters must match.
Let us now try to understand each term in detail.
Baud rate: Used to specify Data speed, which is a measure of the number of times a digital signal changes state in one second or the number of signal events or signal transitions occurring per second. The changes can be
a) From positive voltage to zero voltage,
b) From zero voltage to negative voltage, or
c) From positive voltage to negative voltage.
The baud rate can never be higher than the raw bandwidth of the channel, as measured in Hz. Baud rate and bit rate, often and incorrectly, are used interchangeably. The relationship between baud rate and bit rate depends on the sophistication of the modulation scheme used to manipulate the carrier. The bit rate (bits per second or bps) and baud rate can be the same, if each bit is represented by a signal transition in a single-bit modulation scheme. Baud rate is almost always a lower figure than bps for a given digital signal because some signal modulation techniques allow more than one data bit to be transmitted per change state.
So the bit rate (bps) and baud rate (baud per second) can be connected by the formula: -
bps = baud per second x the number of bit per baud
The number of bit per baud is determined by the modulation technique. The following two examples give how it could be.
1) When FSK ("Frequency Shift Keying", a transmission technique) is used, each baud transmits one bit; only one change in state is required to send a bit. Thus, the modem's bps rate is equal to the baud rate
2) When we use a baud rate of 2400, you use a modulation technique called phase modulation that transmits four bits per baud. So:
2400 baud x 4 bits per baud = 9600 bps
Such modems are capable of 9600 bps operation
Common baud rates for telephone lines are 14400, 28800, and 33600. Baud rates greater than these are possible, but these rates reduce the distance by which devices can be separated. These high baud rates are used for device communication where the devices are located together, as is typically the case with GPIB devices.
Data bits: When the computer sends a packet of information, the amount of actual data may not be a full 8 bit. Standard values for the data packets are 5, 7, and 8 bits. Which setting you choose depends on what information you are transferring. For example, standard ASCII has values from 0 to 127 (7 bits). Extended ASCII uses 0 to 255 (8 bits). If the data being transferred is simple text (standard ASCII), then sending 7 bits of data per packet is sufficient for communication. A packet refers to a single byte transfer, including start/stop bits, data bits, and parity. Since the number of actual bits depends on the protocol selected, the term packet is used to cover all instances.
Start & Stop bits: Stop bit is used to indicate the end of a single packet. Typical values are 1, 1.5, and 2 bits. Since the data is clocked across the lines and each device has its own clock, it is possible for the two devices to become slightly out of sync. Therefore, the stop bits not only indicate the end of transmission but also give the computers some room for error in the clock speeds. The more bits that are used for stop bits, the greater the lenience in synchronizing the different clocks, but the slower the data transmission rate. Start bit is the bit, which signals the receiver that data is coming. Every byte of data in an asynchronous serial transmission is preceded by a start bit and followed by a stop bit.
Parity: It's used for error checking in serial communication. There are two types of parity: even and odd. And the option of using no parity is also available. For even and odd parity, the serial port will set the parity bit (the last bit after the data bits) to a value to ensure that the transmission has an even or odd number of logic high bits. For example, let us take the data as 011.Then for even parity; the parity bit would be 0 to keep the number of logic high bits even. Similarly, for odd parity the parity bit would be 1, resulting in three logic high bits.
Another category of parity, Marked and spaced parity does not actually check the data bits, but simply sets the parity bit high for marked parity or low for spaced parity. This allows the receiving device to determine if noise is corrupting the data or the transmitting and receiving devices' clocks are out of sync.
If an odd number of bits (including the parity bit) are changed while transmitting a set of bits then parity bit will be incorrect and will thus indicate that an error in transition has occurred. That means, parity bit is an error detecting code, but is not an error correcting code as there is no way to determine which particular bit is corrupted. So then the data must be discarded entirely, and re-transmitted from scratch
(V) Various types of serial communication Standards:
5. Fire Wire
8. PCI Express
9. SPI & SCI
PS: Each of these above modules are explained in next coming modules
Module - 8 (Serial Communications - Continued)
Module - 6(Sample C programs)
ABOUT THIS COURSE:
Totally EEHerald plan to bring 12 modules. You can be assured of completing basic course in Embedded Systems after studying and practicing exercises in all the modules. We will give priority to programming and serial communications (SPI, USB, CAN etc..) part. To receive a copy of total course syllabus, please email to us.
This free tutorials on embedded systems is prepared by embedded professionals with more than10 years of industrial experience, however we want your feedback on this course content; please email your questions, suggestions and comments to firstname.lastname@example.org. Your questions on present modules will be answered in the revised modules. We may change the course content based on the majority of your requests and feedbacks.
Please let your friends know about this course, we request you to email this link to your friends and colleagues who are interested in embedded system.
Author: Srinivasa Reddy N