This is only a preview of the February 2022 issue of Silicon Chip. You can view 0 of the 112 pages in the full issue. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Dual Hybrid Power Supply – Pt1":
Articles in this series:
Items relevant to "Fan Controller & Loudspeaker Protector":
Items relevant to "Solid-State Tesla Coil":
Items relevant to "Remote Gate Controller":
Items relevant to "Resistor-Mite auto-ranging ohmmeter":
Items relevant to "Using a capacitive soil moisture meter":
Items relevant to "Musical bicycle horn":
Purchase a printed copy of this issue for $11.50. |
100-120W resistor. The backlight takes
a significant proportion of the overall
current, thus this range of values is a
compromise between display readability and battery life. In an indoor
setting, this value could be increased
significantly.
To fit the probe into the 3D printed
case, I desoldered the plug and soldered wires directly to the probe. I then
fixed it to the case using hot melt glue.
On the first prototype (pictured), the
probe was mounted component side
down, but the case is now designed
for the opposite orientation.
On the two prototypes, the start
pushbutton was protected from moisture by repurposing a section of the
rubber overlay from a multi-button
keypad.
Software & calibration
The ST7735 LCD display driver was
written and is maintained by Peter
Mather on The Back Shed forum.
This must be loaded into the Micromite first, then saved as a library. To
do this, load “moisturelib.bas” into
Musical bicycle horn
Human powered vehicle racing in
Australia generally requires an “electronic warning device” to be fitted to
each vehicle to be used when overtaking. Usually, a piezo siren is used, but
those are boring! This design uses a
piezo siren to play simple tunes, and
with the right software, it can also act
as a very loud MIDI synthesiser.
The horn is powered by two AAA
cells and is controlled by an Arduino
Nano. Its circuit is shown in Fig.1.
Sound is generated by a piezo transducer salvaged from an old smoke
alarm. In general, the older the smoke
alarm, the larger the piezo diameter
siliconchip.com.au
the Micromite and then type “library
save”. Next, load “moisture.bas”. The
Micromite will need to be reset before
the first time it is run so the display
driver is initialised.
After that, the software will run
automatically.
Calibration is straightforward. Short
the pins of CON5, then press the start
button until the display says “Reset”,
then release it. Remove the short from
CON5, then power the unit up with a
completely dry probe. Wait until the
display switches off, then submerge
the probe in water and power it back
up again. Keep it submerged until it
switches off.
The prototype is housed in a custom 3D-printed case. The STL files
and Micromite BASIC software code
are available to download: siliconchip.
com.au/Shop/6/6232
Editor’s note: a BC547 can be used for
Q1 and a BC639 for Q2 if you have
trouble finding the recommended
ones.
Kenneth Horton,
Woolston, UK. ($120)
The moisture meter in its 3D-printed
case. Once calibrated, the unit
displays the moisture content of the
soil that the probe is inserted into as
soon as the start button (on top) is
pressed. It will then automatically
switch off after eight seconds.
and thus lower the resonant frequency,
hence better performance for lower
notes. The best transducers are separate from the smoke alarm case so that
a separate resonance chamber does not
need to be created.
To generate a high voltage for the
piezo to be loud enough, a two-stage
system is used. One stage boosts the
battery voltage to an intermediate
level, and the second stage drives the
transducer. This is inspired by but
implemented differently from the Hornit bike horn.
The first stage uses a PWM signal
generated by the Arduino to switch
Q1 on and off at 62.5kHz, drawing
current through L1 so that when Q1
is switched off, the voltage across Q1
rises above the supply voltage. This
forward-biases diode D1 and charges
the 47μF capacitor. As there is no feedback, zener diode ZD1 clamps the maximum voltage to 22V for safety.
The second stage consists of autotransformer L2, designed for piezo
sirens and some smoke alarms, pulsed
by Q2 to generate each note. The
autotransformer has an approximate
inductance of 3mH on the primary
and 90mH on the secondary, and produces over 100V peak-to-peak for driving the transducer depending on the
frequency.
The autotransformer is the hardest part to source. I found the easiest
Australia's electronics magazine
February 2022 105
Fig.1
method of obtaining one was to buy
a small piezo siren such as Jaycar
LA5141 and disassemble it. The smoke
alarm the piezo transducer was salvaged from may also have one.
Two buttons are connected to header
CON2, one for making the horn go off
and one for changing the tune that is
played. A double-throw momentary
centre-off switch could also be used.
LED1 indicates the status.
The microcontroller spends most of
its time in power-down mode, using
virtually no power, waking only when
a button triggers an interrupt or the
chip is reset.
A couple of modifications need
to be made to the Arduino Nano to
reduce the power requirements and
avoid charging the batteries when
plugged into a computer. Fig.2 shows
the changes on the circuit of a standard Nano.
106
Silicon Chip
The modifications involve disconnecting the positive USB power rail
from the ATmega328P and removing unnecessary components that use
power.
This means removing the diode
between the USB +5V rail and the 5V
rail, cutting a track to disconnect the
5V pin of the CH340 USB to serial converter, adding a wire to connect the 5V
pin of the CH340 to the USB +5V rail
and removing the RX, TX and power
LEDs. I also removed the built-in voltage regulator for good measure.
The brownout detection fuses on
the ATmega328P need to be changed
to reset the microcontroller at 1.8V
instead of the default 2.7V, so that it
will operate reliably with partially discharged cells. To do this, the extended
fuse needs to be set to 0xFE from its
default value of 0xFD. You need an
external Atmel programmer to do this,
Australia's electronics magazine
although you can use another Arduino. See these links:
siliconchip.com.au/link/abb2
siliconchip.com.au/link/abb3
siliconchip.com.au/link/abaw
I have designed a PCB for the horn.
It is single-sided and has fairly generous tolerances for home manufacturing, although wire links are needed
if two layers aren’t available. I also
designed a 3D-printed case to house
the unit. It might need to be modified
to suit your piezo siren. The software,
PCB patterns and 3D printer STL files
can be downloaded from the GitHub
link below.
The battery and PCB are screwed
to a tray that can be slid in and out
of the housing for access when the
front is removed. The USB connector
of the Arduino, LED and button connector are accessible from the back.
As the unit isn’t fully waterproof, I
siliconchip.com.au
Fig.2
recommend that the circuit board be
conformally coated to protect against
moisture.
Large components such as the autotransformer and capacitors should be
glued down for vibration resistance.
Optimising the volume
I noticed that the volume was unpredictable for each note. To get the best
performance, I wrote a Python script
and corresponding Arduino sketch to
try many different duty cycles. When
left with a computer with a microphone in a quiet room, the computer
will measure which parameters give
the loudest results.
After a bit of cleaning up, the program will produce code that can be
pasted into the main BikeHorn sketch.
See the Tuning subfolder in the source
siliconchip.com.au
code for more information on this.
Generating & uploading tunes
I wrote a plugin for the sheet music
editing software Musescore3 that can
take suitable sheet music and MIDI
files and generate an array that can
be copied and pasted into the sketch.
Note that the “Loop endlessly” checkbox should be ticked and musical
rests at the start and end of the tune
removed for continuous operation.
See the Musescore Plugin page,
which can be found at https://github.
com/jgOhYeah/TunePlayer
Tunes need to be pasted into tunes.h
in the main BikeHorn sketch and the
tune’s name included in the array at
the bottom of the file. The Arduino
IDE can be used to upload the sketch
to the Arduino.
Australia's electronics magazine
If the ‘change tune’ button is pressed
on resetting the microcontroller, the
Arduino will go into MIDI synthesiser
mode. This listens for MIDI messages
on the serial port and attempts to play
them. It can only play one note at a
time, though, and by default, it listens
on MIDI channel 1.
On the computer side, a program
such as Hairless MIDI Serial is suitable. Turning the MIDI to serial bridge
on in Hairless MIDI Serial is enough
to reset the microcontroller without
taking the siren apart.
You can find source code and related
files for this project at https://github.
com/jgOhYeah/BikeHorn and a video
of it in operation at siliconchip.com.
au/Videos/Bike+Horn
Jotham Gates,
Notting Hill, Vic. ($150)
February 2022 107
|