Monday 14 November 2022

DSP Equations In Latex

I was recently documenting some DSP equations in Latex and couldn't find any suitable examples so I've put them together and thought I'd share.

The Fourier Transform

\large \mathscr{F} \normalsize (x(t))=\int_{-\infty}^{\infty}x(t)e^{-j \omega t}dt

Rendering

$$\large \mathscr{F} \normalsize (x(t))=\int_{-\infty}^{\infty}x(t)e^{-j \omega t}dt$$

The Discrete Time Fourier Transform

X(k) = \sum_{n=0}^{N-1}x(n).e^{-j 2 \pi nk/N},\; for\; 0 \le k \le N-1

Rendering

$$X(k) = \sum_{n=0}^{N-1}x(n).e^{-j 2 \pi nk/N},\; for\; 0 \le k \le N-1$$

The Inverse Discrete Time Fourier Transform

x(n) = \frac{1}{N} \sum_{k=0}^{N-1}X(k).e^{j 2 \pi nk/N},\; for\; 0 \le n \le N-1

Rendering

$$x(n) = \frac{1}{N} \sum_{k=0}^{N-1}X(k).e^{j 2 \pi nk/N},\; for\; 0 \le n \le N-1$$

FIR Filter

y(n) = \sum_{n=0}^{N-1}h(k).x(n-k)

Rendering

$$y(n) = \sum_{n=0}^{N-1}h(k).x(n-k)$$

IIR Filter

y(n) = \sum_{k=0}^{N}a_{k}.y(n-k) + \sum_{r=0}^{M}b_{r}.x(n-r)

Rendering

$$y(n) = \sum_{k=0}^{N}a_{k}.y(n-k) + \sum_{r=0}^{M}b_{r}.x(n-r)$$

Roots Of Quadratic Equation $ax^{2} + bx + c = 0$

x=\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Rendering

$$x=\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$

One-Pole Filter

Difference Equation

y(n)=x(n)+\alpha.y(n-1)

Rendering

$$y(n)=x(n)+\alpha.y(n-1)$$

z Transform

Y(z)=X(z)+\alpha z^{-1}Y(z)

Rendering

$$Y(z)=X(z)+\alpha z^{-1}Y(z)$$

Transfer Function

H(z)=\frac{1}{1-\alpha z^{-1}}

Rendering

$$H(z)=\frac{1}{1-\alpha z^{-1}}$$

Frequency Response

H(e^{j\omega T})=\frac{1}{1-\alpha e^{-j\omega T}}

Rendering

$$H(e^{j\omega T})=\frac{1}{1-\alpha e^{-j\omega T}}$$

M-Point Moving Average Filter

Frequency Response

H[f]=\frac{sin(\pi f M)}{M sin(\pi f)} \: for \: 0 < f \leqslant 0.5

Rendering

$$H[f]=\frac{sin(\pi f M)}{M sin(\pi f)} \: for \: 0 < f \leqslant 0.5$$


Notes

To align equations with the equals sign, embed in the following blocks, use "&=" for the alignment and separate each line by ending with " \\".

\begin{equation*}
\begin{align*}


\end{align*}
\end{equation*}

VSCode doesn't support equation numbering auto increment and Colab doesn't support "equation*" or "aligned*" for disabling equation numbers. Colab requires "aligned" not "align".

Latex References


Tuesday 21 June 2022

DSP Tech Brief : Notes On Notch Filtering - IIR vs. FIR

 A very simple way to implement a notch filter is to use and FIR filter and place a conjugate pair of zeros on the unit circle to define the location of the notch, as shown in the following z-Domain diagram:


Testing this filter in the application showed that while the initial results were good, because the interference was removed, there was a subtle negative impact on the performance of the signal processing functions further down the chain.

On investigation, the cause of this performance degradation turned out to be due to the FIR filter implementation not resulting in equal signal magnitudes in the pass-bands either side of the notch.

This can be clearly seen in the following diagram, where we have a sample rate of 16 kHz and a notch at 2 kHz.


Swapping the FIR filter for a single IIR biquad filter solved the problem and the IIR filter frequency response is shown below:


Functions for designing both FIR and IIR notch filters are included in the Numerix-DSP SigLib DSP and ML library, which can be downloaded from here: https://github.com/Numerix-DSP/siglib.

Sunday 23 January 2022

Analog I/O Example For The NXP LPC55S69-EVK

 I recently wrote some DSP code for the excellent NXP LPC55S69-EVK.

The standard audio I/O example for the LPC55S69-EVK implements a very simple piece of code to read in an array of audio data from the stereo codec and then write it back. It does not show how to access that data or process it using background DSP functions.

I have written an example that uses interrupts, ping-pong buffers and background tasks to apply DSP functions to the real-time audio datastream.

The example can be downloaded from: https://github.com/Numerix-DSP/embedded_projects


Version 10.00 Of The SigLib DSP Library Released And Is Now Fully Open Source

SigLib V10 now includes enhanced functions for training and inferring Artificial Intelligence and Machine Learning Convolutional Neural Networks (CNNs). In addition to the traditional DSP functions, the SigLib ML functions are designed for embedded applications such as vibration monitoring etc. They are architected for Edge-AI applications and have been written for the highest level of MIPS and memory optimization.

Containing over 1000 DSP and ML functions, SigLib is now available with a dual open source (GPL) and commercial license and is available from GitHub at: https://github.com/Numerix-DSP/siglib.