Implementation of a harmonic oscillator¶
Laboratory Class 07 - 14 October 2021¶
Topics¶
Theoretical and experimental aspects linked to the development of a harmonic oscillator:
general discussion on the difficulty of implementing an oscillator;
from the differential equation of a forced oscillator to the z–transform of the simulator response function V (z);
derivation of the difference equation;
setting of the boundary conditions for the cosine operation;
dependency of the working frequency \(f_0 = \frac{ω_0}{2\pi}\) on the parameter k, provided that \(ω_0T ≪ 1\): and \(f_0 = f_s/\left( 2^{\frac{k}{2}+1}\pi\right)\), with \(f_s = 1/T\).
Problems¶
implementation and characterization of a harmonic oscillator.
Harmonic Oscillator¶
Differential Equation¶
Let’s start by writing the differential equation into the “Laplace” space or “s-space”. In this case the Fourier transform is not enough because it can not handle initial conditions.
Bilinear transform¶
It is possible to obtain the approximate transfer function by applyng the bilinear transform
After the sobstitution we obtain:
By inverting the z-transform we get:
As an fpga works best with powers of two, \(c = 1-2^{k+1}\) is assumed.
Boundary conditions¶
Instead of actually computing the boundary condition, the fact that \(sin(x)\) is symmetric with respect to its maximum is used:
The value of \(y[1]\) was computed by setting \(\text{boundary conditions}[n]= 0\) and assuming an infinite wave.
Characterization of the oscillator¶
By inverting the relation
In terms of the k parameter:
Cosine¶
The quadrature (cosine) WF can be obtained by making a second sinusoid starting when the other wf crosses zero.