Neil Robertson Blog on DSPRelated.com
https://www.dsprelated.com/blogs-1/nf/Neil_Robertson.php
Neil Robertson Blog on DSPRelated.com
https://www.dsprelated.com/blogs-1/nf/Neil_Robertson.php
https://d23s79tivgl8me.cloudfront.net/user/profilepictures/113580.jpgen-USTue, 03 Aug 2021 11:36:16 +00001627990576Digital Filter Instructions from IKEA?
https://www.dsprelated.com/showarticle/1404.php

Swedish “Bygglek” = build and play. Swedish “Bygglek” = build and play.

Swedish “Bygglek” = build and play. Swedish “Bygglek” = build and play.

Swedish “Bygglek” = build and play. Swedish “Bygglek” = build and play.

Swedish “Bygglek” = build and play. Swedish “Bygglek” = build and...]]>
Fri, 18 Jun 2021 17:58:51 +0000Neil RobertsonSetting Carrier to Noise Ratio in Simulations
https://www.dsprelated.com/showarticle/1398.php
When simulating digital receivers, we often want to check performance with added Gaussian noise. In this article, I’ll derive the simple equations for the rms noise level needed to produce a desired carrier to noise ratio (CNR or C/N). I also provide a short Matlab function to generate a noise vector of the desired level for a given signal vector.

Definition of C/N

The...]]>
Sun, 11 Apr 2021 15:12:57 +0000Neil RobertsonAdd a Power Marker to a Power Spectral Density (PSD) Plot
https://www.dsprelated.com/showarticle/1387.php
Perhaps we should call most Power Spectral Density (PSD) calculations relative PSD, because usually we don’t have to worry about absolute power levels. However, for cases (e.g., measurements or simulations) where we are concerned with absolute power, it would be nice to be able to display it on a PSD plot. Unfortunately, you can’t read the power directly from the plot. ...]]>Sun, 07 Feb 2021 15:25:26 +0000Neil RobertsonFind Aliased ADC or DAC Harmonics (with animation)
https://www.dsprelated.com/showarticle/1380.php
When a sinewave is applied to a data converter (ADC or DAC), device nonlinearities produce harmonics. If a harmonic frequency is greater than the Nyquist frequency, the harmonic appears as an alias. In this case, it is not at once obvious if a given spur is a harmonic, and if so, its order. In this article, we’ll present Matlab code to simulate the data converter...]]>Mon, 11 Jan 2021 18:12:36 +0000Neil RobertsonCompute Images/Aliases of CIC Interpolators/Decimators
https://www.dsprelated.com/showarticle/1375.php
Cascade-Integrator-Comb (CIC) filters are efficient fixed-point interpolators or decimators. For these filters, all coefficients are equal to 1, and there are no multipliers. They are typically used when a large change in sample rate is needed. This article provides two very simple Matlab functions that can be used to compute the spectral images of CIC interpolators and...]]>Sun, 01 Nov 2020 17:50:34 +0000Neil RobertsonDesign Square-Root Nyquist Filters
https://www.dsprelated.com/showarticle/1361.php
In his book on multirate signal processing, harris presents a nifty technique for designing square-root Nyquist FIR filters with good stopband attenuation [1]. In this post, I describe the method and provide a Matlab function for designing the filters. You can find a Matlab function by harris for designing the filters at [2].

Background

Single-carrier modulation, such as QAM,...]]>
Mon, 13 Jul 2020 18:20:47 +0000Neil RobertsonThird-Order Distortion of a Digitally-Modulated Signal
https://www.dsprelated.com/showarticle/1355.php

