Signal Processing: Digital-to-Analog Conversion (Signal Reconstruction)

avatar

eq27.png

Introduction

Digital signal processing is a straight forward task. It converts analog signal to a digital signal that is easily processed, stored or visualize. However, digital signal processing does not limit to analog-to-digital conversion. We need to convert back the digital signal to analog signal for our analog system and devices. In this blog, we explain and discuss a simple way to convert digital signal to analog using reconstruction technique.

Reconstruction

If we consider xa(t) is strictly bandlimited so that Xa(jΩ) = 0 for |Ω| > Ω0 and Ts < π/0, we can reconstruct xa(t) from the samples x(n) = xa(nTs). Reconstructing the signal undergoes two step. First, samples x(n) are converted into sequence of impulses,

eq21.png

and then xa(t) is filtered with a reconstruction filter, which is an ideal low-pass filter that has a frequency response given by,

eq22.png

The impulse response of the reconstruction filter is

eq23.png

The output of the filter is given by

eq24.png

The interpolation formula shows how xa(t) is reconstructed from its samples x(n) = xa(nTs).

Example and MATLAB Simulation

Consider a discrete-time signal is given as x(n) = cos(0.2πn) +sin(0.2πn). We find the continuous-time signal that replicates a continuous-time signal at the sampled frequency, fs = 100 Hz. First, we solve for the fundamental frequency of the discrete-time signal. We get

eq25.png

The continuous-signal for the discrete-time signal, x(n) = cos(nπ/8) + sin(nπ/8), is

eq26.png

We implement the MATLAB script:

%Discrete-time signal
fs = 100;
n = 0:1:100;
xn = cos(0.2*pi*n)+sin(0.2*pi*n);

%Continuous-time signal
t = 0:1/fs:1;
xt = cos(20*pi*t)+sin(20*pi*t);

%Quantization and Encoding
qn = max(xn)/8;
y=round(xn/qn);
sgn = uint8((sign(y)'+1)/2);
xhn =[sgn dec2bin(abs(y),7)]; %encode the signal values to binary
%Plotting each signal representation
ax1 = subplot(3,1,1);
stairs(n, xn*(1/qn),'g'); grid on;
ax2 = subplot(3,1,2);
stem(n,xn,'r','MarkerSize',4);grid on;
ax3 = subplot(3,1,3);
plot(t,xt, 'b');grid on;
xlabel(ax1, 'samples');xlabel(ax2, 'samples');xlabel(ax3, 'time');
ylabel(ax1, 'levels');ylabel(ax2, 'amplitude');
ylabel(ax3, 'amplitude');



The script generates the plot shown in the figure below.

eq27.png

Let us have another example. We consider the discrete time signal, x(n) = 2cos(0.2πf1n) + 0.5(2πf2n) with f1 = 1/6 and f2 = 2/5. We set the sampling frequency to ten times the ratio between f2 and f1. We have the reconstructed signal shown in the figure below.

eq28.png

The reconstructed signal is generated by applying the reconstruction filter algorithm stated in section 1. The MATLAB script to generate the output is listed below.

f1 = 1/6; f2 = 2/5;
N = 24;
Fs = 10*(f2/f1);
%if f1 > f2
    %Fs = 10*f1;
%else
   % Fs = 10*f2;
%end
Ts = 1/Fs;
t = 0:Ts:48;
n = -24:Ts:24;

for i = 1:length(n)
    hr(i) = (sin((pi*(t)))/Ts)/((pi*(t))/Ts);
    h = hr.';
    xn = 2*cos(2*pi*f1*n)+0.5*cos(2*pi*f2*n);
    xt(i) = xn(i)*h(i);
end

%Quantization and Encoding
qn = max(xn)/8;
y=round(xn/qn);
sgn = uint8((sign(y)'+1)/2);
xhn =[sgn dec2bin(abs(y),7)]; %encode the signal values to binary


%Plotting each signal representation
ax1 = subplot(3,1,1);
stairs(n, xn*(1/qn),'g'); grid on;
ax2 = subplot(3,1,2);
stem(n,xn,'r','MarkerSize',4);grid on;
ax3 = subplot(3,1,3);
plot(t,xt, 'b');grid on;
xlabel(ax1, 'samples');xlabel(ax2, 'samples');xlabel(ax3, 'time');
ylabel(ax1, 'levels');ylabel(ax2, 'amplitude');
ylabel(ax3, 'amplitude');

Conclusion

In Digital-to-Analog conversion, the signal is reconstructed from the sampled signal x(n). A reconstruction filter enables us to revert the discrete values into its continuous-time values. The reconstruction of a signal may not be accurate to the actual represented signal due to the innate error in sampling. However, the reconstructed signal is a representation of the original continuous-time signal.

4. References

  1. Gérard Blanchet, Maurice Charbit, Digital Signal and Image Processing Using MATLAB, online access

  2. Neal S. Widmer, Gregory L. Moss, Ronald J. Tocci, Digital Systems: Principles and Applications, 12th Edition, online access

  3. John W. Leis, Digital Signal Processing Using MATLAB for Students and Researchers. online access

Posted with STEMGeeks



0
0
0.000
2 comments
avatar

Congratulations @juecoree! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You received more than 25000 upvotes.
Your next target is to reach 30000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Hive Tour Update - Advanced posting
Valentine's day challenge - Give a badge to your beloved!
0
0
0.000