This is only a preview of the November 2025 issue of Practical Electronics. You can view 0 of the 80 pages in the full issue. Articles in this series:
Items relevant to "3D Printer Filament Drying Chamber, Part 2":
Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
|
Circuit Surgery
Regular clinic by Ian Bell
Measuring the frequency response of a circuit
or device using a PC sound card, part 2
L
ast month, we started discussing how to measure the
frequency response of a circuit or
device. This was motivated by the need
to measure the response of the example
digital filter from the recent DSP series,
recognising that not all readers will have
test lab equipment capable of this.
The alternative is to use the “sound
card” (audio interface) of a computer or
laptop to generate the input signal and
analyse the response using software. Such
programs are mainly aimed at measuring audio systems/acoustics, but can be
applied to circuits acting on signal frequencies in the audio range (20Hz-20kHz).
In the previous article, we mainly focused on the basic principles of circuit
frequency response of linear circuits such
as amplifiers and filters, which we will
recap briefly below. We also introduced
use of PC sound cards to make measurements, concluding with a test set-up like
that shown in Fig.1.
Here, we see one stereo channel used for
measurements and the other for reference,
but other configurations are possible.
Audio interfaces are limited compared
to lab test gear in that they only generate
and measure AC over a limited amplitude
range. Therefore, the I/O signal levels,
DC offsets and load drive capabilities for
the device under test and sound card I/O
may not be compatible. This may require
signal conditioning circuits at either or
both the input and output of the device,
as shown in Fig.1.
That figure includes an audio amplifier that could be used to listen to the
test signal. It can also be used to listen
to the output from the circuit under
test (connected in parallel to the sound
card line input). I have used a switch
set-up to enable easy comparison of the
two signals.
If you do set up the capability to listen
to test signals, be careful and keep volume
levels low. Test signals are not pleasant
to listen to and have more potential to
damage your speakers or even your ears
than standard audio recordings.
44
A recap of the key concepts
signals and transfer functions can be
represented with a Cartesian format
using complex numbers, which facilitates mathematical circuit analysis. Still,
this advanced maths is not essential
knowledge for basic frequency response
measurement.
To measure a frequency response, we
can apply a sinewave input, wait for the
circuit to stabilise (steady state approximation), measure the input and output
amplitude and phase difference, then
repeat for as many frequencies as required. This is straightforward, can be
implemented manually (with a signal
generator and dual channel oscilloscope),
but is relatively slow.
Alternatively, other inputs, such as
sinusoids that are swept continuously
in frequency, or various types of wideband noise, can be used. The frequency
response results are obtained by mathematical analysis of the measured
For a linear circuit with input X and
output Y, we write Y(f ) = H(f )X(f ), where
H is the transfer function – the relationship between the input and output of a
circuit. The signals and transfer function
vary with the frequency, f. The term “frequency response” often refers to graphs
showing how the transfer function H(f )
varies with frequency.
Each point on the graph represents a
single frequency, which implies a steady
state (infinite duration) sinusoidal input,
and linearity implies a sinusoidal output.
At each frequency, the output waveform
may be shifted in time and may have a
different amplitude with respect to the
input.
The time shift is usually expressed as
phase shift – the proportion of the cycle
time (⅟f ) of the waveform at the frequency of interest (f ), typically in degrees.
The fact that two aspects change from
input to output (amplitude and phase)
means that H at a given frequency cannot
be represented by a single
number.
We can use the polar form of
gain magnitude/phase angle,
which is what is shown on
the Bode plot. Alternatively,
PC
Sound
card
R Optional audio
L amplifier
In
Line R
out L
Out
Loopback
connection
Line L
in
R
USB
Input signal
conditioning
In
Device under test
Out
USB
In
Output signal
Out conditioning
Fig.1: one possible setup
for using a sound card to
measure circuit behaviour. Possible USB connection – eg, for MCU dev board
Practical Electronics | November | 2025
response; for example, using a fast Fourier transform (FFT), rather than simple
individual measurements.
In this case, the instrument or app
does the maths for you to calculate and
present the results. Still, some understanding of the theory will help when
choosing settings/preferences and interpreting the results.
An introduction to REW
Prior to writing these articles, I had not
made extensive use of sound card apps
for circuit measurement, so this article
covers my experience and experiments
so far. I have tried a few programs, but
have spent most time using one called
Room EQ Wizard (REW), so it will be the
focus of this article.
I cannot claim to be a REW expert, but I
have obtained some useful results. I may
look at other features and other apps in
the future.
REW is aimed at room acoustic measurement, loudspeaker measurement and
audio device measurement. For example,
to help optimise the acoustics of a listening room, studio or home theatre and
find the best locations for speakers, subwoofers and listening positions. Having
said that, its use for electronics is recognised by the developer.
Some of its extensive measurement
capabilities, including for frequency
response and distortion, are useful for
circuits via a setup such as the one
shown in Fig.1. Others, such as reverberation time (RT60) are more specifically
acoustics-related.
REW is available as a free download
from www.roomeqwizard.com for Windows, macOS and Linux. I have only
used the Windows version. REW is supported by donations, but there is also pro
upgrade available for a one-time fee that
provides multiple-input measurement
capabilities. At the time of writing, the
current version is 5.31 (released in 2024).
REW was created by John Mulcahy over
twenty years ago, and he has continued
to develop it since then. Originally, REW
was mainly focused on setting up equalisers, but its measurement capabilities
have been extended over the years. It is
still under development, with various
beta releases of version 5.40 published
over recent months.
If I understand it correctly, a key new
feature in this future version is an application programming interface (API)
which will, for example, allow advanced
users to integrate their own code with
REW, to make use of its measurement
or calculation capabilities.
REW is a complex piece of software
with many features, settings and capabilities. As such, it may present a steep
learning curve for new users. However,
Practical Electronics | November | 2025
it has comprehensive documentation (in
the program, via tooltips and online),
which provides a good introduction to
getting started and using the software.
This seems to reflect a philosophy of
making software suitable for both enthusiasts and professionals (indeed, it is used
by both). The main preferences dialogs
include help text in the window, which
means you don’t have to search separately to find out what the settings do.
There is also an active support forum
on the AV Nirvana website (https://pemag.
au/link/ac8k).
It is recommended that new users read
the first few sections of the help before
jumping to more specific details. I will
cover some key points here to provide an
overview of REW’s relevant capabilities,
and explain how I used REW for circuit
measurements. Of course, I will not fully
describe all aspects of the software.
Different information may apply to different computers, operating systems and
audio interfaces, so you may need some
details which were not relevant to me.
Units and levels
Various units of measurement will be
encountered in REW (and other software and instruments making similar
measurements), so it is worth defining
what these mean before proceeding with
discussing its use.
For testing circuits, we also need to
be aware of the voltage levels of audio
interface I/O, as this will determine
compatibility with the device under test
(DUT) and the design of any signal conditioning circuitry.
Signal levels in audio and acoustics
are commonly expressed using decibels
(dB); for example, in dBV or dBu units.
Decibels express the ratio of two numbers,
which is straightforward for gain, where
we have an input and output level; for
example, gain (in dB) = 20log10(vout/vin).
For signals in isolation, we need to use
a reference level to express the value in
decibel form. For example, for a voltage
signal, vS, we need a reference level of v0.
The decibel value for the signal is then
20log10(vS/v0). For power (p) measurements, the decibel value is 10log10(pS/
p0). If the signal value equals the reference, the level is 0dB.
Consumer audio line levels are typically
about 0.316V RMS (root-mean-square),
which is 0.447V peak (0.316V × √2) or
0.894V peak-to-peak (0.447V × 2) for a
pure sinewave signal. A signal of 0.316V
RMS can be expressed as -10dBV – that
is, minus ten decibels relative to a reference level of 1V RMS. For an RMS signal
voltage of vS, the dBV value is 20log10(vS).
In early audio systems, connections
were made using matched 600Ω input
and output impedances, which was based
on the practice in early telephony systems. The reference level used here was
based on the voltage required to deliver
1mW of power to a 600Ω load, which is
0.775V RMS (V2 ÷ R = 0.775V2 ÷ 600Ω
= 0.001W).
Voltage values referenced to 0.775V
are expressed as dBu, where the u is for
“unloaded”, as modern audio systems
do not use 600Ω matched loads, but the
reference level has persisted in common
usage. dBV and dBu reference levels differ
by a factor of 0.775 (multiply or divide
as appropriate).
Due to the log function, this translates
to an addition or subtraction of decibel values, specifically of 2.21dB, as
20log10(0.775) = -2.21. So, we have dBu =
dBV + 2.21dB and dBV = dBu – 2.21dB.
Signal power can be expressed in dBm,
that is, decibels relative to one milliwatt
(1mW). If we are measuring voltages, we
need to know (or assume) the load resistance the voltage is driving to calculate
the power value.
Professional audio systems typically
use higher voltages than consumer ones,
with a nominal level of +4dBu (1.228V
RMS, 1.736V peak for a sinewave). In
both cases, there can be variation in levels
between different products. Sound card
outputs are often designed to be used as
headphone outputs, so they may differ
from standard line outputs.
Full-scale levels
All signal processing systems have maximum input and output levels at which
signal integrity is maintained. This is
often slightly ‘soft’ – close to maximum,
the signal quality will tend to decrease
as distortion increases before a full limit
(hard clipping) is reached.
For ADCs and DACs, there is a very
specific hard limit set by the maximum
numerical value that can be represented
in the conversion – the full-scale (FS)
value. Ideally, the analog circuitry associated with such a converter will not
be too close to its limits at the converter
full-scale, so the system as a whole will
have a simple hard limit at the converter’s full-scale value.
This full-scale value can be used as a
reference for a decibel full-scale unit, denoted dBFS. dBFS is useful because we
can immediately see how much headroom
we have available to increase signal levels
(eg, for a better signal-to-noise ratio), or
cope with the highest input levels (eg,
due to resonant peaks) without causing
clipping in the measurement system.
Measurements in dBFS cannot be converted to other units using a generally
applicable formula because the reference
level depends on the specific hardware
used and settings such as volume or
gain controls. However, for a given setup
45
Fig.2: the Room EQ Wizard (REW) toolbar.
Fig.4: the Room EQ Wizard (REW) oscilloscope.
Fig.5: the Room EQ Wizard (REW) real-time spectrum analyser (RTA).
46
Practical Electronics | November | 2025
where the full-scale voltage is known,
the conversion to or from other units is
straightforward.
REW makes use of dBFS values and
has the means to calibrate the reference
value (define the full-scale voltages). For
frequency response plots, it can use the
relative input to output dBFS levels to
plot transfer functions (denoted as dBr),
or the voltage levels (V/V in dB).
Tools and measurements
When REW opens, it presents a set of
toolbar buttons (Fig.2) above a largely
blank window containing a welcome message. The black area is used for response
measurement graphs once these have
been made or loaded from saved data.
The Measure button opens a window
that allows you to configure and run
a frequency response measurement.
However, before doing so, you need
to set up the computer correctly and,
using the preferences window (rightmost button), configure REW’s use of
your audio interface(s) and then run a
sound card calibration. We will look at
this in more detail below.
REW features various tools including
a signal generator (Fig.3), oscilloscope
(Fig.4), and real-time spectrum analyser
(RTA) – see Fig.5. These are launched
using the toolbar buttons and can be used
independently of frequency response
measurements. They are useful in their
own right for work with circuits, subject
to the limitations (discussed last month)
that are imposed by using sound cards
for measurements.
The signal generator shown in Fig.3 is
configured to produce a 1kHz sinewave
0.5dB below the full-scale output level.
The tabs in the top part of the window
indicate the range of other signal types
that can be generated. The signal level
can be set using dBu, dBV, volts (RMS) or
dBFS units. Calibration is required to set
the output voltage accurately (see below).
The “Lock frequency to RTA FFT”
box, which is checked in Fig.3, means
the frequency is adjusted to the nearest
FFT bin centre for the spectrum analyser (RTA), which improves spectral
resolution, but restricts the frequencies
to specific values based on the FFT. For
example, the actual output with the setting shown in Fig.3 will be 999.76Hz,
not 1kHz. This is handy when using the
spectrum analyser.
The “Add dither” option adds 2 LSB
variations in the output signal, which
helps to remove quantisation noise from
distortion measurements. This is useful
for analysing electronics, rather than
acoustics, where other noise dominates.
The lock frequency and dither controls just mentioned give some insight
into the comprehensive and complex
Practical Electronics | November | 2025
Fig.3: the Room EQ Wizard (REW) signal generator controls.
nature of REW. The number of options
and settings may seem daunting to new
users, particularly if the terminology
and related theory are not very familiar. However, REW’s documentation is
very good, and clearly explains things
such as when various options are appropriate to use.
The two input channel Scope tool
(Fig.4) provides the basic functionality
and controls you would expect from an
oscilloscope, including measurement
cursors and some maths functions.
The spectrum analyser will show the
spectrum of any input signal, but is particularly useful in conjunction with the
signal generator. The example in Fig.5
shows a 1kHz (actually 999.7Hz FFTlocked) sinewave.
The harmonics (distortion components)
are labelled 2, 3 etc. A distortion analysis is shown at upper left. A peak can be
seen at the mains frequency (50Hz); the
other parts of the spectrum are noise.
Frequency response in REW
REW makes frequency response measurements using a logarithmically swept
sinusoidal signal which, as noted earlier,
is faster than a stepped sine approach. The
input sweep and response are processed
using an FFT and compared to obtain the
transfer function and impulse response,
from which other measurements, such
as distortion, can be derived.
It can also use stepped sines for distortion measurements via the RTA, an
approach which is slower but more accurate at lower distortion levels.
REW uses one audio I/O channel for
primary measurements (the default is
the right stereo channel, as in Fig.1). The
other input does not have to be used, but
can be looped back (as in Fig.1), where
REW can use it as a timing reference to
compensate for delays in the sound card
and operating system.
The sound card itself may not have a
perfectly flat frequency (gain) response,
47
Getting Started with the B-L475E-IOT01A1
We were contacted by a reader who asked for more detail on configuring the
development board used in the article last month.
We did not provide a detailed account of getting started using the SMT32 ecosystem in the articles because there are a number of online resources on this
(video and text), one of which we referenced in the June 2025 issue. Typically,
these describe ‘blinky’ projects that flash LEDs.
However, STM32 may be more challenging to get started in than some other
systems, like Arduino, so we will provide a few extra notes here.
The configuration of the board should not be a problem because the STM32CubeIDE app does the work for you. You can start a new project for a specific
board and all code to configure the MCU to use that board will be automatically
written for you. You start with a working project that has no specific function.
One potential problem is that the online examples refer to various boards, so
you may have to use a different pin to control the LED, but much of the general
content of these examples will be applicable. DigiKey provides a ‘blinky’ example at https://pemag.au/link/ac8l
As is typical, this uses a different board, but the changes needed are minimal.
During project creation, search for the board we used (B-L475E-IOT01A1) in the
Target Selector, not the one in their example. The main code is in Core → Src →
main.c (not just Src → Main) This difference is probably because the example
uses an old software version.
The B-L475E-IOT01A1 has two LEDs, so you have a choice of which one to
flash. One option is to click the PA5 pin in the CubeMX view and select GPIO_
Output (the default is SPI clock) and save the .ioc file.
Alternatively, use LED2, which is configured for use by default on the BL475E-IOT01A1. You don’t need to save the .ioc file (“Save” will be greyed out
unless you change something, but it is not needed in here). Use “HAL_GPIO_
TogglePin(GPIOB, GPIO_PIN_14);” to toggle the LED instead of the code in the
example.
When looking at the autogenerated main code, you will see there are more peripheral initialisation calls, as the B-L475E-IOT01A1 board has more features.
After that, create new projects in the same way (with the default configuration),
then follow the configuration changes described in the articles. No changes to
the board hardware are required.
but REW can compensate for this using
a measurement made with a direct connection between the input and output.
This could also be used to compensate
for the frequency response of any conditioning circuits, which should also
ideally have a flat response.
Setting it up
REW obviously needs control of your
sound card, so it is best not to have any
other audio/media programs running,
or have any media playing in a browser
when you start REW or one of its tools.
On the other hand, you can play media
on the PC and observe the audio waveform on the REW scope via a loop-back
connection or your device under test.
To get the best results, the REW
instructions recommend not simultaneously running any other apps or
processes with high processor demand,
disconnecting from the internet and
switching off wireless networking (to
reduce interference).
I tried a few quick experiments while
running a real-time spectral analysis and
observed significant (temporary) disruption to the measurement when switching
Bluetooth on and off and launching a demanding program. If this occurred during
48
a frequency response measurement, it
would likely invalidate it.
Therefore, it makes sense to keep the
PC doing as little additional activity
as possible when making important
measurements.
Sound card drivers (or the operating
system) may provide audio processing
with the aim of enhancing your music listening or gaming experience or applying
processing, such as noise cancellation on
inputs. These features need to be switched
off while making measurements.
For example, in Windows settings
(System → Sound → Properties), for the
selected output device (eg, Speakers/Line
Out), there may be options such as “Audio
Enhancements” or “Spatial Sound” under
“Advanced Settings”, which need to be
deselected. You probably also need to
set the “Allow applications to take exclusive control of this device” option
selected in the Windows audio properties for the device.
The sound card manufacturer may also
provide utilities/apps for interface control
and/or sound processing as part of the
driver install or as separately installed
apps. You may also need to use these
make sure that all processing is off and
the I/O connector settings are configured
correctly (for example, the jack socket
is set to be a line input rather than side
speaker outputs) and to control settings
like sampling rates.
Some audio interfaces will attempt
to automatically change their configuration when devices are plugged in (eg,
in response to headphone impedances
on output connections), so it is a good
idea to first plug in the leads you will
use for measurement and then check the
all the sound settings are correct. If possible, switch off auto-detection before
adjusting settings for measurement work.
Sound card preferences
REW can use all the audio I/O interfaces that it detects on the computer, and
you need to select the appropriate ones
and which channels to use (eg, stereo left
or right) for input and loop-back. This
is done via the REW Soundcard Preferences window (Edit → Preferences →
Soundcard).
You also need to select the driver to
use (Java or ASIO) and the sampling rate,
which must match the setting in the operating system. There are various other
settings in the Soundcard Preferences,
and you should read the REW help page
on this, which has detailed instructions
and advice on how to configure things.
REW supports a range of sampling frequencies depending on the sound card.
As discussed in depth in the recent
DSP series, the maximum frequency
that can be measured is half the sample
rate (the Nyquist frequency). The sound
card should have an anti-aliasing filter,
but is still better to avoid using signals
with content above this value during
measurements.
The instructions recommend using
44.1kHz or 48kHz for acoustic measurements, assuming a 20kHz upper
frequency requirement, as higher rates
do not improve the results. Higher sampling rates are more demanding (memory
and processing), but are required for results at higher frequencies.
Signal levels and calibration
As mentioned above, the sound card
will have a maximum input voltage it
can handle without clipping – this is the
full-scale (FS) value of its ADC. Full-scale
would be expected to occur at an equal
magnitude for positive and negative excursions of the AC signal. The specific
full-scale voltage will vary for different
sound cards, but will typically be in the
order of a volt for line inputs.
As discussed last month, clipping must
be avoided when making frequency response measurements. It can occur in
the external circuitry or the sound card.
Clipping in the sound card will be detected by REW, and notification can be
Practical Electronics | November | 2025
From soundcard
line output
Buffer
Device
under test
Out
Gain
0 to 3
Buffer
Audio line
driver
GainOut
0 to 0.5
Out 2
Gain
To soundcard
line input
Fig.6: a block diagram of my signal conditioning circuitry for testing the DSP filter.
provided to the user. Measurements can be
automatically stopped if clipping occurs.
REW will not detect clipping in the
device under test or signal conditioning circuits if the sound card input does
not reach full-scale, so care must be
taken to avoid this. The signal generator and scope tools can be used before
a frequency response measurement to
check for clipping or other problems in
the circuitry.
The output of the sound card will also
have a full-scale output voltage, which
will depend on the output volume control setting and possibly other settings.
We can calibrate the signal generator
and input so that the numerical values of
voltages set and measured by REW are accurate. After calibration, REW will display
the full-scale output voltage in the signal
generator window (Fig.3) and full-scale
input voltage in the RTA window (Fig.4).
The full-scale input voltage is also
shown in the scope channel setup dialog,
via clicking the leftmost of the three
cog icons, near the “CH1-CH2” button
– see Fig.4.
To calibrate REW, you need a DMM,
audio millivoltmeter or oscilloscope capable of measuring AC RMS voltages at
around the 1V level. A basic meter that’s
accurate at mains frequencies is sufficient.
I/O voltage calibration
After dealing with the operating system
settings and REW preferences, proceed
as follows.
1) Connect the sound card line input
directly to the line output (loop-back in
both channels) with a connection that
allows you to measure the signal voltage between the ground and signal lines
of the output.
I used two audio cables with one connector cut off and the signal and ground
(shield) wires soldered to male jumper
wires which could easily be plugged into
a solderless breadboard or pin headers,
but you could also use a splitter cable
and clip the meter to a jack plug or other
connector.
2) Set the volume control to an output
to a low level using the operating system
control. Set the stereo balance to centre.
The input (recording) volume in the
operating system can probably be set
at maximum, but it may depend on the
specific setup. If the interface input has
a physical gain control (more likely with
an external USB unit), this may also need
adjusting as part of the process.
Practical Electronics | November | 2025
4) Run the signal generator, scope and
RTA tools in REW, with the signal generator producing a sinewave on both
channels (L+R) at a frequency the meter
can accurately measure. Fig.3 shows the
signal generator configured for a 1kHz
sinewave, which was fine for the true
RMS meter I was using, but other frequencies can be used.
5) Set up the scope to show both channels (Right and Left) with the voltage scale
set so that the full-scale lines are visible.
The scope display in Fig.4 shows the
input (blue) and output (yellow) waveforms and the full-scale levels (dotted
horizontal lines) with signal levels just
below full-scale.
6) Set the generator signal level to
0.00dBFS and adjust the system output/
main volume until the signal amplitude
on the scope is just below clipping. That
is, if you increase the volume just above
this value, you will see the clipped waveforms on the scope.
The volume control may not provide
very fine steps, so it may not be possible to set the output exactly equal to the
full-scale input – use the highest value
with no clipping.
Measure the signal level with the meter
and enter this as a calibration level in the
signal generator and RTA via their “Calibrate level” buttons (see Figs.3 & 5). The
signal does not have to be at full-scale
when doing this – REW will calculate
the full-scale values from the current
output level setting and input level of
the sound card’s ADC.
If you change the output level in the
signal generator, the meter reading should
change to match the new setting, and
the RTA and scope should show this
accurately. You can switch the generator output level units and RTA y-axis
to volts to make it easier to check this.
Once the full-scale calibration is complete, do not change any of the computer
or audio interface volume or gain settings.
Conditioning circuit design
Fig.6 shows a block diagram of the circuitry used for the DSP filter frequency
Input
Protection
and DC shift
Out
response measurement. Of course, this
can also be used directly for other circuits
under test or adjusted to match different
voltage range requirements.
The circuit was designed to provide
unity gain from input to output in the
audio range, with the possibility to make
gain adjustments to fine-tune the signal
levels. It was constructed on a solderless
breadboard to facilitate experimentation
and development. There isn’t enough
space to cover all the details of the circuit
in this article, so we will just provide an
overview here.
The first buffer AC-couples the output
from the sound card, provides a variable
gain of up to three times (adjusted with
a trimmer potentiometer), and has highfrequency roll-off (at around 250kHz) to
help remove any RF signals that might
be picked up at the input.
With the sound card I was using, the
maximum (just below full-scale) output
from the sound card was 0.431V RMS,
which is 1.22V peak-to-peak for a sinewave. The same value applies to a
unity-gain circuit. For testing the DSP
filter, the signal needs to be amplified
to around 3.2V peak-to-peak (just under
the microcontroller’s ADC’s 3.3V input
range), which is 1.13V RMS.
A gain of 2.6 times (3.2 ÷ 1.22) is required, hence the buffer’s maximum
gain of 3 times.
As described in the DSP series (August
& September 2025 issues), the MCU
digital filter implementation includes
a protection circuit, AC-coupling and
DC shift to bias the input to 1.65V (half
the 3.3V supply). This is included in
the DUT block in Fig.6, along with a
reconstruction filter at the MCU DAC’s
output (Fig.7).
No anti-aliasing filter was used at the
MCU’s ADC input because the frequency response test would not be applying
signals with content beyond the Nyquist limit.
The reconstruction filter used was a
fourth-order low-pass op amp based circuit with a 20kHz cutoff, not the simple
RC filter from the previous basic test
SMT32 MCU Dev
ADC in Board implementing DAC out
DSP filter
USB
PC USB for power,
programming and debug
4th-order
20kHz lowpass filter
Out
Output
Fig.7: the connections for
testing the DSP filter.
49
Fig.8: REW’s calibration measurement for my sound card (16 bits, 192kHz sampling rate).
Fig.9: REW’s measurement progress display.
further details on the “Getting set up for
measuring” help page.
It is suggested that REW output
volume and sweep level settings (in
Preferences) of 0.5 and -12dB to -6dB
are used, respectively, but this is aimed
at acoustic measurement. I tried various options, checking the frequency
response and distortion graphs, and
got good results with settings of 1.0
and -1.0dB, respectively.
An example sound card calibration
measurement is shown in Fig.8. A key
aspect is that it is flat over the 20Hz to
20kHz range.
After calibration, you need to save the
results to a calibration (.cal) file via the
“Make a cal file…” button in the preferences window (you are reminded to
do this). You can have as many of these
calibration files as you want, selecting
the relevant one when you make a measurement. The calibration also appears
like a regular measurement, with various graphs available to view.
The frequency response (as in Fig.8) is
referred to as “SPL and phase” in the set
of buttons for selecting which graphs to
view, and is displayed by default. SPL is
sound pressure level and reflects REW’s
primary use. REW also uses microphone
calibration files, which relate to SPL
meters, so are not needed for electronic
circuit measurements.
Any measurements, including those
used for calibration, can be saved to a file
and opened again in REW later. This is
a different file type (.mdat) for the calibration file. Measurements are saved
separately, via the list of measurements
in the main REW window.
Making measurements
Fig.10: a plot of an RC low-pass filter response measured using REW.
(September 2025). This means the reconstruction filter gain is flat throughout
most of the stop-band up to the near DSP
filter’s Nyquist limit of 24kHz.
The RC filter was fine for quickly checking with an oscilloscope that the cutoff
of the DSP filter looked about right, but
would have had a significant effect on
the overall frequency response if used
in this measurement.
The DSP filter and reconstruction filter
have unity gain in the passband, so the
output of 3.2V peak-to-peak needs attenuating back to 1.22V peak-to-peak for
overall unity gain and to suit the sound
card’s maximum input level.
The output from the device under test
goes to a second variable gain buffer and
then to an audio line driver. The audio
50
line driver is more capable of driving
capacitive loads and long cables than a
typical op amp, and can drive both single-
ended and balanced inputs.
The line driver has a gain of about two
times, which needs to be taken into account in the attenuation provided by the
buffer. A gain of about 0.19 is required
(1.22 ÷ 3.2 ÷ 2).
Sound card calibration
REW can measure the frequency response of a sound card and use this to
compensate for any variations in sound
card gain when making measurements.
This is done via the “Calibrate sound
card” button in the Preferences window.
There are step-by-step instructions provided after you click the button and
Measurements are made via the “Make
a measurement” window after clicking
the Measure toolbar button. There are a
lot of settings and options, but the documentation explains these in detail, so
we just give a brief outline here.
The measurement type needs to be
SPL for a frequency response. You can
give the measurement a name and type
in notes if you want.
Key things to set are the frequency
range and the output level. A level of
0dBFS should be OK with a unity-gain
circuit without resonant peaks, but a
slightly lower level may give better distortion performance. There is an option
to abort the measurement if clipping
occurs, which should usually be left on.
There is a setting for sweep length
(the number of sample points). Longer
sweeps provide better signal-to-noise
ratios in measurements and are suited
to use with electronics (the help advises against their use with loudspeakers).
The longest option (4M points) was
Practical Electronics | November | 2025
www.poscope.com/epe
Fig.11: the frequency response of the example digital filter as measured by REW.
- USB
- Ethernet
- Web server
- Modbus
- CNC (Mach3/4)
- IO
- PWM
- Encoders
- LCD
- Analog inputs
- Compact PLC
Fig.12: an LTspice simulation plotting the expected response of the digital filter.
used for the measurements here. You
can also run multiple sweeps and average the results.
You can set some sound card options,
but these should already be as required
as they are based on the Preferences settings. You can select the calibration file
to use, with the default being the last
one created.
Once you are happy with the settings, click the Start button to make the
measurement. REW will show the measurement progress via a small rolling
graph of the measurement and information on the remaining number of sweeps
and time (Fig.9). It also shows the headroom in decibels below full-scale for the
largest reading so far.
After the measurement, REW may
give a warning if the levels were excessively low, if clipping was detected, or
high levels of distortion were present.
Measurement results
Before attempting to measure the DSP
filter, I tried a simple RC low-pass circuit as the device under test (as in Fig.6).
This used a 330nF capacitor and a 390Ω
resistor. The cutoff (-3dB) frequency for
this circuit is 1.24kHz; 1 ÷ 2πRC = 1 ÷
Practical Electronics | November | 2025
(2 ⸳ π ⸳ 390Ω ⸳ 330F ⸳ 10-9). Using measured values of the components (347nF
and 386Ω), a cutoff of 1.19kHz would
be expected. The results are shown in
Fig.10. Using the cursors available on
the results graph in REW, the cutoff was
1.20kHz, which is within 1% of the expected value.
I moved on to measuring the digital
filter using the circuits shown in Figs.6
& 7. The filter configuration was a 1kHz
low-pass windowed sinc, with 37 coefficients, a 48kHz sampling rate, and a
rectangular window running on the BL475E-IOT01A1 STM32 development
board, as described in recent articles.
The results are shown in Fig.11. Fig.12
shows an LTspice simulation of the same
filter using the approach described in
detail earlier in the DSP series. Comparison of the two graphs shows a good
match, and confirms that the filter implementation is working correctly, and
that REW is a useful tool for making
such measurements.
Coming up
Next month, we will continue to explore this topic, focusing on the signal
PE
conditioning circuitry.
- up to 256
- up to 32
microsteps
microsteps
- 50 V / 6 A
- 30 V / 2.5 A
- USB configuration
- Isolated
PoScope Mega1+
PoScope Mega50
- up to 50MS/s
- resolution up to 12bit
- Lowest power consumption
- Smallest and lightest
- 7 in 1: Oscilloscope, FFT, X/Y,
Recorder, Logic Analyzer, Protocol
decoder, Signal generator
51
|