Quantization RG 12 Communication Concepts Lecture 7&8 Analogue-to-Digital Conversion: Sampling, Quantization and Encoding Communication Concepts I. Messages & Information II. Data Compression and Coding III. The Communication Channel IV. Analogue and Digital Communications RG 09 Analogue and Digital Many message sources are analogue in nature: Analogue means the signal amplitude can have any value (within a defined range) E.g. audio, video, speech, images. Most communication systems transmit digital signals. Digital means the signal is restricted to a finite set of values (and those values are represented by binary numbers) the trend is for more and more e.g. digital switch-over Converting from analogue to digital involves sampling and quantization Advantages of Digital Communications Transmission Bandwidth It takes less analogue bandwidth to transmit the digitized message source than the analogue message (only because source coding- data compression- can be used!) Immunity from noise The digital message can be transmitted with as few errors as we require. We end up with an exact replica of the digital message (i.e. no distortion of the message apart from the digitization process itself). With analogue messages noise accumulates. Compatibility with digital message sources Data networks (such as the Internet) are intrinsically digital by digitizing analogue sources we can use the same networks for all sources. Security Very sophisticated encryption techniques can be used to protect the transmitted messages Analogue-to-Digital Conversion in Communications Analogue Message Source A/D Conversion Coding Digital Transmission Decoding Analogue Message Sink D/A Conversion Analogue-to-Digital Conversion Sampling Quantization Encoding Communication Technology Communication Concepts: Sampling & Quantization RG 12 Sampling Need for sampling Sampling a waveform The sampling theorem Sampling in the frequency domain Aliasing Signal reconstruction Practical sampling issues The need for Sampling Sampling is a crucial step in digitization* of analogue signals. Applies to time waveforms (signals) and spatial waveforms (images) Sampling can also happen to already digital signals. unsampling or reconstructing the analogue from samples relies on low pass filtering this effectively fills in the gaps between samples. In communications sampling facilitates time division multiplexing where we can send multiple sampled message sources over the same communication channel (just put samples of second signal in gaps of first). *note that sampling itself is an analogue process Sampling a Waveform 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 Sampling a sine-wave too slowly 0 0.5 1 1.5 2 2.5 3 3.5 4 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 The Sampling Theorem A signal is completely represented by samples of that signal provided the sample rate is at least twice the highest frequency in the signal. max 2 f f s > Notes: This is always true. The sampled signal is still analogue Nothing has been lost in this process. [for bandpass signals you might be able to get away with a lower sampling rate] Viewed in the frequency domain. The resulting sampled signal has many replica signals attached to harmonics of the sampling frequency Recovering the Original Signal To recover the original signal (i.e. unsample the sampled signal) we need to: remove all the unwanted high frequency replica signals (or equivalently fill in the gaps of the time waveform) This can be done with a low-pass filter that removes (attenuates) signals with frequencies greater than f s /2. Called a reconstruction filter This process makes sampling completely reversible nothing is lost in the sampling process provided we obey the sampling theorem Communication Technology Communication Concepts: Sampling & Quantization RG 12 Aside: Spectrum A recipe (usually represented by a graph) for making a signal (e.g. an audio wave) out of different amounts of different frequencies. In audio: Pressure, Power or voltage (e.g. from a microphone) Frequency (Hz) Fundamental frequency Harmonics 5 th Harmonic Aside: Filters Filters change the amplitude (and usually phase) of the frequencies present at the input of the filter and put them on the output. Filter frequency frequency frequency A m p l i t u d e A m p l i t u d e Filter Frequency Response Input Output Sampling a sinusoid sampled waveform 0 0.5 1 1.5 2 2.5 3 3.5 4 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 Sampled waveform: very different from original Sampling a sinusoid 0 0.5 1 1.5 2 2.5 3 3.5 4 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 A sampled waveform also represents signals at higher frequencies! Frequency spectrum of sampled wave f s 2f s 3f s 0 frequency Spectral content Original this line only Sampled this line and all the others Reconstruction filter leaves only original sampling completely reversible Communication Technology Communication Concepts: Sampling & Quantization RG 12 Signal Reconstruction Recovering an unsampled signal Pass samples through LPF f s 0 F s /2 Spectrum of sampled signal Reconstruction Filter These removed In time domain: The reconstruction filter joins the samples with a smooth line Aliasing What happens when sampling theorem not obeyed? Frequencies in the input (=original analogue message signal) greater than f s /2 generate frequencies less than f s /2 in the sampled and therefore recovered signal. These overlap with the original message signal. This is called aliasing. Note that aliasing tends to occur at the high frequencies of the signal (in audio this will appear as high frequency noise, in imaging Moire patterns). Since the alias overlaps the original message it cannot be removed by the reconstruction filter (or other means) and distorts recovered message signal. Example: Wagon Wheel http://www.michaelbach.de/ot/mot_wagonWhee l/index.html Aliasing: frequency representation f s 2f s 3f s 0 Aliasing: Lower side frequency of spectral replica overlaps with original signal. Original cannot be recovered exactly frequency Spectral content Spectrum of sampled signal Avoiding Aliasing Anti-alias filtering Oversampling (guard band). f s 0 Oversampling allows practical reconstruction filter and no aliasing F s /2 Anti-Alias filter Sample Bandwidth < f sample /2 Filtered signal f s 0 Aliasing avoided Signal to be sampled Signal with no frequencies above fs/2. Sampled signal with no aliasing Oversampling Reduce specification on analogue* (anti- alias) filter can have slower transition from passband to stopband In practice: Oversample to allow low cost analogue filter then use digital filter. Can also be used to reduce quantization noise quantization noise is spread over all frequencies; digital filter removes frequencies outside of frequency range of the message signal including some of the quantization noise. *actually also applies if we are re-sampling a digital signal Communication Technology Communication Concepts: Sampling & Quantization RG 12 Sampling: Summary Sampling essential step in digitization, but is an analogue process. If sampling theorem obeyed nothing lost (we can get back the original exactly) Use filters in anti-aliasing and message- signal reconstruction. Quantization Quantization is the process that turns an analogue signal (that can have any amplitude value) into a digital one (that can only have amplitudes at specific values). The quantized signal is an approximation to the analogue one. The difference between them is the quantization error or when averaged (mean-square error): the quantization noise. This cannot be removed once introduced*. Generally attempt to minimize quantization noise. Quantization is not a completely reversible process (unlike sampling) as we have added quantization noise to the original signal which is present when we convert back to analogue. * Unless we have oversampled then some of it can Putting it Together 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 1 2 3 4 5 6 7 8 9 Putting it Together 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 1 2 3 4 5 6 7 8 9 Sampled Signal: amplitude exactly the same as original at sampling time Putting it Together Quantized Signal 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 1 2 3 4 5 6 7 8 9 Quantization Error N = no. of bits is the quantization step-size Quantization can also happen to an already digital signal where the number of discrete levels is reduced Quantization Error and Noise Ratio of biggest to smallest signal The process of quantization introduces errors to the digital signal compared to the original analogue one called quantization error. This is a random error that for an ideal A/D is between the limits (+1/2 and -1/2 ). It can be shown that the signal-to-quantization- noise-ratio in dB is: S/N q = 1.8+ 6N dB The dynamic range increases by 6dB (doubles amplitude) for every extra bit. Communication Technology Communication Concepts: Sampling & Quantization RG 12 Quantization Examples How many bits does a (perfect) A/D converter require to give a signal-to-(quantization) noise ratio of 67dB? An A/D converter has a 10bits what is the best S/N that can be obtained? A signal into an A/D has an output of 100mV (rms). The quantization noise is measured to be 0.03mV (rms). What is the minimum number of bits for the A/D? Summary: Quantization Quantization is the process of restricting an analogue signal to discrete values. It is used widely in communication systems, audio, video and image processing It is usually combined with sampling It distorts the original signal by adding quantization noise. Quantization noise is minimized by having a large number of quantization steps (more bits for the A/D); but this means more data (bits/sec). Encoding Each quantization level is given a binary code. This can be natural binary: e.g. 000 001 010 011 100 etc. or some other code. Encoding 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 1 2 3 4 5 6 7 8 9 1010 1001 1000 0111 0110 0101 0100 0011 0010 0001 0000 1000 0110 0011 PCM Transmission PCM stands for pulse code modulation. Each binary message-word is transmitted one bit at a time. The transmission must also contain a means for the receiver to synchronize to the bit- stream. It needs to know: when a bit starts and finishes When a word starts and finishes There are a number of techniques for doing this. CalculationsAARGH! What is the bit-rate (bits/second) from a PCM encoder? Bit-rate=sample-rate x bits/sample Bits/second bps Hertz bits Sample-rate determined by bandwidth of signal and sampling theorem Bits per Sample determined by acceptable quantization noise and/or dynamic range Communication Technology Communication Concepts: Sampling & Quantization RG 12 Multiplexing Since the transmissions are bits it is possible to combine samples from different encoders. This is called Time Division Multiplexing. 10111000|10000111|11110011|000110011|10000111|10010011|100.. Channel 1 Channel 2 Channel 3 Channel 1 Channel 2 Channel 3 time This is how different telephone conversations are carried together in the telephone network: except that 30 channels are combined Summary Analogue message sources often converted to digital for transmission Processes involved: Sampling: Sampling theorem Quantization: Quantization noise, no. of bits. Transmit bit as PCM or use source-coding to reduce bit rate.