intervoxel
- 192
- 1
- TL;DR
- A recursive generator of a quadrature signal which fits exactly in a NxN grid, where N is a large power of two.
I need to recursively generate a quadrature signal which fits exactly into a grid NxN, where N is a large power of two.
After unsuccessful research, I decided to develop my own solution, starting from the waveguide-form oscillator taken from Pete Symons' book 'Digital wave generation, p. 100'.
\begin{gather}
\begin{bmatrix}\hat{ y_1}\\\hat{y_2}\end{bmatrix}
=
\begin{bmatrix}
k &k-1\\
k+1&k
\end{bmatrix}
\begin{bmatrix} y_1\\y_2\end{bmatrix}
\end{gather}
where k=cos(\omega T).
This formula works perfectly when using floating point numbers.
In the case of the NxN grid, we have \omega T=2\pi/N, and the amplitude is N/2.
For N>>1, we have k=N/2-1.
The difference equations then become
\begin{gather}
\hat{ y_1}=\frac{2((N/2-1)y_1 - y_2)}{N}
\end{gather}
and
\begin{gather}
\hat{ y_2}=\frac{2((N-1)y_1 + (N/2-1)y_2))}{N}
\end{gather}
If we initialize N=128 and y_1=N/2, y_2=0, we get for the first iteration the values \hat{y_1}=63 and \hat{y_2}=127 (it was expected a low value!). That is, y_2>N/2.
What went wrong? Thank you for any help.
After unsuccessful research, I decided to develop my own solution, starting from the waveguide-form oscillator taken from Pete Symons' book 'Digital wave generation, p. 100'.
\begin{gather}
\begin{bmatrix}\hat{ y_1}\\\hat{y_2}\end{bmatrix}
=
\begin{bmatrix}
k &k-1\\
k+1&k
\end{bmatrix}
\begin{bmatrix} y_1\\y_2\end{bmatrix}
\end{gather}
where k=cos(\omega T).
This formula works perfectly when using floating point numbers.
In the case of the NxN grid, we have \omega T=2\pi/N, and the amplitude is N/2.
For N>>1, we have k=N/2-1.
The difference equations then become
\begin{gather}
\hat{ y_1}=\frac{2((N/2-1)y_1 - y_2)}{N}
\end{gather}
and
\begin{gather}
\hat{ y_2}=\frac{2((N-1)y_1 + (N/2-1)y_2))}{N}
\end{gather}
If we initialize N=128 and y_1=N/2, y_2=0, we get for the first iteration the values \hat{y_1}=63 and \hat{y_2}=127 (it was expected a low value!). That is, y_2>N/2.
What went wrong? Thank you for any help.