This is only a preview of the June 2024 issue of Silicon Chip. You can view 57 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Arduino Clap Light":
Items relevant to "ESR Test Tweezers":
Items relevant to "MicroMag3 Magnetic Sensor":
Items relevant to "USB-C Serial Adaptor":
Items relevant to "DC Supply Protectors":
Items relevant to "WiFi DDS Function Generator, Pt2":
Items relevant to "Arduino bin reminder":
Purchase a printed copy of this issue for $12.50. |
Part 2 by Richard Palmer
WiFi DDS
Function Generator
This flexible function generator, introduced last month, has seven different
output modes and numerous other useful settings like burst and sweep modes.
It can be controlled via an onboard touchscreen, a remote web interface via
WiFi, or SCPI commands via WiFi from a computer.
D
espite its substantial feature
set, the LCD touchscreen interface makes it simple to use. The
unit can also be controlled from a
computer, tablet or mobile phone via
its web browser interface. This second
and final part of this series of articles
focuses on constructing, commissioning and operating the unit.
As with the other test bench instruments I have designed (Bench Supply,
Programmable Load and ‘Swiss Army
Knife’), SCPI commands are also supported. The device fits neatly into a
snap-
together instrument enclosure,
with a single PCB accommodating all
the components, LCD screen, controls
and connectors.
The Raspberry Pi Pico W microcontroller has a much simpler ‘drag and
drop’ programming method than the
ESP32 processors I used in the earlier
instruments in this series, making programming simple.
Construction
Because a generous PCB is required
to accommodate the switches, rotary
82
Silicon Chip
encoder and various connectors, there
is ample space to use through-hole
components almost exclusively in
this project.
As shown in Fig.8, the Pico and
PCM5102A modules mount on one
side of the PCB, with all the passives,
while the LCD, LEDs and switches are
on the other.
Two footprints are provided for
the PCM5102A module, to suit the
two most common versions available
online.
It is best to start by fitting all of the
parts on the Pico side of the PCB first,
doing some testing, then moving to the
other side of the board. That’s because
the LCD screen obscures the pads of
several components. The screen is
mounted on 6mm spacers to align
its face with the front panel, rotary
encoder and pushbuttons.
Refer to the overlay diagram, Fig.8,
as you mount the parts on the PCB. You
can also check the PCB photos (from
part one) to see how it should look.
Start with the only surface-mounting
device, diode D1. Tack-solder one lead
Australia's electronics magazine
to its pad (making sure the leads bend
down towards the PCB, not up in the
air like a dead bug), then check its
alignment with the other pads.
If it’s misaligned, remelt the solder and nudge it gently into position,
then solder the other leads and refresh
the first one. You can do that by adding a little extra solder or, even better, adding a tiny bit of flux paste and
then heating it with a clean soldering
iron tip.
Follow with the resistors. Ideally,
you should check each batch with
a multimeter to verify they have the
correct resistance (the colour-coded
bands can sometimes be hard to distinguish). After that, fit diode D2, the
only through-hole (axial) diode, with
its cathode stripe to the left as shown
in Fig.8.
If you are using IC sockets, mount
them so that the notched ends face
in the correct directions (IC2 faces
down, the others face up), then plug
REG3 into its socket, with pin 1 at
upper left. If not using sockets, solder REG3 in place, also being careful
siliconchip.com.au
4
37
MOD2b
5
36
35
7
RASPBERRY 34
PI Pico W 33
10
11
12
29
13
28
14
27
15
26
16
25
18
WIFI
MODULE
23
22
20
21
OUT A
5.6kW
2.2kW
PCM5102A
MOD2
24
19
220pF
100nF
2.2kW
31
30
220pF
5.6kW
32
RP2040
MCU
2.2kW
2.2kW
L
IC2
24C256
10kW
10kW
10kW
9
100nF
2.2kW
2.2kW
2.2kW
6
100nF 220mF
IC1
NE5532
100nF
17
100nF
10W
38
220pF
220pF
G R G
10kW
2.2kW
1kW
2.2kW
+
100nF
39
3
8
2.2kW
40
10W
D1
BAT54S
SCK
BCK
DIN
LRCK
GND
VIN
100nF
1
2
MICRO
USB–B
PORT
5819
10W
10mF
10mF
K
100nF
220mF
D2
MOD2a
+
MOD1
100pF
CON5
10W
4.7kW
4.7kW
REG3
MAX1044
220mF
CON4
CON1
+
100nF
REG1
7809
O UT B
TRIG IN
TRIG OUT
CON3
CON2
+
100nF
+12V
+
REG2
7805
PCM5102_MOD
4.7kW
100nF
4.7kW
2GER
5087
LED1
LEDW
A
K
3GER
4401XAM
S1
LED2
LEDT
K
A
LED4
LEDA
LED3
LEDB
K
K
A
A
3.5" SPI TOUCH SCREEN
LCD MODULE WITH
480 x 320 PIXEL RESOLUTION
(ILI9488 CONTROLLER, LCD1)
ROTARY
ENCODER
S5
S4
S3
S2
A ON
B ON
L BUT
R BUT
siliconchip.com.au
Australia's electronics magazine
Figs.8 & 9:
fit the
components
on both sides
of the PCB as
shown here. It’s
best to solder
the top side
components
first (starting
with the sole
SMD, then
the axial
components)
and only fit the
switches, LCD
screen etc to
the underside
once all the
components
on the other
side have been
mounted and
tested.
Errors on the
PCB cause
Button A to
start channel
B and Button
B to have no
effect, while
LED T/Trig Out
is shorted to
ground. The
two tracks
currently going
to pins 22 and
23 (GP17 and
GND) of MOD1
should be cut
and re-routed
to pins 21
& 22 (GP16
and GP17),
respectively.
Also, both
tracks
currently
going to pin 33
(AGND) need
to be re-routed
to pin 32
(GP27).
June 2024 83
Screen 1: the Function Generator provides this web page so it can be controlled
remotely via WiFi.
to orientate it correctly. Leave IC1 and
IC2 off for now.
After that, mount REG1 and REG2.
While they do not generate substantial
amounts of heat, it is worth mounting them with a thin smear of thermal paste between the tabs and PCB.
Start by bending their leads down by
90° just after the end of the thick part,
insert them into their pads, attach the
tab with a machine screw and nut, then
solder and trim the leads.
Don’t get REG1 & REG2 mixed up,
as they have different output voltages
but come in the same package type.
Now solder all the ceramic capacitors in place. They are not polarised,
so their orientations are not critical.
Many are 100nF types, but there are
other values, so don’t confuse them.
Follow with the electrolytic capacitors, which are polarised; in each case,
the longer lead should be inserted
into the pad nearest the + symbol on
the PCB.
Fit the DC socket, ensuring it is
pushed down fully before soldering
its tabs, and you are ready for initial
testing. Apply 12V DC to the input and
use a DMM set to measure DC volts to
check the +5V, +9V and -9V rails.
You can use one of the regulator tabs
as a convenient ground (negative) reference and probe the Pico’s pin 40 pad
(+5V), IC1’s pin 8 (+9V) and IC1’s pin 4
(-9V). Each should be within half a volt
of the expected reading. If not, switch
off the power and check for incorrectly
placed, orientated or poorly soldered
components.
Assuming all is well, solder or plug
in IC1 and IC2, ensuring that pin 1 is
84
Silicon Chip
in the correct location in each case.
Next, solder in the sockets for the
Pico W and PCM5102A modules. The
20-pin sockets for the Pico W and
the 6-pin socket for the DAC module
may be available pre-made. If not,
you can cut them down from longer
sockets. The 9-pin socket for the DAC
module will probably have to be cut
from a socket with at least 10 pins.
Cut in the middle of a pin to ensure
a clean break.
The four RCA connectors are the
final components to mount on this
side of the board. Ensure they are
fully pushed down before soldering
their pins.
Now move on to the other side of the
PCB. Mount the switches and encoder
on the rear of the board, as shown in
Fig.9. The switches need to have the
flats orientated as shown, or they might
not work. We will add the LEDs and
LCD screen at a later stage.
Programming the Pico W
Loading software to the Raspberry
Pi Pico W is very straightforward. It
does not need to be mounted on the
PCB for this process. Plug it into any
computer (Windows, Linux or Mac)
using a suitable USB cable. It will
appear as a virtual drive on the system
called “RPI-RP2”. If the virtual drive
doesn’t appear, unplug the Pico and
hold down the white BOOTSEL button while plugging it back in.
Copy the 0410421A.uf2 binary
file (download at siliconchip.au/
Shop/6/398) onto that drive using the
computer’s regular file management
tool. The Pico will automatically
Australia's electronics magazine
reboot and run the uploaded code as
soon as the file is transferred.
After programming has finished, the
Pico will reboot and the drive on your
computer will disconnect, at which
point you can unplug it.
Uploading that file actually did two
things: it loaded the software onto the
Pico and also some files that are used
to generate the web page for remote
control (stored in a ‘LittleFS’ file system). We have combined them into a
single file to make programming as
easy as possible.
There is a file in the download package linked earlier called “Pico Production Programming.pdf” that explains
how the files can be loaded separately
if you are interested.
Further testing
The main functions can now be
tested by plugging the programmed
Pico W and PCM5102A module into
the board and powering it up. Solder
the headers to them if they are not
already attached; you can use the sockets on the main PCB as a jig to hold
them in place while you do so.
Clicking the channel A and B
switches should start the Generator
producing a 1kHz sinewave at 1V
peak-to-peak on channel A and 500Hz
at 1V peak-to-peak on channel B. Both
signals should have no significant
DC offset. A 3.3V 1kHz square wave
should also appear at Trig Out.
The LCD screen can now be
mounted on 6mm spacers. While I
used tapped metal spacers in the prototype, plastic or untapped spacers can
be used with 12mm countersunk head
machine screws and nuts. If your LCD
screen has a four-pin header mounted
at the SD card holder end of the module, cut the pins off flush with the plastic retaining strip to prevent them from
binding on the PCB and RCA sockets.
The LCD screen’s pins are only just
long enough to reach the PCB pads,
so they should be soldered on both
sides of the board to ensure good connections.
Powering up the unit should now
produce the operating display on the
LCD. If the screen orientation isn’t correct or it responds to touches erratically, use the touchscreen calibration
process described in the PDF manual included in the download package. That should correct any screen
rotation and touchscreen alignment
problems.
siliconchip.com.au
Setting up WiFi
If desired, the following steps to
enable the WiFi functions can be performed later.
Edit your WiFi credentials using the
touchscreen interface (see Screens 6 &
7) and click the AC button to enable
WiFi. When a connection is made to
the WiFi LAN, the red LED will change
from flashing to constantly on. Don’t
switch off the unit for 30 seconds after
setting the WiFi credentials to ensure
they have been saved to EEPROM.
The unit may now be accessed from
a web browser at http://dds.local
If the firmware program and files
have been loaded correctly, the display
should look like Screen 1, and the values should update to match those on
the LCD screen after a second or so. If
not, try a hard reload of the web page
by holding down the Shift key while
refreshing the page.
Apart from the optional calibration
step, the unit should now be fully
functional.
Preparing the case
The main depression on the underside of the case is slightly larger than
the one on the top, and clearance
around the LCD screen is at a premium.
So, we use the case upside down, with
the four small circular dimples beside
the rounded rectangular depression
on top.
Fig.10 shows the case drilling details;
it is also available as a PDF download
(siliconchip.au/Shop/11/400). If you
print that PDF, ensuring that you do
it at “actual size” or 1:1 (not “shrink”
or “fit to page”), you can use it as a
drilling template.
Carefully trim the templates to size,
but don’t cut out any holes. Lay the
top template on top of the case and
prick through the centre of the four
LEDs, four switches, four PCB mounting holes, the encoder mounting hole
and the corners of the LCD cutout.
Next, drill all the holes: 3.5mm diameter for the LEDs and PCB mounting holes and 10mm diameter for all
others.
After that, make the LCD cutout.
Probably the easiest way to do that
is to drill a series of small (~3.5mm)
holes around the inside of the perimeter, knock the centre piece out, then
file the edges smooth. The LCD cutout is intentionally a millimetre or so
larger all-round than the actual screen;
the decal will cover any gaps.
siliconchip.com.au
Fig.10: you can mark the case using the dimensions shown on this drilling
diagram, or print/copy it at actual size and use it as a template that can be
temporarily attached to the case. If using it as a template, prick or drill small
holes through the centres of each hole to locate them before drilling.
Fig.11:
you can
download
the
artwork
for these
labels
from our
website,
print them
at ‘actual
size’,
laminate
them, cut
them out
and stick
them to the
case.
Australia's electronics magazine
June 2024 85
Countersink the four PCB mounting holes so that the tops of the screw
heads are flush with the surface of the
case. Test-mount the PCB on 10mm
spacers. If required, ream out the
switch holes in the top of the case to
stop them from binding.
Once the cover fits neatly with a
little clearance around the switches,
encoder and LCD, colour around and
inside the switch and LED holes, plus
the LCD cutout with a black permanent
marker. That will stop the grey plastic
from being visible through the holes
in the decal.
Assemble the PCB to the top cover
on 10mm spacers. If the LCD mounting screws bind on the inside top of
the cover, either drill clearance holes
in the cover or gently countersink the
screw holes in the LCD’s PCB.
Test the LEDs against the inside top
of the case. Their tops should protrude
by about 1mm. It may be necessary to
lightly countersink the backs of the
holes in the top of the case if the LEDs
don’t protrude far enough.
Insert but do not solder the LEDs.
The two white LEDs fit above the
channel A and B buttons, the blue one
(trigger) above them and the red one
(WiFi) near the 5V regulator. Mount
the PCB into the top of the case and
solder in the LEDs. ensuring the flats
on the lenses face as shown in Fig.9.
If you choose different coloured
LEDs, the current limiting resistor values may need to be changed to equalise their brightness. In development,
2.2kW resistors provided adequate
brightness for the red and blue LEDs,
but the white LEDs needed 4.7kW
resistors to reduce their brightness to
match the others.
Print and laminate the decals
(Fig.11), also available as a download
at the link above, again ensuring that
they are printed at 1:1 scale. Carefully
trim their outsides to size.
Cut a hole in the main decal for the
encoder. A 10mm wad punch does
the job neatly. The LED holes can be
cut with a 3mm plier punch. Cut the
switch holes with an 8mm wad punch
to allow for adjustments if the switches
are not perfectly centred. You can use
a sharp hobby knife if you don’t have
punches.
Lay the decal in position and check
that all the holes align. Make any
switch centring adjustments on the
decal and punch/cut them to 10mm. If
the LED holes in the decal are slightly
out of position, make the hole in the
case top marginally larger. The decal
will cover any scars.
Finally, check the LCD screen alignment by feeling for its corners through
the decal. Prick the corners of the LCD
screen on the decal and remove the
unwanted section with a sharp knife.
Repeat the process for the rear panel,
noting that the exact height of the RCA
connectors will vary slightly depending on which version you have used.
Prick all the holes through the decal
and drill 3mm holes for the power
socket and one RCA socket.
Loosely fit the back shell and place
the unit on the bench, then slide the
connector panel up to the RCA connectors and check the alignment of the
pilot holes. Make any adjustments to
their positions and drill all five holes
to 10mm, allowing adequate clearance
for the RCA plug shells and the coaxial power plug.
Now lay the trimmed decal in its
cutout on the rear panel. Holding the
assembly up to the light should enable
you to establish the correct position of
the holes in the decal. Punch the holes
with a 10mm wad punch.
Colour in and around the holes
in the connector cover with a black
marker to hide any grey plastic behind
the decal. The decals may now be
affixed with thin double-sided tape
and the encoder knob attached. Stick
the small rubber feet onto the bottom
of the case.
If using the optional acrylic stand,
assemble it and place the Generator
into the stand to ensure everything is
square. Turn the assembly over and
Screen 2: a sample of the Function
Generator’s display on the 3.5in LCD
touchscreen. This one sets the Pulse
waveform output parameters.
Screen 3: the sweep menu is accessed
via the “Swp” button on the main
screen.
Screen 4: the burst menu lets you
set up a channel to switch its signal
output on and off at intervals, or have
the signal switch between the two
channels (the “B alt A” setting).
86
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Scope 9: when “B alt A” is enabled for burst waveforms,
the signal alternates between channels B and A. The idle
value for the currently inactive channel is the DC offset for
sinewaves, or V Low for other waveforms.
put a small drop of superglue at each
join. Stick the rubber feet to the crossing points of the stand. The unit is
now complete.
Operation
Basic operation is very straightforward: supply power to the unit and
click the channel on/off button to start
generating the selected waveform. The
white status LED lights when a channel is active.
Changing settings is achieved by
Screen 5: the Control menu lets you
set the phase difference between
channels, enable the external trigger
input and set the trigger input/output
signal polarities.
siliconchip.com.au
Scope 10: channel A’s signal is inverted in channel B (blue
trace) when coupling is enabled and the phase lag is set to
more than 0° for step and pulse waveforms.
touching the value on the screen and
winding the encoder knob. The highlighted digit is changed with the white
‘number position’ buttons under the
knob. The left button will move the
highlight to a more significant digit,
and the right button to a less significant digit.
Channel A and B settings are
accessed by touching the A or B at the
top of the screen (see Screen 2). The
selected channel button is highlighted.
To change the waveform, touch the
waveform label at the top of the screen
and select the required function from
the drop-down list. Due to its computation requirements, the IMD waveform
is only available on channel A.
It is possible to set some parameter combinations that are not legitimate; for instance, a sinewave with
an amplitude of 10V and a DC offset
of +5V. Erroneous parameter combinations are flagged at the bottom of the
LCD and web page. Where the combination will cause the unit to clip or
Screen 6: the Settings menu lets
you calibrate the output levels and
provides access to the touchscreen
calibration and WiFi settings screens.
Screen 7: the communications settings
menu (“COMMS”) is accessed via the
settings menu by pressing the SET
button on the main screen.
Australia's electronics magazine
June 2024 87
otherwise generate a distorted waveform, the software ensures that the
settings are compatible.
In the case above, the sinewave’s
amplitude value is automatically
reduced to prevent clipping. Further
details of the handling of problematic
setting combinations are provided in
the PDF user manual included in the
software download package.
Across the bottom of the screen are
the menu buttons that give access to
the sub-menus shown in Screens 3-7.
In the sweep (Swp) menu (Screen
3), setting the V/F/D value determines whether channel A waveform’s
amplitude, frequency or duty cycle is
swept. The Initial and Final values of
the swept parameter can then be set.
Sweeps can be one-shot or continuously repeated and have linear or logarithmic steps. Logarithms can only
be calculated for positive values, so
for log sweeps, a value of 0.01 is used
when the initial value is set to zero
or less.
Touching the Sweep button at the
top of the LCD screen or clicking the
encoder button will start the sequence,
as will an external trigger pulse if
that function has been enabled in the
control menu. Sweep parameters are
stored separately for each waveform
and V/F/D combination. The “X” button at the bottom right exits the menu
and returns to the channel A waveform display.
For bursts (Screen 4), set the number
of cycles for the channel A signal to be
active and idle. Clicking on the Burst
button at the top of the LCD screen or
clicking the encoder knob will start
the burst sequence. One-shot or continuous burst cycles can be generated.
Channel B can also be set to alternate with channel A. When the “B alt
A” feature is selected, channel B uses
channel A’s waveform settings (Scope
9). This setting overrides the value of
the Control menu B=A setting.
The Con (Control) menu (Screen 5)
sets B-to-A channel signal coupling,
phase, and trigger input and output
functions. For most waveforms, channel B’s output can be set to follow
channel A using the B=A setting in
the Control menu.
For sine, square and triangle pulses,
a phase offset from 0-359.99° can be
set. For step and pulse waveforms,
any phase setting above 0° results in
an inverted waveform on channel B
(Scope 10).
The Set (settings) menu (Screen 6)
provides output voltage and touch
screen calibration, communication
settings, and a factory reset button.
To set your WiFi parameters, enter
the Com (communications) sub-menu
(Screen 7). Replace “mySSID” and
“myPass” with your WiFi network’s
credentials using the on-screen keyboard and click the AC button to
enable the unit to auto-connect to
your local WiFi network. The connection process can take several seconds,
during which the WiFi LED will flash.
Multiple WiFi networks can be
stored – instructions for doing that are
in the PDF user manual.
All parameters are saved to EEPROM
within 30 seconds of the last value
change. The red WiFi LED will change
state for two seconds to indicate an
EEPROM save has occurred.
accessible via http://dds.local once
your WiFi credentials have been
entered and activated in the Com submenu. Both channels, the Control and
the Burst/Sweep menus are all displayed side by side on the screen.
Operation is similar to the LCD
screen: click on the value to be
changed and wind the virtual knob.
The radio buttons below the knob
indicate which digit will be changed.
Changing true/false or +/- parameters
is best accomplished with the units
radio button selected (just to the left
of the decimal point).
More detailed information on the
web interface is in the PDF user manual.
SCPI remote Control
Screen 8: adding the Function Generator to the TestController software is
straightforward; select the unit from the drop-down list and add its hostname.
Almost all settings and functions
can be set and read using SCPI commands. The results of the power on
self-test (POST) and the last error message can also be read remotely via the
Pico’s serial interface or TCP port 5025
using http://dds.local as the address.
The user manual explains the SCPI
commands, parameters and results
in detail.
Using a program such as TestController (siliconchip.au/link/abev)
enables automated and repeated testing using one or more remotely controllable instruments.
While more complete instructions
are available in the user manual, connecting the Function Generator to
TestController is as simple as copying
two files from the download pack and
registering the device on the TestController Load Devices menu (Screen 8).
To illustrate the power of automated
tests, I have included the script used
to test the frequency response of the
DAC’s sinewave (Listing 1). It cycles
through the DDS frequency range at a
set output voltage.
After waiting several seconds for
the reading to settle at each point,
the script reads the value from my
Bluetooth-enabled Owon B41T multimeter and XDS3000 digital oscilloscope, puts the frequency and voltage
values into the logging table and proceeds to the next value.
The table of readings was exported
to Excel for analysis, though it could
also have been performed in TestController. These values were used to produce the Fig.3 frequency response plot
published last month (after correcting
for the B41T’s frequency response).
Australia's electronics magazine
siliconchip.com.au
88
Silicon Chip
Web interface
The web interface (Screen 1) is
The finished WiFi DDS
Function Generator. The touchscreen is
used to select functions, while the knobs and buttons let you
set values and turn the channels on or off independently.
After each tweaking of the settings,
the automated tests ran in the background, saving hours manually adjusting the frequency and jotting down
the results. With a little more effort,
I could have used the ‘math’ functions in TestController to plot the final
response curve.
Further information on using TestController can be found in my April
2023 article on that software, see:
siliconchip.au/Article/15740
Calibration
Uncalibrated, the unit’s output
voltages should be accurate to within
1%, with any error due to resistor tolerances in the buffer amp. If greater
accuracy is required, set both channels to PULSE mode and set both V
High and V Low to 5.00V. At least one
of the time values should have a nonzero value.
Start both channels and enter the
LCD touch screen Set menu (Screen
6). Enter the voltages measured on the
output pins in the respective fields,
then touch Save and restart each channel’s output. The output voltages will
now reflect the new calibration settings. Wait 30 seconds before turning
siliconchip.com.au
the unit off to ensure the settings are
permanently saved.
Conclusion
The use of modules simplified the
design and construction of what could
otherwise been a substantially more
challenging project. The PCM5102A
module avoids soldering the DAC
chip’s finely spaced pins and allows
optimum component placement
around the main DAC chip.
Similarly, the Raspberry Pi Pico W
is an inexpensive, highly functional
WiFi-capable microcontroller that is
much simpler to program than the
ESP32 used in earlier instruments in
this series.
Using these two modules allowed
the project to almost avoid soldering
surface-mounting components altogether. This may bring the project
within reach of those who don’t have
easy access to, or confidence with,
SMD components.
Providing remote control capability extends the usefulness of the
unit where access to the LCD screen
controls is difficult. Importantly, it
also allows it to be teamed up with
other test instruments for automated
SC
testing.
TestController sinewave frequency response script
; DDS to B41T multimeter and DSO
=var sVal=20
; create a control variable
#log 4
; log readings every 4 seconds
#while (sVal<70000)
PlatyDDS:::SINE:FREQ (sVal)
#hasLogged
; wait for the log delay to expire
=sVal=(sVal*1.2) ; exponential frequency increment
#endwhile
#log 0
; stop logging
Listing 1: this TestController script geometrically steps the unit’s output
frequency from 20Hz to 70kHz while logging the output levels via separate
instruments.
Australia's electronics magazine
June 2024 89
|