In the following analysis, we assume that signal phase at the amplifier output is not a function of amplitude. With this assumption, the output y of a non-ideal...]]>
Tue, 09 Jun 2020 16:27:59 +0000Neil RobertsonSecond Order Discrete-Time System Demonstration
https://www.dsprelated.com/showarticle/1341.php
Discrete-time systems are remarkable: the time response can be computed from mere difference equations, and the coefficients ai, bi of these equations are also the coefficients of H(z). Here, I try to illustrate this remarkableness by converting a continuous-time second-order system to an approximately equivalent discrete-time system. With a discrete-time model, we can then...]]>Wed, 01 Apr 2020 18:20:59 +0000Neil RobertsonA Simplified Matlab Function for Power Spectral Density
https://www.dsprelated.com/showarticle/1333.php
In an earlier post [1], I showed how to compute power spectral density (PSD) of a discrete-time signal using the Matlab function pwelch [2]. Pwelch is a useful function because it gives the correct output, and it has the option to average multiple Discrete Fourier Transforms (DFTs). However, a typical function call has five arguments, and it can be hard to remember how to set them...]]>Tue, 03 Mar 2020 18:06:17 +0000Neil RobertsonFractional Delay FIR Filters
https://www.dsprelated.com/showarticle/1327.php
Consider the following Finite Impulse Response (FIR) coefficients:

b = [b0 b1 b2 b1 b0]

These coefficients form a 5-tap symmetrical FIR filter having constant group delay [1,2] over 0 to fs/2 of:

D = (ntaps – 1)/2 = 2 samples

For a symmetrical filter with an odd number of taps, the group delay is always an integer number of samples, while for one with an even...]]>
Sun, 09 Feb 2020 20:15:03 +0000Neil RobertsonModel Signal Impairments at Complex Baseband
https://www.dsprelated.com/showarticle/1312.php
In this article, we develop complex-baseband models for several signal impairments: interfering carrier, multipath, phase noise, and Gaussian noise. To provide concrete examples, we’ll apply the impairments to a QAM system. The impairment models are Matlab functions that each use at most seven lines of code. Although our example system is QAM, the models can be used for any...]]>Wed, 11 Dec 2019 15:45:53 +0000Neil RobertsonCompute Modulation Error Ratio (MER) for QAM
https://www.dsprelated.com/showarticle/1305.php
This post defines the Modulation Error Ratio (MER) for QAM signals, and shows how to compute it. As we’ll see, in the absence of impairments other than noise, the MER tracks the signal’s Carrier-to-Noise Ratio (over a limited range). A Matlab script at the end of the PDF version of this post computes MER for a simplified QAM-64 system.

Figure 1 is a simplified block...]]>
Tue, 05 Nov 2019 18:54:37 +0000Neil RobertsonPlotting Discrete-Time Signals
https://www.dsprelated.com/showarticle/1298.php
A discrete-time sinusoid can have frequency up to just shy of half the sample frequency. But if you try to plot the sinusoid, the result is not always recognizable. For example, if you plot a 9 Hz sinusoid sampled at 100 Hz, you get the result shown in the top of Figure 1, which looks like a sine. But if you plot a 35 Hz sinusoid sampled at 100 Hz, you get the bottom graph,...]]>Sun, 15 Sep 2019 15:12:03 +0000Neil RobertsonInterpolation Basics
https://www.dsprelated.com/showarticle/1293.php
This article covers interpolation basics, and provides a numerical example of interpolation of a time signal. Figure 1 illustrates what we mean by interpolation. The top plot shows a continuous time signal, and the middle plot shows a sampled version with sample time Ts. The goal of interpolation is to increase the sample rate such that the new (interpolated) sample...]]>Tue, 20 Aug 2019 20:14:46 +0000Neil RobertsonA Direct Digital Synthesizer with Arbitrary Modulus
https://www.dsprelated.com/showarticle/1275.php
Suppose you have a system with a 10 MHz sample clock, and you want to generate a sampled sinewave at any frequency below 5 MHz on 500 kHz spacing; i.e., 0.5, 1.0, 1.5, … MHz. In other words, f = k*fs/20, where k is an integer and fs is sample frequency. This article shows how to do this using a simple Direct Digital Synthesizer (DDS) with a look-up table that is at most 20...]]>Mon, 03 Jun 2019 20:05:10 +0000Neil RobertsonIIR Bandpass Filters Using Cascaded Biquads
https://www.dsprelated.com/showarticle/1257.php
In an earlier post [1], we implemented lowpass IIR filters using a cascade of second-order IIR filters, or biquads.

