5
\$\begingroup\$

I was reading a book which says

Asynchronous transmission is so named because the timing of a signal is unimportant. Instead, information is received and translated by agreed upon patterns. To alert the receiver to the arrival of a new group, therefore, an extra bit is added to the beginning of each byte. This bit, usually a 0, is called the start bit. To let the receiver know that the byte is finished, 1 or more additional bits are appended to the end of the byte. These bits, usually 1s, are called stop bits.

As the picture below shows:

enter image description here

I don't quite get the idea, why do we need a start/stop bit? Isn't that a byte consists of 8 bits, so the receiver just needs to count how many bits it has received so far, if the number is 8, it has one byte and repeats the process. So why do we need start/stop bit?

\$\endgroup\$
  • 13
    \$\begingroup\$ So how do you count bits if you don't know when to start counting? Remember, messages aren't continuous and can come sporadically, and both HI and LO, your only two states are both already used to represent data. There is no third state to represent absence of a message. \$\endgroup\$ – DKNguyen Jun 10 at 15:05
  • \$\begingroup\$ asynchronous, no clock, you need at least one edge and an agreed upon (or if possible detected) rate so that you can do mid bit cell sampling for the those 8 bits give or take (parity, len, etc). And that is not enough to know where you are depending on the situation you may need to have some number of framing errors until you think you are synced up. \$\endgroup\$ – old_timer Jun 10 at 19:07
  • 1
    \$\begingroup\$ even if you had a clock you dont know where the boundaries are you could have something like spi where you have a clock and a select signal so you can see both where to sample and how to divide up what you are sampling so you can recover it on the other side. \$\endgroup\$ – old_timer Jun 10 at 19:08
  • \$\begingroup\$ "timing of a signal is unimportant" -- know there's a joke if I've heard one. \$\endgroup\$ – ilkkachu Jun 11 at 19:06
25
\$\begingroup\$

If you didn't have a zero start bit that kicked-off the timing to the receiver, how would you know what to do when a serial byte comes along with a leading 1 digit in the data stream? What happens if the next bit is also 1 and the bit after that - what if all the bits are 1? Then you'd miss the entire byte because nothing would change (due to not having a start bit of 0).

Regular 8 high bits with leading zero start bit: -

enter image description here

Missing start bit: -

enter image description here

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – Voltage Spike Jun 13 at 4:28
5
\$\begingroup\$

Another consideration, in addition to the accepted answer, is timing. You will have drift between the sender and receiver clock, so the receiver has to "recover" the clock in one way or another. There are fancy schemes like 10/8B which use idle signals to do this, but the simple approach in UARTs is to have a "start bit," whose presence signals the rising edge of the signal. This allows the receiver to resynchronize their clock to receive the upcoming byte.

These start and stop patterns have to occur often enough to ensure alignment does not drift too far during receiving. This leads to start and stop bits appearing every byte. It's a simple rule, even if it falls short of being "ideal" in other ways.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Good point to make, which I was trying to get the OP to understand. \$\endgroup\$ – user105652 Jun 11 at 22:52
4
\$\begingroup\$

I don't quite get the idea, why do we need a start/stop bit? Isn't that a byte consists of 8 bits, so the receiver just needs to count how many bits it has received so far, if the number is 8, it has one byte and repeats the process. So why do we need start/stop bit?

The receiver can't count the bits it's receiving, because the receiver doesn't know whether or not it's receiving bits!

Let's imagine that the sender and the receiver are communicating using sound, and let's imagine that a 0 is represented by one second of silence and a 1 is represented by one second of sound. In your book, the "idle state"—what the sender sends when it doesn't have any actual data to send—is 1, meaning sound.

Now suppose that you're the receiver, and the sender is not using a start bit. You hear eight seconds of continuous sound. Did you just hear the byte "11111111", or is the sender just idling? You have no way of knowing, because it all sounds the same to you.

Alternatively, suppose that you hear one second of silence, then six seconds of sound, then one second of silence. Did you just hear the byte "01111110"? Or was it, perhaps, the byte "11110111" followed by the byte "11101111"? Again, you have no way of knowing.

This is where the start bit comes in. Whenever the sender wants to send a byte, first it sends a 0 (one second of silence), then it sends the byte of data.

Now your job as a receiver is a lot easier! If you hear nine seconds of sound, you know that the sender is merely idling. If, on the other hand, you hear one second of silence followed by eight seconds of sound, you know that the sender just sent the byte "11111111".

