Introduction:
We know that a digital signal is superior to an analog signal. The tendency today is to change an analog signal to digital data. In this section we describe two techniques, pulse code modulation and delta modulation. The most common:
Sampling:
The first step in PCM is Sampling. The analog signal is sampled every Ts second, where Ts is the sample interval or period. The inverse of the sampling interval is called sampling rate or frequency and denoted by fs, where fs = 1/Ts .
There are three sampling methods: ideal, natural and flat-top. In ideal sampling, pulses from the analog signal are sampled. In natural sampling, a high speed switch is turned on for only the small period of time when the sample occurs. The most common sampling method, sample and hold, however, create float-top samples by creating a circuit..
According to the Nyquist theorem, the sampling rate must be at least 2 times the highest frequency contained in the signal.
Quantization:
The result of sampling is a series of pulses with amplitude values between maximum and minimum amplitudes of the signal. The following are the steps in Quantization:
Assume that we have a sampled signal and signal amplitude are between 20V and -20V. We decide to have eight levels (in my code, I decide only two level to make coding easy). ∆ = 5V.
The first row is the normalized value for each sample (actual amplitude/∆). The quantization process selects the quantization value from the middle of each zone. This means that the normalized quantized values (second row) are different from the normalized amplitude. The difference is called the normalized error (third row). The fourth row is the quantization code for each sample based on the quantization levels at the graph. The encoded words (fifth row) are the final products of the conversion.
Quantization level: The amplitude of a signal fluctuates between two values only, we need only two level and we can represent a level with only one bit (0 or 1).
Coding:
In the coding process, each discrete value is represented by a b-bit binary sequence.
Mathematically representation:
Step1: Initialize graphics by using Turbo C :
We use the following code to initialize the graphics in Turbo C :
Step 2:
now take the maximum and minimum co-ordinate as following :
Step 3: Draw the input signal:
Now we take amplitude and frequency of a signal [assume signal is sinusoidal] as following:
Step 4: Sampling Stage:
Now we take the sample interval and then sample the signal as following:
Step 5: Quantization stage:
Now we assume the label. In my code we assume that the label is 2 and then we calculate the Delta value as following: Del = (maximum amplitude – minimum amplitude)/ label. Then we find the normalized PAM value and from there, I find normalize quantized value. Then draw the curve only. The code is:
Step 6: Quantize code:
Now we convert the quantized values into quantize code. The code is as following:
Step 7: find the bit Stream:
Now the quantize code is converted into the binary value. The binary value is saved into the bits array. Code is as following:
Conclusion:
We use the above procedure to convert an analog signal to digital signal. We give a sine wave by taking input the amplitude and a frequency. According to nyquist theorem, the sampling rate must be the twice of the frequency of the input signal. For example, if the input signal frequency is 10 then the sampling rate must be 20. The sample time interval T = 1/20 = 0.05 which is very small to draw the line this interval. So user must input the sampling rate above 0.1 so that the time interval = 10 or above. We use two levels so we can represent the signal in 1 bit (0 or 1).
Complete Code in C/C++:
We know that a digital signal is superior to an analog signal. The tendency today is to change an analog signal to digital data. In this section we describe two techniques, pulse code modulation and delta modulation. The most common:
1. The analog signal is sampled.Figure of analog to digital conversion:
2. The sample signal is quantized.
3. The quantized value are encoded as streams of bit.
Sampling:
The first step in PCM is Sampling. The analog signal is sampled every Ts second, where Ts is the sample interval or period. The inverse of the sampling interval is called sampling rate or frequency and denoted by fs, where fs = 1/Ts .
There are three sampling methods: ideal, natural and flat-top. In ideal sampling, pulses from the analog signal are sampled. In natural sampling, a high speed switch is turned on for only the small period of time when the sample occurs. The most common sampling method, sample and hold, however, create float-top samples by creating a circuit..
According to the Nyquist theorem, the sampling rate must be at least 2 times the highest frequency contained in the signal.
Quantization:
The result of sampling is a series of pulses with amplitude values between maximum and minimum amplitudes of the signal. The following are the steps in Quantization:
1. We assume that the original analog signal has instantaneous amplitudes between Vmin and Vmax.For example:
2. We divide the range into L zones, each of height ∆ (delta)
∆ = (Vmax- Vmin)/L.
3. We assume quantized values of 0 to L-1 to the midpoint of each zone.
4. We approximate the value of the sample amplitude to the quantized values.
Assume that we have a sampled signal and signal amplitude are between 20V and -20V. We decide to have eight levels (in my code, I decide only two level to make coding easy). ∆ = 5V.
The first row is the normalized value for each sample (actual amplitude/∆). The quantization process selects the quantization value from the middle of each zone. This means that the normalized quantized values (second row) are different from the normalized amplitude. The difference is called the normalized error (third row). The fourth row is the quantization code for each sample based on the quantization levels at the graph. The encoded words (fifth row) are the final products of the conversion.
Quantization level: The amplitude of a signal fluctuates between two values only, we need only two level and we can represent a level with only one bit (0 or 1).
Coding:
In the coding process, each discrete value is represented by a b-bit binary sequence.
Mathematically representation:
Step1: Initialize graphics by using Turbo C :
We use the following code to initialize the graphics in Turbo C :
Step 2:
now take the maximum and minimum co-ordinate as following :
Step 3: Draw the input signal:
Now we take amplitude and frequency of a signal [assume signal is sinusoidal] as following:
Step 4: Sampling Stage:
Now we take the sample interval and then sample the signal as following:
Step 5: Quantization stage:
Now we assume the label. In my code we assume that the label is 2 and then we calculate the Delta value as following: Del = (maximum amplitude – minimum amplitude)/ label. Then we find the normalized PAM value and from there, I find normalize quantized value. Then draw the curve only. The code is:
Step 6: Quantize code:
Now we convert the quantized values into quantize code. The code is as following:
Step 7: find the bit Stream:
Now the quantize code is converted into the binary value. The binary value is saved into the bits array. Code is as following:
Conclusion:
We use the above procedure to convert an analog signal to digital signal. We give a sine wave by taking input the amplitude and a frequency. According to nyquist theorem, the sampling rate must be the twice of the frequency of the input signal. For example, if the input signal frequency is 10 then the sampling rate must be 20. The sample time interval T = 1/20 = 0.05 which is very small to draw the line this interval. So user must input the sampling rate above 0.1 so that the time interval = 10 or above. We use two levels so we can represent the signal in 1 bit (0 or 1).
Complete Code in C/C++:
No comments:
Post a Comment