This post provides a Matlab function to do the same for Butterworth bandpass IIR filters. Compared to conventional implementations, bandpass filters based on biquads are less sensitive to coefficient quantization [2]. This becomes important when designing...]]>
Sat, 20 Apr 2019 19:18:19 +0000Neil RobertsonDemonstrating the Periodic Spectrum of a Sampled Signal Using the DFT
https://www.dsprelated.com/showarticle/1235.php
One of the basic DSP principles states that a sampled time signal has a periodic spectrum with period equal to the sample rate. The derivation of can be found in textbooks [1,2]. You can also demonstrate this principle numerically using the Discrete Fourier Transform (DFT).

The DFT of the sampled signal x(n) is defined as:

$$X(k)=\sum_{n=0}^{N-1}x(n)e^{-j2\pi kn/N}...]]>
Sat, 09 Mar 2019 19:40:12 +0000Neil RobertsonCompute the Frequency Response of a Multistage Decimator
https://www.dsprelated.com/showarticle/1228.php
Figure 1a shows the block diagram of a decimation-by-8 filter, consisting of a low-pass finite impulse response (FIR) filter followed by downsampling by 8 [1]. A more efficient version is shown in Figure 1b, which uses three cascaded decimate-by-two filters. This implementation has the advantages that only FIR 1 is sampled at the highest sample rate, and the total number of filter...]]>Sun, 10 Feb 2019 20:32:27 +0000Neil RobertsonUse Matlab Function pwelch to Find Power Spectral Density – or Do It Yourself
https://www.dsprelated.com/showarticle/1221.php
In my last post, we saw that finding the spectrum of a signal requires several steps beyond computing the discrete Fourier transform (DFT)[1]. These include windowing the signal, taking the magnitude-squared of the DFT, and computing the vector of frequencies. The Matlab function pwelch [2] performs all these steps, and it also has the option to use DFT averaging to compute the...]]>Sun, 13 Jan 2019 18:18:48 +0000Neil RobertsonEvaluate Window Functions for the Discrete Fourier Transform
https://www.dsprelated.com/showarticle/1211.php
The Discrete Fourier Transform (DFT) operates on a finite length time sequence to compute its spectrum. For a continuous signal like a sinewave, you need to capture a segment of the signal in order to perform the DFT. Usually, you also need to apply a window function to the captured signal before taking the DFT [1 - 3]. There are many different window functions and each...]]>Tue, 18 Dec 2018 20:43:38 +0000Neil RobertsonDesign a DAC sinx/x Corrector
https://www.dsprelated.com/showarticle/1191.php
This post provides a Matlab function that designs linear-phase FIR sinx/x correctors. It includes a table of fixed-point sinx/x corrector coefficients for different DAC frequency ranges.

A sinx/x corrector is a digital (or analog) filter used to compensate for the sinx/x roll-off inherent in the digital to analog conversion process. In DSP math, we treat the digital signal...]]>
Sun, 22 Jul 2018 17:22:49 +0000Neil RobertsonDigital PLL’s, Part 3 – Phase Lock an NCO to an External Clock
https://www.dsprelated.com/showarticle/1177.php
Sometimes you may need to phase-lock a numerically controlled oscillator (NCO) to an external clock that is not related to the system clocks of your ASIC or FPGA. This situation is shown in Figure 1. Assuming your system has an analog-to-digital converter (ADC) available, you can sync to the external clock using the scheme shown in Figure 2. This time-domain PLL model is...]]>Sun, 27 May 2018 18:06:07 +0000Neil RobertsonADC Clock Jitter Model, Part 2 – Random Jitter
https://www.dsprelated.com/showarticle/1160.php
In Part 1, I presented a Matlab function to model an ADC with jitter on the sample clock, and applied it to examples with deterministic jitter. Now we’ll investigate an ADC with random clock jitter, by using a filtered or unfiltered Gaussian sequence as the jitter source. What we are calling jitter can also be called time jitter, phase jitter, or phase noise. It’s...]]>Sun, 22 Apr 2018 17:30:15 +0000Neil RobertsonADC Clock Jitter Model, Part 1 – Deterministic Jitter
https://www.dsprelated.com/showarticle/1157.php
Analog to digital converters (ADC’s) have several imperfections that affect communications signals, including thermal noise, differential nonlinearity, and sample clock jitter [1, 2]. As shown in Figure 1, the ADC has a sample/hold function that is clocked by a sample clock. Jitter on the sample clock causes the sampling instants to vary from the ideal sample time. This...]]>Mon, 16 Apr 2018 17:29:19 +0000Neil RobertsonPhase or Frequency Shifter Using a Hilbert Transformer
https://www.dsprelated.com/showarticle/1147.php
In this article, we’ll describe how to use a Hilbert transformer to make a phase shifter or frequency shifter. In either case, the input is a real signal and the output is a real signal. We’ll use some simple Matlab code to simulate these systems. After that, we’ll go into a little more detail on Hilbert transformer theory and design.

