This is only a preview of the March 2020 issue of Practical Electronics. You can view 0 of the 80 pages in the full issue. Articles in this series:
|
PIC n’ Mix
Mike Hibbett’s column for PIC project enlightenment and related topics
Audio Spectrum Analyser – design update
W
e change tack this month
and return to our series covering audio spectrum analysis.
In the original series of article on this
subject last year we developed a circuit
design for a low-frequency audio spectrum analyser covering 100Hz – 1kHz.
Evolving from a design for a simple
guitar tuner, this grew into to a fully
fledged audio spectrum display, using
a 2.5-inch colour LCD and a dsPIC33
processor, covering the low end of the
audio range up to 1kHz.
That initial design had some issues
(as all initial designs do) so we return
now to correct those errors and expand
on the functionality.
The first issue to address is that the
original PCB design, as shown in Fig.
1, required some wire straps and two
PCB traces to be cut. These corrected
connection errors to the processor’s
internal op amp. These issues will be
easy to correct in a second PCB iteration. (The first physical realisation of
any PCB design is rarely perfect – in
our experience, never!)
PSU noise
In addition to correcting the bugs in our
PCB design, months of experimentation
and use of this circuit have brought out
a number of desired design changes to
the hardware and user interface. The
most important issue we noticed was
that the use of a DC-DC converter as a
power supply from batteries increased
the noise on the audio input signal.
This is not terribly surprising; a simple
battery, as used on our original design
introduces no noise, so any switching
circuit used in its place will have a negative impact. As engineers, our job is
to minimise that impact.
PSU options
Thinking about a ‘revision 2’ of this
board we have decided to provide a
second option for the power supply.
You can choose a low-efficiency / lownoise LDO (low drop-out) power supply
driven by four alkaline batteries, or an
efficient DC-DC converter power supply
that can run from one, two or three alkaline batteries, as used now. We will
add both circuit options to the PCB
design so you can decide which to use.
We also want to extend the original
input range of 0 – 1kHz to the entire
hearing (audio) range, up to 20kHz.
That makes it suitable for younger readers’ ears – beyond the age of 20 hearing
range starts to decrease (and at 55 we are
happy to be able to hear up to 12kHz!).
In this series of articles we will also
create a 3D-printable enclosure for the
final product. This will be a first for
Practical Electronics, but since we
introduced hobbyist 3D printers way
back in 2009 and ten years later we find
they cost as little as £130, it’s reasonable to expect that these devices are
becoming a feature in hobbyist workshops. (In fact, to keep abreast of the
times, we will be discussing the introduction of hobbyist laser cutters in an
article later this year!)
So, in summary, the changes we are
going to make are:
Correct the PCB traces for the op amp
connections
Add an optional low-noise LDO DC
supply
Increase the audio range to 20kHz
Provide additional user interface
features
Create a 3D printable enclosure.
The second-to-last feature in that list
is the only one that involves software
changes to the original design. Let’s talk
through those changes first, as they will
be the most challenging to implement
in the coming months.
User interface
Currently, the LCD display shows no
textual indication of frequency – it’s
just a constantly varying signal ranging from zero to 1kHz. This is fun to
play with but not terribly practical. In
this update we will provide options to:
Display the value of the peak
frequency
Allow a button press to choose the
frequency span
Allow a button press to toggle peak
trace hold.
Fig.1. Original Spectrum Analyser design with PCB modifications.
40
Practical Electronics | March | 2020
Fig.2. Updated Audio Spectrum
Analyser schematic – note the
addition of the MCP1700T LDO
power supply section at top.
IC3
MCP1700T-3302E/TT
3
C14
10µF
X5R
10V
3.3V – 6V input
regulated PSU
VIN
1
VOUT
2
C15
10µF
X5R
10V
GND
Analogue power supply filter
Battery
1.5V – 5.5V input
regulated PSU
Battery+
2
Battery–
1
JP5
IC1
TPS61097A-33DBVT
3.3V
5
A_3.3V
L1
SRN3010TA-100M
1
C1
100nF
3
C2
10µF
X5R
10V
2
L
VOUT
R6
TBD
VIN
EN
C4
100nF
GND
C3
10µF
X5R
10V
C12
TBD
R5
TBD
C13
TBD
C5
10µF
X5R
10V
SD media
4
3
Mic
1
2
2
R4
TBD
1
JP2
No connections
used for
mechanical
support only
PICkit 3
Header
6
5
4
3
2
C10
TBD
8
R1
4.7kΩ
1
MCLR
2
3.3V
3
GND
4
PGD
5
PGC
6
7
1
8
JP3
9
10
11
12
13
14
C8
100nF
R2
4.7kΩ
IC2
dsPIC33EP256GP502-I/SO
MCLR
AVDD
AN0/OA2OUT/RA0
AVSS
AN1/C2IN1+/RA1
RPI47/T5CK/RB15
PGED3/VREF–/AN2/C2IN1-/SS1/RPI32/CTED2/RB0
RPI46/T3CK/RB14
PGEC3/VREF+/AN3/OA1OUT/RPI33/CTED1/RB1
RPI45/CTPLS/RB13
PGEC1/AN4/C1IN1+/RPI34/RB2
RPI44/RB12
PGED1/AN5/C1IN1-/RP35/RB3
TDI/RP43/RB11
VSS
TDO/RP42/RB10
OSC1/CLKI/RA2
VCAP
OSC2/CLKO/RA3
VSS
MS/ASDA1/SDI1/RP41/RB9
RP36/RB4
CVREF2O/RP20/T1CK/RA4
VDD
TCK/CVREF1O/ASCL1/SDO1/RP40/T4CK/RB8
SCK1/RP39/INT0/RB7
PGED2/ASDA2/RP37/RB5
PGEC2/ASCL2/RP38/RB6
MIC–
JP4
JP1
1
R3
4.7kΩ
MIC+
C11
10µF
X5R
10V
C7
100nF
28
VCC
LED
27
26
4
25
3
24
9
23
5
22
6
21
7
20
C6
10µF
X5R
10V
19
18
10
12
13
17
11
16
14
15
2
C9
100nF
RESET
CS
SDO
D/C
SDI
SCK
T-CLK
T_DIN
T_DO
T_CS
T_IRQ
GND
LCD panel
S2
S1
Adding these features to our design
will provide a significant amount of
new software that you can download,
play with and expand on. The key feature being added will be the display of
text; we will make use of existing opensource software libraries to provide the
fonts and driver code required to implement them.
Even with just two buttons there are
several ways to implement a user interface in our software. One is to do a menu
system similar to the technique used by
PC monitors where one button cycles
through a menu list and another toggles
between options. Another method would
be to provide specific functions to each
button. We have chosen the latter route
because it will be simpler to implement.
The specification for the implementation
can be described as follows:
Practical Electronics | March | 2020
Button A
On each press of the button, cycle
between peak frequency display,
peak trace hold, none
When active, the peak frequency will
be displayed in the format xxxx Hz
directly above the peak signal.
Button B
Pressing once will display the fre-
quency span for three seconds
Pressing the button again while the
span is being displayed will cycle
through the different span settings.
The display will be updating quite frequently, so it’s possible that the display
of the peak frequency value may be a
little difficult to read – it will be interesting to see it in action! If it does pose
a problem we can look at reducing the
display refresh rate down to perhaps
once per second.
Increasing the maximum frequency
span of the device to 20kHz will require some component value changes
on the input filter from the microphone,
which we will cover in the next article. To be clear, this is not going to be
a high-precision measurement device;
the microphone will have poor performance above 16kHz or so, and we
will not be calibrating the circuit –
so consider this as a ‘for indication
only’ design.
Let’s go back and look at the circuit
changes we will implement next month.
Power supply
Our main change to the electronics
will be the addition of a low-noise
LDO regulator. The original design
41
used an efficient switching regulator
that could operate from batteries with
a voltage covering 1.5V to 5.5V. While
that is great for battery life, switching
regulators generate lots of noise, and
when studying the circuit in operation we did see considerable noise on
the microphone input signal and the
output from the operational amplifier
in the microcontroller. While that did
not appear to impact performance, we
would like to improve the design. So
we have decided to implement two
regulators on the PCB board – leaving
you the choice of which to use. We
will add a simple three-pin LDO regulator, which is not very efficient, but
will generate significantly less noise.
You can fit either regulator circuit, as
shown in the schematic.
Adding an LDO in this project is
not really a bad choice. True, LDOs
are very inefficient, and dump wasted
energy as heat – which can be bad for
the component and other devices surrounding it. However, in practice, it
depends on just how much current you
are drawing – in low-power product
designs, an LDO can be more efficient
that a switching regulator. This is why
many low-power microcontrollers incorporate both regulator technologies
and switch between them depending
on the system current consumption
at the time. In our design we draw
120mA at 3.3V, which is a little too
high to use that argument, but it’s low
enough that in use we will not notice
the poor efficiency.
For the new LDO design we opted
for a small three-pin SOT-23 regulator
from microchip because it is cheap and
readily available (plus we had some in
the lab.) We chose to deviate slightly
from its datasheet recommendations
for circuit design by choosing 10µF
bypass capacitors rather than 1µF.
Why? Simply because we used 10µF
in the previous design, and for regulation a slightly larger value would
be better. Feel free to use 1µF if that
is more convenient.
The final design changes, including
the design corrections from last year,
are shown in Fig.2. Those final design
corrections were:
n P
in 2 of the CPU now connects to
R4, not Pin 5
n P
in 3 of the CPU connects to pin 17
n T
he signal that was on pin 17 now
connects to pin 18.
Before committing this design to a
PCB it’s worth running some tests, so
as we had the LDO regulator IC in the
lab, we removed the original regulator
circuit (the inductor and the switching
regulator) and ‘birds nest’ soldered the
42
alternative regulator in
place. It’s a bit fiddly, but
with the aid of our PCB
microscope we covered
in last month’s Practically Speaking column,
we were able to come up
with a working solution
shown in Fig. 3. By soldering two pins of the
regulator over one of the
original input bypass
capacitors it took just a
single wire to complete
the circuit.
Unsurprisingly, the
circuit draws 120mA
with a 6V input supply
and continues to draw Fig.3. Testing the new LDO power supply option on the PCB.
120mA down to 3.3V.
.3V – 6V with the quiet but ineffiWhere we must be careful in this n 3
cient LDO regulator. This will work
design implementation is with the
with four alkaline batteries.
circuit being powered by a ‘high’ battery voltage. At 6V input (four new
AAA alkaline batteries), the regulator If you are trying to build something
is dumping 6.0 – 3.3V, or 2.7V, out of very small, the former option works
the regulator as heat. With a constant well with, say, two AAA batteries.
120mA current draw, this equates to The second option will require four
324mW. That energy is being dissi- AA or AAA batteries. Using four AAA
pated by a very small package, so we batteries you can expect around six
hours use; and with two AAA battercan expect it to get warm. If it gets
too warm, that will be a problem – ies a little longer. We feel that with
the low cost of alkaline batteries and
the device could fail.
To test this we hooked the circuit the benefits of a low-noise regulator,
up to a bench supply and ran it at 6V choosing the LDO regulator and four
while monitoring the chip temperature AAA batteries will be the best choice
with a low-cost thermal sensor. These for the enclosure design. You can of
devices cost less than ten pounds and course choose your own configuraare readily available (eg, eBay item tion. If we can, we will make space
for both battery holder options in our
383337313555.) These sensors are not
terribly accurate but are perfectly suited enclosure design.
for this kind of application, where we
are looking for a general indication of Enclosure considerations
When we come to the 3D-printed enheat rise. After an hour of operation
the regulator settled at 35°C, just 10°C closure design we will be looking at
above room ambient. That’s perfectly providing the following features:
acceptable, but we will still take care n Include legends for the buttons, indicating their function
during PCB design to provide as large
rovide a recess for the on/off
an area of copper as possible on the n P
switch, so we do not need to drill
ground pin to help dissipate the heat
or cut the plastic
being generated.
rovide a hole for the LCD, so no
That completes the circuit chang- n P
need for accurate drilling, cutting
es in preparation for the next article.
or ‘dremel-ing’
To complete the physical design we
ngle the enclosure so it can be
will add a simple on-off switch to the n A
easily visible on the desktop
battery, but we will mount that in the
rovide easy access for replacement
enclosure – the design of which will n P
of the batteries.
be covered in another article.
Speaking of enclosures brings us
Next time
to the final point – what batteries to
use? We need to determine which of In the next article we will have the
the two power supply options to fit, PCB design completed and the board
back from PCBWay, do we will be able
as this will impact enclosure design.
To recap, with this new design we to discuss the software changes and
can support two battery voltage ranges: review the improvements as a result
n 1
.5V – 5.5V with the noisy but efof our PCB changes. If time permits,
ficient switching regulator; works we will present the 3D-printed enclowith two or three alkaline batteries sure design.
Practical Electronics | March | 2020
|