Changes

/* Reconstructing the DFT of a Discrete-Time Sampled Signal */
*Discrete-Time Fourier Transform (DTFT)
*Discrete Fourier Transform (DFT)
*Discrete Convolution Block*Arbitrary Temporal Waveform|All versions|{{download|http://www.emagtech.com/contentdownloads/project-file-download-repository|ProjectRepo/SystemLesson8.zip System-Level Tutorial Lesson 8|[[RF.Spice A/D]] R15}} }}
=== What You Will Learn ===
In this tutorial you will learn how to use [[RF.Spice]]'s discrete-time Fourier transform (DTFT) blocks as well as its discrete Fourier transform (DFT) blocks. You will also learn how to define arbitrary temporal waveforms.
== A Note on RF.Spice's Fourier Transform Blocks ==
<math> X^s[k] = \sum_{n=0}^{N-1} x[n]\sin(2\pi kn/N) </math>
All of [[RF.Spice]]'s ten DTFT blocks and ten DFT blocks take a continuous signal as their input, sample it with a sampling period T specified by you, and produce two output signals corresponding to the cosine and sine DTFT or DFT transforms. It is very important for you to understand that the two output signals of the DTFT blocks are still constructed and plotted as functions of time. They are indeed time domain voltage signals that are computed through a transient simulation of your input signal, but they must be interpreted in the frequency domain by reinterpreting the time axis as a frequency axis (f &ge; 0). As a result, you can always see and plot only the positive frequency axis.
{{Note|For practical computation of DTFT transforms, you should keep the sampling period on the order of seconds. An extremely short sampling period T would lead to an extremely large spectral period (1/T) and would require an extremely long transient time interval.}}
</table>
To generate a single pulse waveform of duration 8s, use the following [[parameters]] for the voltage source V1:
{| border="0"
|}
Run a Transient Test of this circuit with the [[parameters]] specified below:
{| border="0"
</table>
Before moving to the next part, change the sampling period of the DTFT block to T = 0.5s and run another Transient Test of your circuit using the same [[parameters]] as before. Note that the 8-point DTFT block X1 will collect a total of 8 samples of your input signal v(1) at half-second intervals. This means that the DTFT block will see your input pulse waveform only over the time interval [0, 4s]. In other words, your input signal has been effectively reduced to:
<math> x_1(t) = rect \left( \frac{t-2}{4} \right) </math>
|}
Using [[RF.Spice]]'s arbitrary temporal waveform generator, you can define any mathematical function of time as the waveform of your voltage source. You can access this generalized source from '''Menu > Parts > Waveform Generation Blocks > Basic Waveforms > Arbitrary Temporal Waveform Generator'''. In the property dialog of this source, click the {{key|Edit Model...}} button to open a second dialog where you need to enter a mathematical expression as a function of "v(t)". In other words, v(t) stands for the time variable.
In this part of the tutorial lesson, you will define a sinc function:
</table>
Run a Transient Test of this circuit with the [[parameters]] specified below:
{| border="0"
<math> X_5(f) = X_3(f) = rect(f) * 8 \left[ \frac{\sin(8\pi f)}{8\pi f} \right] e^{-j8\pi f} </math>
Run one more transient test of your circuit with the same [[parameters]] as before. The results are shown in the figure below, where you can see a doubled spectral period of f<subs</sub> = 1/T = 1/(0.25s) = 4Hz, while the output pulse's unit width has remained the same as before.
<table>
|-
! scope="row"| X1
| 16-Point Discrete-Time Convolution Block
| Defaults, T = 1s
|-
! scope="row"| 2
| 32-Point Discrete-Time Convolution Block
| Defaults, T = 0.5s
|-
! scope="row"| X3
| Discrete-Time Signal Hold Block| Defaults, T = 0.5s, Tmax = 20s
|}
<math> f[n] * g[n] = \sum_{k=-\infty}^\infty x[k]\, h[n - k] </math>
[[RF.Spice A/D]] provides ten Discrete Convolution blocks with different numbers of samples ranging from 5 to 64. You can access these block from '''Menu > Parts > Digital Signal Processing Blocks > Discrete Convolution Blocks'''. In this part of the tutorial lesson, you are going to convolve a pulse function with itself. For the input pulse you will use a '''Finite Sequence Pulse Generator''' which can be accessed from the same menu as the pulse (train) generator. To generate a pulse sequence of duration 8s, use the following [[parameters]] for the voltage source V1:
{| border="0"
</table>
Run a Transient Test of this circuit with the [[parameters]] specified below:
{| border="0"
|}
Before running the simulation, open [[RF.Spice]]'s "SPICE [[Simulation Options]]" dialog and change the '''Integration Method''' from the default choice "trap" to "gear". Sometimes, the simulation may not converge quickly using the "trap" method.
<table>
</table>
Next, replace the 16-point convolution block with the 32-point convolution block , set its sampling period to T = 0.5s, and follow it with the '''Discrete-Time Signal Hold Block ''' as shown in the figure below:. Set the value of the sampling period T of this block equal to 0.5m and its '''Tmax''' parameter to 20s.
Change the <table><tr><td>[[parametersFile:SysTUT8 37.png|thumb|640px| The 32-Point Discrete Convolution Block followed by a Signal Hold Block.]] </td></tr></table> Change the parameters of the Finite Sequence Pulse Generator as follows:
{| border="0"
| 0
|}
 
Run a Transient Test of this circuit with the parameters specified below:
 
{| border="0"
|-
| valign="top"|
|-
{| class="wikitable"
|-
! scope="row"| Start Time
| 0
|-
! scope="row"| Stop Time
| 20s
|-
! scope="row"| Linearize Step
| 0.5ms
|-
! scope="row"| Step Ceiling
| 0.5ms
|-
! scope="row"| Preset Graph Plots
| v(1), v(2), v(3)
|}
 
The simulation results are shown in the figure below. The total input signal duration is still 8s, but you have twice as many input samples this time.
 
<table>
<tr>
<td>
[[File:SysTUT8 38.png|thumb|750px|The graph of the input pulse signal, the convolution output signal, and the output of the signal hold block with T = 0.5s.]]
</td>
</tr>
</table>
== Comparing & Contrasting DTFT and DFT Blocks ==
|}
In the last this part of this tutorial lesson, you are going to take the discrete-time output signal of the convolution circuit of the previous part and pass it through DFT16 and DTFT16 blocks to calculate both the discrete-time Fourier transform (DTFT) and discrete Fourier transform (DFT) of the triangular pulse sequence. Set the '''Sequence Length''' of the DFT block to N = 48.
<table>
</table>
Run a Transient Test of this circuit with the [[parameters]] specified below:
{| border="0"
|}
Before run the For this simulation, open [[RF.Spice]]'s "SPICE [[Simulation Options]]" dialog and too, change the '''Integration Method''' from the default choice "trap" SPICE integration method to "gear". Otherwise, in the simulation may not converge.  <table><tr><td>[[File:SysTUT8 36.png|thumb|550px| Changing the "Integration Method" to '''Gear''' in SPICE Simulation Options dialog.]]</td></tr></table> The simulation results are shown in the figure below. You can see that the Fourier transform results stabilize after a quite long period of time.
<table>
The DFT results are indeed the samples of the DTFT results in the time interval [16s, 17s]. Zoom in the above graph and scale the time axis to the interval [15.5s, 17.5s] to better see the details. As you can see from the figures, your input signal is a triangular pulse sequence which is the result of convolution of a pulse sequence with itself. According to Parseval's theorem:
<math> \mathcal{F}\left \{ x(t) * h(t) \right \} = \mathcal{F}\left \{ x(t) \right \} \cdot \mathcal{F}\left \{ h(t) \right \} = X(f) \cdot H(f) </math>
the Fourier transform of the convolution of the two "rect" functions must be a "squared sinc" function, which is clearly visible from the results.
</table>
The DFT samples are taken by default over one frequency period equal to 1/T. You can extend the sampling window to "n_dur / T" by setting a value greater than 1 for the '''n_dur''' parameter of the DFT block. Also, the frequency sampling starts by default at t = N<sub>DTFT</sub>.T + n_delay/T. The default value of the '''n_delay''' parameter of the DFT block is zero. It can take both positive or negative values.
== Reconstructing the DFT of a Discrete-Time Sampled Signal ==
 
The following is a list of parts needed for this part of the tutorial lesson:
 
{| border="0"
|-
| valign="top"|
|-
{| class="wikitable"
|-
! scope="col"| Part Name
! scope="col"| Part Type
! scope="col"| Part Value
|-
! scope="row"| V1
| Finite Sequence Pulse Generator
| T = 1s, w = 0.1s, N = 9, Rise Time = 1ms, Fall Time = 1ms
|-
! scope="row"| R1 -R2
| Resistor
| 100
|-
! scope="row"| X1
| 16-Point Discrete Convolution (DTCONV16) Block
| Defaults, T = 1s
|-
! scope="row"| X2
| 16-Point Discrete Fourier Transform (DFT16) Block
| Defaults, T = 1s, N = 64, Duty Cycle = 0.25
|-
! scope="row"| X3
| Complex Modulus Block
| Defaults
|-
! scope="row"| X4
| Discrete-Time Signal Hold Block
| Defaults, T = 15.625ms, Tmax = 156.25ms
|}
 
Before closing this tutorial lesson, let's see what happens if you increase the DFT's sequence length or period N to 64. Place and connect the parts as shown in the figure below.
 
<table>
<tr>
<td>
[[File:SysTUT8 40.png|thumb|680px| The DFT16 block followed by a discrete-time signal hold block.]]
</td>
</tr>
</table>
Open the property dialog of the DFT16 block called X2, set N = 64 and set the value of the sampling pulse '''Duty Cycle''' to 0.25. Since the sampling period is T = 1s, the spectral period is f<sub>s</sub> = 1Hz. With a sequence length of N = 64, the spectral contents will be sampled at f<sub>s</sub>/N = 1/(NT) = 1/64Hz = 15.625mHz. Remember that on the time axis this mean signal details on a time scale of 15.625ms. In other words, the DFT pulse sequence is located in the time interval [16s, 17s] with a pulse period of T<sup>&prime;</sup> = 15.625ms. This is the value that you will choose for the sampling period of the signal hold block. Set the value of the '''Tmax''' parameter of this block to 10T<sup>&prime;</sup> = 156.25ms.
 
Run a Transient Test of this circuit with the parameters specified below:
 
{| border="0"
|-
| valign="top"|
|-
{| class="wikitable"
|-
! scope="row"| Start Time
| 0
|-
! scope="row"| Stop Time
| 20
|-
! scope="row"| Linearize Step
| 0.5ms
|-
! scope="row"| Step Ceiling
| 0.5ms
|-
! scope="row"| Preset Graph Plots
| v(5), v(6)
|}
 
The simulation results are shown in the figure below. Zoom in the graph's time axis and scale it to the interval [16s, 17s] to see the reconstructed spectral response.
 
<table>
<tr>
<td>
[[File:SysTUT8 41.png|thumb|750px|The graph of the output of the DFT16 block with N = 64.]]
</td>
</tr>
</table>
 
<table>
<tr>
<td>
[[File:SysTUT8 42.png|thumb|750px|The zoomed-in graph of the input and output signals of the discrete-time signal hold block in the time interval [16s, 17s].]]
</td>
</tr>
</table>
<p>&nbsp;</p>
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorial 2FD_Tutorials | Back to RF.Spice A/D Tutorial Gateway]]'''
28,333
edits