## Wednesday, August 3, 2011

### More on CODECs: Quantization + Sampling Rate = A PCM Wave

In my last post I started writing about about CODECs and how they are used in a communications system to convert analog signals to digital signals on one end and, on the other end, convert a digital signal back to an analog signal. I discussed sampling rates and the Nyquist Sampling Theorem. It turns out there's more to generating the Pulse Code Modulated (PCM) wave shown in that last post.

Quantization is used along with the sampling rate to generate a PCM wave. The instantaneous voltage value of an analog signal is quantized into 28 (256) discrete signal levels. With each sample the signal is instantaneously measured and adjusted to match one of the 256 discrete voltage levels.

PCM Wave Generation (note: not to scale)

Since quantization adjusts voltage levels to match one of 256 discrete voltage levels it is easy to see that there will be some signal distortion. This distortion is known as quantizing noise and is greater for low amplitude signals than high amplitude signals. A technique called companding is used to compress and divide the lower amplitude signals into more voltage levels and provide more signal detail at the lower voltage amplitudes. In North America and Japan, this is done using an algorithm called the μ-law. Other countries in the world use the A-law algorithm so conversion is required when calls are made between countries using different algorithms.

Once a piece of an analog signal has been quantized and companded it is then given an 8 bit binary code. This process is referred to as encoding.

After a single analog signal has been encoded it is multiplexed, or combined, with 24 other encoded 8 bit signals. This generates a 192 bit (8×24) sequence for the 24 signals. A process called framing then adds one framing bit to create a 193 bit frame. The framing bits are used to keep the receiving device in synchronization with the frames it is receiving and follow a 12 frame pattern that is repeated with each 12 frames. This sampling rate has determined the Digital Signal (DS) Level System I'll cover here in a future post.