Of course, most machine communication systems don't use sound; they use electricity instead. But electric signals work just like sound. The receiver is always going to receive something, regardless of whether we want it to or not. So we need to give the receiver some way of knowing whether it's receiving real data or just idle noise.

To address this specific question from your comment:

just one question, if we don't have "idle" value, so when there is no data to send, the receiver won't receive anything, so it can count every 8 bits as a byte without needing stop/start bit?

It's physically impossible not to have an idle value. If you've got an electric cable, then it's possible to send a positive voltage, or a negative voltage, or a voltage of 0, but it's physically impossible to not send any voltage. That means that the receiver is always going to receive some voltage, no matter what we do. So we have to give the receiver some way to know whether the voltage that it's receiving is meaningful or not.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Perhaps the confusion is because we as humans when we see a diagram like in your question, we see exactly where all the bits are, which one follows which one, etc. However, imagine you are the receiver, and all you have to work with is an incoming flow of signal (for example, 2 levels, one level (say, high) to represent a 1 bit, another level (say, low) to represent a 0 bit), as analog electrical signal that is either steady or changing from one value to the other value. Again, note that the receiver is not a human who sees the 1st bit, 2nd bit, etc., with a global view.

Let's say the "idle" value is the same as the 1-bit value (high). Then you don't know when the bits start arriving unless we have the transition from the 1 to 0. Otherwise, if the first bit is 1, how do you know when it starts?

Then for stop bits, you want it to be opposite of the start bit (so, you want it to be values of 1), so it marks the end of one byte, and you can know when the next byte starts when again it goes from high to low.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ You could also argue that instead of a global view, it's a non-causal view. Not only is it non-causal, but the diagrams are also drawn after someone or something has already figured out where everything starts and ends and labelled them. You might as well say "Why do we need all this work to solve this equation? The answer is right here at at the end! Just use that!" \$\endgroup\$ – DKNguyen Jun 10 at 17:55
  • \$\begingroup\$ @auspicious99 Thanks for your answer. just one question, if we don't have "idle" value, so when there is no data to send, the receiver won't receive anything, so it can count every 8 bits as a byte without needing stop/start bit? \$\endgroup\$ – amjad Jun 11 at 4:11
  • \$\begingroup\$ @amjad To avoid confusion every byte sent has start and stop bit added, so 10 bits are sent each time. Some still call it a baud rate. The receiver expects 10 bits per byte of data. Remember the start and stop bits help keep the receiver in sync with the data. 8 bit data could be all 1's or all 0's. With no transition from 0 to 1 or 1to 0 the byte boundary cannot be detected. \$\endgroup\$ – user105652 Jun 11 at 5:16
  • 2
    \$\begingroup\$ Note, that in this case the stop bit doesn't really "mark the end of one byte", it doesn't mark anything, the end of the byte is known from the timing. The stop bit is there to reset the line to its idle state so that the next start bit can be detected whenever it comes. \$\endgroup\$ – vsz Jun 11 at 11:16
  • 1
    \$\begingroup\$ @auspicious99: In the absence of stop bits, what would happen if a device sent 5,000 consecutive zero bytes before leaving the line idle for awhile? How accurate would a receiver's clock have to be to determine that the sender had sent exactly 5,000 zero bytes, rather than either 4,999 zeroes and a 0x80, or 5,000 zeroes followed by a 0xFF? There are ways of designing asynchronous protocols to ensure that within any continuous communication there will be periodic line transitions without using stop bits, but most UARTs can't be configured to support them. \$\endgroup\$ – supercat Jun 11 at 20:23
0
\$\begingroup\$

If an idle line is represented by a continuous stream of the same state which has no clear beginning, every transmission must start by sending something which differs from an idle line condition, regardless of whether the first bit being transmitted is zero or one. In the absence of some other means of indicating when a transmission begins, a start bit is thus generally essential in both synchronous and asynchronous protocols where an idle line would be indistinguishable from a uniform string of ones or zeros.

While there are ways of designing protocols that don't require a separate start and stop bits between bytes, and thus improve communications efficiency by 10%, they tend to be somewhat more complicated than the current protocol which was designed to be mechanically decoded with a combination of a solenoid, a motor, and some cams. One of the things that would make doing without stop bits tricky is that if a start bit always drives the line to the opposite of the idle state, and each data bit may be independently high or low, then the act of sending many consecutive zero bytes could simply drive the line low for an arbitrarily long time without any transitions to ensure that the sender and receiver stay in sync.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.