Tuesday, February 23, 2010

Sampling, Quantization & Encoding

Since we have discussed on what digital signals are, the next question that obviously comes up is how do we generate a digital signal? Digital signals can be generated from analog signals by the means of 3 basic steps:
  • Sampling
  • Quantization
  • Encoding
We will take a look at each of these steps one by one.

What should be the first step in getting a digital signal? You need to discretize the analog signal in time. This process is called the process of sampling. For the purpose of sampling, the analog signal values are measured at discrete intervals of time, say at an interval of 1 second each. Physically this can be done with the help of a simple circuit that uses a switch. The switch is on for a very small amount of time at an interval of one second. Thus, the analog signal passes through the switch during this small amount of time only, when the switch is on. Hence we approximately get the amplitude of the analog signal at these discrete periods of time.

Theoretically, this is represented as multiplying the analog signal by a train of impulses. An impulse is a signal that has some value only during the present time instant, ie, at time t = 0, but is zero elsewhere.A train of impulses are impulse signals occurring periodically over time. The train of impulses can thus be represented by the following diagram.


Thus, on applying the following input to the sampling circuit, the output is obtained as:




Once a signal is sampled, it is called a discrete signal. The next step towards digitization is Quantization. In this step, we do what is left for a signal to be called as digital, that is, amplitude discretization. We divide the amplitude into discrete levels. Usually the number of levels is a power of 2. This is done for easier binary representation. This will be further illustrated when we look into encoding. The resulting signal looks like this:

 
 Here, discretization of amplitude has been done with unit amplitude as the step.

The resulting signal is a digital signal. However, the digital systems we generally use, have binary representations only, that is, they can understand only two states, zero or one, or on or off. This is due to the fact that they are implemented using switches, namely, transistors, which can be either switched on or off. For this reason, the number of levels we have divided the amplitude into, have to be encoded in binary. This process is known as Encoding. Here we find the use of taking 2^n levels in amplitude. Any radix 2 number (having number of values equal to 2^n),  can be encoded into binary using n-bits, where each bit represents either zero or one. Any value within this 2^n can then be represented by an n-bit number. This can be demonstrated by a simple example.

Let us consider that we divide the amplitude into 8 equal levels. Now we know,
8  = 2^3
Thus, according to the previous argument, the number of bits required to represent any of these levels is 3. This is shown as follows:
Level 0 = 000 binary
1 = 001
2 = 010
3 = 011
4 = 100
5 = 101
6 = 110
7 = 111
Thus, we get 8 levels, from level 0 to level 7, which can be represented by 3-bit binary numbers. It is to be noted that the levels are numbered from 0 to 7, thus making a total of 8 levels.

For the digital signal we have generated, the encoded signal is as follows. We need 4-bits for encoding here, as 2^4 = 16:


The process of encoding provides us with the required digital signal, which can be transmitted over any transmission medium and can also be used by digital systems for different purposes.

We will try to explore the world of digital further in the up-coming posts. And as we move on, we'll try to focus on the practical aspect of designing a digital circuit. But before that, I must keep my promise. Here is the solution to the question that I asked: 
Why do we need a usb programmer rather than serial programmer on laptops?
Well, the answer is simply because laptops do not have a serial port for communication. Hence we are obliged to use a usb port and hence a usb programmer.

9 comments:

  1. Great!!! This helped me a lot........ Thanks!

    ReplyDelete
    Replies
    1. It is really great to know the article was of help to you :) Thanks for the comment :)

      Delete
  2. This information helprd me alot to continue prepairing my presentation
    thank you soooooo much
    Ali
    Lebanese International University-Yemen

    ReplyDelete
  3. It is great to know that the post was of help. :)

    ReplyDelete
  4. Great explaination. Thank you.

    ReplyDelete