Silicon Chip – July 2019

(Frankie) #1

78 Silicon chip Australia’s electronics magazine siliconchip.com.au


To program AVR family microproces-
sors, you need a programmer such as
the USBasp (see http://www.fischl.de/usbasp/
for details and drivers). This can be pur-
chased online from many suppliers for
just a few dollars.
Suitable free software is
available for Windows, Linux
and Apple IOS online. This
description will focus on the
Windows version.
You need to install the USBasp
drivers and download suitable pro-
gramming software. For Windows,
this includes
eXtreme Burner (http://extremeelectron-
ics.co.in/avr-tutorials/gui-software-for-
usbasp-based-usb-avr-programmers/),
AVRDUDESS (http://blog.zakkemble.net/
avrdudess-a-gui-for-avrdude/) and
Khazama (http://khazama.com/project/
programmer/).
Plug it in and complete the installation
of the USBasp programmer into your PC.
If you have the option of 3.3V or 5V pro-
gramming levels, select 5V.
Launch the programming software you
downloaded earlier and set the target de-
vice to “ATmega328” or “Atmega 328P”,
depending on your chip. Both may be
used. Now download the HEX file for this
project from the SILICON CHIP website (if
you don’t already have it) and select it as
the file to be used to program the chip in
your software.
Make sure JP1 has not been fitted to
your signal generator board; if it has, re-
move it now. Note that since some of the
ATmega328 pins connect to the AD9850
module, the AD9850 module’s power LED
will still light up and flash while the pro-
grammer is connected and running, de-
spite having removed JP1 and therefore

cut the
power sup-
ply to the mod-
ule.
This is of no concern.
Plug the six-pin connector from
the USBasp programmer into CON3 on
the signal generator PCB, making sure that
pin 1 on the programmer cable lines up
with the pin 1 indicator on the PCB.
Now select “Write FLASH buffer to chip”
or “Write – Flash” to program the ATme-
ga328 with the HEX file. The LEDs on the
USBasp will blink furiously for a minute
or two while the HEX file is loaded into
the ATmega328. A bar graph may be dis-
played in some cases on the PC screen, to
show progress.
You then have to program the ATme-
ga328 internal ‘fuses’. These configure
the operating characteristics of the AT-
mega328 to suit the software being run
on the device.
For this step, insert the following set-
tings into the relevant Fuse page/section
of the programming software, then click
on “Write” to send the data to the fuses:
Low byte: 0xE2
High byte: 0xD9
Extended byte: 0xFF
Lock byte: 0xFF
Since the processor and display are
powered via the programmer, once pro-
gramming is complete, the display will
briefly show the start-up message and then
the initial signal generator screen. At this
point, you can unplug the programming
cable from CON3 and place a shunt on JP1.

Programming the ATmega328 micro


dly, but there are two benefits: this is a
standard part that’s easier to get, and its
shaft will line up perfectly with push-
buttons S1/S2 and the access hole for
trimpot VR1 (if provided).
Alternatively, if you can get your
hands on a 9mm PCB-mounting right-
angle potentiometer, it will be dead
easy to mount to the PCB, as it’s fitted
similarly to RE1.
However, due to the location of the
hole for the 16mm pot’s shaft, its shaft
will sit around 3.5mm lower than S1/
S2 and VR1.


But this is hardly a tragedy. So the
choice is yours.
Now plug in the ATmega328 micro-
controller (IC1), making sure its pin 1
is orientated correctly, to towards the
upper-left corner of the board.
If you haven’t already programmed
it or purchased a programmed chip,
see the panel above detailing the pro-
gramming instructions.

Further testing
Later, we will be attaching REG1 to
the metal case but since we haven’t

built it yet, so for further testing, tem-
porarily attach a flag heatsink or at-
tach it to a spare sheet of metal using
a machine screw and nut.
You can now apply 12V power to
CON1, press S3 and check that you
can control the output frequency, am-
plitude etc (see the operating instruc-
tions below).
Power the unit down before finish-
ing construction.

Fitting the shields
You will notice several holes around
the buffer, attenuator, output and band
select/HPF sections of the board. There
are also lines on the PCB ‘silkscreen’
between these holes. This is where
shield plates can be fitted.
However, you do not need to fit
shields in most of these areas; the only
ones that are critical are those between
the three high-pass filter sections (be-
tween L1 & L2 and L2 & L3).
So you only really need to cut two
shield pieces and mount them using
four posts in the holes provided. These
are shown in red on the PCB overlay
diagram, Fig.5.
Each shield piece should be around
8mm high and cut from 0.5mm tin
plate, or recycled tin cans (a fruit or
Milo tin lid is ideal).
The strips are then mounted to the
board using component leads off-cuts
soldered into the holes shown in red.
This is simple yet effective.
You could fit shields in the other
locations but testing has shown that
it makes virtually no difference to
the device’s performance so I don’t
feel that it’s worth the time and ef-
fort to do so.

Making the enclosure
I couldn’t find a suitable ready-
made box for the signal generator, so
I came up with a relatively easy way
to make one.
It’s a simple folded metal box and
works well, resulting in a unit that is
light but robust, compact and effec-
tively shielded.
Dimensioned drawings of the metal-
work are available on the SILICON CHIP
website – they’re a little too large to
publish here! The two panels are cut
and folded from 0.8mm thick alumin-
ium sheets. The top cover and base
may each be cut from a small 300 x
250mm sheet, making it relatively in-
expensive to build.
This grade of aluminium is light
Free download pdf