Phase Shifter

A...]]>
Sun, 25 Mar 2018 16:43:41 +0000Neil RobertsonCoefficients of Cascaded Discrete-Time Systems
https://www.dsprelated.com/showarticle/1141.php
In this article, we’ll show how to compute the coefficients that result when you cascade discrete-time systems. With the coefficients in hand, it’s then easy to compute the time or frequency response. The computation presented here can also be used to find coefficients of mixed discrete-time and continuous-time systems, by using a discrete time model of the continuous-time...]]>Sun, 04 Mar 2018 16:08:17 +0000Neil RobertsonDesign IIR Filters Using Cascaded Biquads
https://www.dsprelated.com/showarticle/1137.php
This article shows how to implement a Butterworth IIR lowpass filter as a cascade of second-order IIR filters, or biquads. We’ll derive how to calculate the coefficients of the biquads and do some examples using a Matlab function biquad_synth provided in the Appendix. Although we’ll be designing Butterworth filters, the approach applies to any all-pole lowpass filter...]]>Sun, 11 Feb 2018 21:08:34 +0000Neil RobertsonDesign IIR Highpass Filters
https://www.dsprelated.com/showarticle/1135.php
This post is the fourth in a series of tutorials on IIR Butterworth filter design. So far we covered lowpass [1], bandpass [2], and band-reject [3] filters; now we’ll design highpass filters. The general approach, as before, has six steps:

Find the poles of a lowpass analog prototype filter with Ωc = 1 rad/s.

Given the -3 dB frequency of the digital highpass filter,...]]>
Sat, 03 Feb 2018 16:09:47 +0000Neil RobertsonDesign IIR Band-Reject Filters
https://www.dsprelated.com/showarticle/1131.php
In this post, I show how to design IIR Butterworth band-reject filters, and provide two Matlab functions for band-reject filter synthesis. Earlier posts covered IIR Butterworth lowpass [1] and bandpass [2] filters. Here, the function br_synth1.m designs band-reject filters based on null frequency and upper -3 dB frequency, while br_synth2.m designs them based on lower and upper -3...]]>Wed, 17 Jan 2018 23:54:49 +0000Neil RobertsonDesign IIR Bandpass Filters
https://www.dsprelated.com/showarticle/1128.php
In this post, I present a method to design Butterworth IIR bandpass filters. My previous post [1] covered lowpass IIR filter design, and provided a Matlab function to design them. Here, we’ll do the same thing for IIR bandpass filters, with a Matlab function bp_synth.m. Here is an example function call for a bandpass filter based on a 3rd order lowpass prototype:
N=...]]>Sat, 06 Jan 2018 18:35:44 +0000Neil RobertsonDesign IIR Butterworth Filters Using 12 Lines of Code
https://www.dsprelated.com/showarticle/1119.php
While there are plenty of canned functions to design Butterworth IIR filters [1], it’s instructive and not that complicated to design them from scratch. You can do it in 12 lines of Matlab code. In this article, we’ll create a Matlab function butter_synth.m to design lowpass Butterworth filters of any order. Here is an example function call for a 5th order filter:
N=...]]>Sun, 10 Dec 2017 19:20:56 +0000Neil RobertsonSimplest Calculation of Half-band Filter Coefficients
https://www.dsprelated.com/showarticle/1113.php
Half-band filters are lowpass FIR filters with cut-off frequency of one-quarter of sampling frequency fs and odd symmetry about fs/4 [1]*. And it so happens that almost half of the coefficients are zero. The passband and stopband bandwiths are equal, making these filters useful for decimation-by-2 and interpolation-by-2. Since the zero coefficients make them...]]>Mon, 20 Nov 2017 18:26:41 +0000Neil RobertsonThere's No End to It -- Matlab Code Plots Frequency Response above the Unit Circle
https://www.dsprelated.com/showarticle/1102.php

