Silicon Chip – July 2019

(Frankie) #1

siliconchip.com.au Australia’s electronics magazine July 2019 49


command under Linux perform the same task. Other pro-
grams will have their own instructions for writing images
to cards.
Connect the microSD card to your PC; if your comput-
er does not have a card slot, use a USB card reader/writer
(eg, Jaycar Cat XC4740 which costs a princely $5). Install
Win32diskimagewriter and open it.
Extract the .img file from the .zip file and click on the
folder icon under “Image File” to select the image file.
Double check that the “Device” setting matches your mi-
croSD card.
Win32diskimagewriter is capable of writing to almost
all sorts of media, so make sure that you aren’t telling it
to overwrite your USB stick or hard drive. This is very
important!
Fig.3 shows an example of what the Win32diskimage-
writer program looks like just before writing to the card.
Finally, click “Write”. This process may take ten minutes
or even longer, depending on the speed of the card and
other factors.
Once the write has completed successfully, remove the
microSD card from your computer and insert it into the
Raspberry Pi.
If you want to set up the software from scratch, refer to
the panel at left with the step-by-step procedure.

Connecting to a host
To control the Pi and trigger speech synthesis and audio
playback, you need a device which can communicate over

that this is only a software setting this is used by the Pi and does
not affect whether or not it can be written by other systems. There
also some utilities installed which allow the Pi to use a ramdisk
overlay, for any programs that expect to be able to write to the disk.
If you wish to write files to the ramdisk for your own applica-
tion, the easiest way is to create a file in the /tmp folder, which
exists on the ramdisk. But note that its contents will be lost the
next time the Pi is rebooted or powered down.
To set up the read-only SD card, run the command:


wget https://raw.githubusercontent.com/adafruit/
Raspberry-Pi-Installer -Scripts/master/read-only-fs.
sh


This downloads the required script. When the download com-
pletes successfully, run this command:


sudo bash read-only-fs.sh


This will provide several prompts to be answered before ap-
plying its settings.
There are options to set a GPIO pin as a jumper to GND, to al-
low write access (the jumper is only read at boot time and applies
until the next reset). We suggest setting this to GPIO21, as it can
easily be jumpered to GND by placing a jumper across two pins
of the GPIO header.
This is actually one of the pins used for the I^2 S audio data,
but the jumper only needs to be placed long enough to be
detected at boot time, so will not interfere with the audio.
Fig.9 shows the pin allocations for the Raspberry Pi header, in-
cluding the suggested jumper location.
GPIO16 can be set to allow a jumper or external transistor to
shut down the Pi. Both of these pins can be configured differently
in the script. Just follow the prompts.
You can also choose to force the Pi to reboot on a kernel panic
(ie, an unrecoverable operating system fault), which may be handy,
although that is unlikely to happen.
Now that’s all done, download and install some packages and
apply the settings you have chosen. You can reboot after this by
running the command:


sudo reboot


The software on the Pi has now been set up and is ready to use.

Fig.9: the pinout of the Raspberry Pi’s 2x20 way header,
with the functions used by our software shown in red
(I^2 S audio data) and blue (serial transmit/receive), along
with the recommended shutdown and write-enable
jumper locations. If you fit a stackable header to the hat
board, jumpers and other accessories can still be easily
connected to the Pi.

Parts list (audio hat)
1 double-sided PCB coded 01106191, 65 x 31mm
1 2x20 way header socket (CON1)
[Jaycar HM3228 or Altronics P5387 for stackable variant]
1 4-way header or socket (CON2) for connection to the host
microcontroller
2 2-way male header (CON3, CON4)
[optional, for speaker connections]
1 3-way male header (CON5) [optional, line out]

Semiconductors
2 LM386 audio amplifier ICs (IC1,IC2)
1 TDA1543 stereo DAC IC (IC3)
[SILICON CHIP ONLINE SHOP Cat SC3029]
Capacitors
2 100μF 10V electrolytic
2 10μF multi-layer ceramic [eg, Digi-key Cat 445-181284-ND]
2 100nF MKT or multi-layer ceramic
2 10nF MKT

Resistors (all 1/4W 1% metal film)
3 1kW 2 470W
Other parts for complete Speech Synthesiser
1 Raspberry Pi Zero, Zero W or Zero WH
[eg, from Core Electronics]
1 power supply to suit Raspberry Pi
1 microSD card, 2-32GB
1 or 2 small 8W speakers [eg, Jaycar AS3004]
1 microcontroller board (eg, Arduino Leonardo)
4 jumper wires to connect a microcontroller to Speech
Synthesiser board
Wire or jumper wires to connect speakers
Free download pdf