post I presented Matlab code to synthesize multiplierless FIR filters using Canonic Signed Digit (CSD) coefficients. I included a function dec2csd1.m (repeated here in Appendix A) to convert decimal integers to binary CSD values. Here I want to use that function to illustrate a few properties of CSD numbers.

In a binary signed-digit number system, we allow...]]>
Sat, 18 Feb 2017 16:23:36 +0000Neil RobertsonMatlab Code to Synthesize Multiplierless FIR Filters
https://www.dsprelated.com/showarticle/1011.php
This article presents Matlab code to synthesize multiplierless Finite Impulse Response (FIR) lowpass filters.

A filter coefficient can be represented as a sum of powers of 2. For example, if a coefficient = decimal 5 multiplies input x, the output is $y= 2^2*x + 2^0*x$. The factor of $2^2$ is then implemented with a shift of 2 bits. This method is not efficient for...]]>
Mon, 31 Oct 2016 16:54:27 +0000Neil RobertsonThe Power Spectrum
https://www.dsprelated.com/showarticle/1004.php
Often, when calculating the spectrum of a sampled signal, we are interested in relative powers, and we don’t care about the absolute accuracy of the y axis. However, when the sampled signal represents an analog signal, we sometimes need an accurate picture of the analog signal’s power in the frequency domain. This post shows how to calculate an accurate power...]]>Sat, 08 Oct 2016 21:47:09 +0000Neil RobertsonDigital PLL's -- Part 2
https://www.dsprelated.com/showarticle/973.php
In Part 1, we found the time response of a 2nd order PLL with a proportional + integral (lead-lag) loop filter. Now let’s look at this PLL in the Z-domain [1, 2]. We will find that the response is characterized by a loop natural frequency ωn and damping coefficient ζ.

Having a Z-domain model of the DPLL will allow us to do three things:

Compute the...]]>
Wed, 15 Jun 2016 11:18:41 +0000Neil RobertsonDigital PLL's -- Part 1
https://www.dsprelated.com/showarticle/967.php
Figure 1.1 is a block diagram of a digital PLL (DPLL). The purpose of the DPLL is to lock the phase of a numerically controlled oscillator (NCO) to a reference signal. The loop includes a phase detector to compute phase error and a loop filter to set loop dynamic performance. The output of the loop filter controls the frequency and phase of the NCO,...]]>Tue, 07 Jun 2016 14:34:38 +0000Neil RobertsonPeak to Average Power Ratio and CCDF
https://www.dsprelated.com/showarticle/962.php
Peak to Average Power Ratio (PAPR) is often used to characterize digitally modulated signals. One example application is setting the level of the signal in a digital modulator. Knowing PAPR allows setting the average power to a level that is just low enough to minimize clipping.

However, for a random signal, PAPR is a statistical quantity. We have to ask, what...]]>
Tue, 17 May 2016 18:55:24 +0000Neil RobertsonFilter a Rectangular Pulse with no Ringing
https://www.dsprelated.com/showarticle/956.php
To filter a rectangular pulse without any ringing, there is only one requirement on the filter coefficients: they must all be positive. However, if we want the leading and trailing edge of the pulse to be symmetrical, then the coefficients must be symmetrical. What we are describing is basically a window function.

Consider a rectangular pulse 32 samples long with fs ...]]>
Thu, 12 May 2016 13:53:11 +0000Neil Robertson