Escolar Documentos
Profissional Documentos
Cultura Documentos
Este
e Documento Haa sido deescargado desde la Web más
completa en E‐Books y Tuttoriales.
Si deseaas más in
nformacción o lib
bros, enttonces ingresa aa:
http://
h /www.en
nigmae
electro
onica.t
tk
htt
tp://ww
ww.foro
oenigma
a.tk
Y podrás deescargarr muchass aplicacciones úttiles.
Libros
Manuales
Tutorialles
Cursos
Program mas
Música
Películaas
Grupo Enigma Electrónicca
G
En
nigma Teeam
Si aalgún Archivvo Requirieraa de Contrasseña de acceeso siempre será:
www.eenigmaelectronica.tk
Ken Bromham
Pandora’s
Sound & Music Box
Recycle an old CD-ROM drive
for (triggered) playback
This project was originally conceived for model making
applications as a cheap way to provide high quality audio
playback in response to a trigger signal (typically from a
pushbutton or PIR detector), but we’re pretty sure Elektor
readers can find many other uses.
10k
10k
100n 100n
R12 K2
11 32 R10
1k
1 OUTPUT
1k
DELAY
1 40
MCLR/VPP/THV RB7/PGD R11
39 OUTPUT
RB6/PGC 1k
IMMEDIATE
6 38 CS1
RA4/T0CKI RB5
2 33
RA0/AN0 IC5 RB0/INT
S1 1
TRIGGER
S9 15 DD15
RC0/T1OSO/T1CKI
37 16 DD0
RB4 RC1/T1OSI 0V
S2 36 17 DD14
RB3/PGM RC2/CCP1
35
RB2 RC3
18 DD1 K3
R3
34 23 DD11 K4
1k RB1 RC4
PIC16F871 24 DD4 IDE-Interface
S3 RC5
25 DD10 1 2
R4 RC6/TX/CK
CS0 3 26 DD5 DD7 3 4 DD8
3k3 RA1/AN1 RC7/RX/DT
S4 DA2 4 DD6 5 6 DD9
RA2/AN2/VREF-
DA0 5 19 DD13 DD5 7 8 DD10
R5 RA3/AN3/VREF+ RD0/PSP0
20 DD2 DD4 9 10 DD11
6k8 RD1/PSP1
S5 DA1 7 21 DD12 DD3 11 12 DD12
RA5/AN4 RD2/PSP2
22 DD3 DD2 13 14 DD13
R6 RD3/PSP3
INTRQ 8 27 DD9 DD1 15 16 DD14
10k RE0/RD/AN5 RD4/PSP4
S6 DIOR 9 28 DD6 DD0 17 18 DD15
RE1/WR/AN6 RD5/PSP5
DIOW 10 29 DD8 19 20
R7 RE2/CS/AN7 RD6/PSP6
30 DD7 21 22
22k RD7/PSP7
S7 DIOW 23 24
OSC1 OSC2
DIOR 25 26
R8 12 13 14 31
X1 27 28
33k
S8 29 30
INTRQ 31 32
R9
4MHz DA1 33 34
68k C7 C8
DA0 35 36 DA2
CS0 37 38 CS1
22p 22p
39 40
C9 C10 C4 C3
+12V K5
100n 100n 100n 100n
K1 1
+12V gelb
2
schwarz
IC2 IC4 3
schwarz
7812 7805 4
0V +5V rot
+5V
C11 C12 C2 C13 C14 C1
Figure 1. The modern version of Pandora’s Box is a black one governing triggered response from an old CD-ROM drive playing
back music or sound samples. You determine what ‘horrors’ (if any) lurk inside the box.
The standard low cost solution to creat- just by connecting a power supply and module that will interface to any old
ing auto-playback sounds is to use a headphones to your drive, inserting a ATAPI CD-ROM drive. Mind you,
record/playback chip (say, the ISD25XX CD and pressing the Play button. Sim- ATAPI is not a brand, but a connectiv-
series) but these devices are limited to ple as this may sound, there are pit- ity standard for 99% of all CD-ROM
about 3 kHz audio bandwidth, not to falls, particularly with later CD-ROM drives in PCs for home and office use.
mention a lot of hiss and noise, so the drives that do not have a music play- Don’t worry about it, just start rum-
sound quality is not the best unless back button. Also, we really could not maging around in the attic or cellar, dig
you’re specifically after for voice mes- stand the thought of being unable to a CD drive out the IT skip at work, or
sages of the Stephen Hawking type. select and skip tracks, etc. In true commandeer the oldest (usually read-
Elektor fashion we wanted to be in only) CD drive from the kiddies’ PC
control of things and make the old CD- leaving a note saying ‘drive removed
The Elektor approach ROM drive do something really useful. for scientific purposes’. Never tell them
Over the past few years we have The alternative approach developed by you got the idea from Elektor, instead,
received many requests from readers Ken Bromham and described in this tell them to keep using the CD/RW
asking for a circuit that would allow article makes use of a 40-pin PIC drive which is much faster, better, etc.
them to use an old CD-ROM player for 16F87X microcontroller which, helped or better still buy them a mini MP3
the sole purpose of playing back music by a small number of external compo- player and headphones.
CDs. In many cases, that is possible nents, provides a versatile controller
K1
HOEK2
K2
IC4 R10
R7 = 22kΩ
C1 DELAY
R11 R8 = 33kΩ
0V +
S9
IMM
R9 = 68kΩ
R12
C14
IC3
C13 0V Capacitors:
C1,C2 = 47µF 16V radial
TRIG
C4
C6 R2
C3 K3
IC5 C5 S1
IC2 C2 C7
C12 R3 S2
ROTKELE )c(
C11
1-204030
X1 R4 S3
+5V
0V What can it do?
IC1 0V R5 S4
+12V
The controller module has two main
C8 R6 S5 modes of operation, single trigger use
K5
030402-1
R7 S6 or multiple-trigger use, with further
C9 C10
R8 S7
options selected by a 4-way DIL
K4
switch (psst… in fact both modes run
R9 S8
simultaneously). There are also two
HOEK3
Single-trigger mode
The function here is very simple. Acti-
vating the single trigger input will
cause playback of one track from the
CD. There are four options (selected
with a DIL switch), as follows :
DIL switch # 1
off = normally open contact for single
trigger
on = normally closed contact for sin-
gle trigger
DIL switch # 2
off = no response to trigger until end
of track
on = respond anytime
DIL switch # 3
off = random track selection
on = sequential track selection
DIL switch # 4
off = keep disc continually spinning
(defeat drive’s inactivity timeout)
on = allow the CD-ROM drive to
power down.
Semiconductors:
K1,K2,K3 = 2-way PCB terminal block,
lead pitch 5mm
Downloads
D1=LED, red, low current K4 = 40-way boxheader PIC source and hex code files.
IC1,IC2 = 7812 K5 = power supply plug for CD-ROM File number: 030402-11.zip
IC3,IC4 = 7805 drive
IC5 = PIC16F871/P, programmed, order PCB, order code 030402-1 (see Readers PCB layout in PDF format. File
code 030402-41 (see Readers Services page) number: 030402-1.zip
Services page) Heatsink, e.g., Fisher SK59 (6 K/W)
Disk, PIC source and hex code files, order www.elektor-
Miscellaneous: code 030402-11 or Free Download electronics.co.uk/dl/dl.htm,
S1-S8 = pushbutton, 1 make contact CD-ROM drive
select month of publication.
spend a lot of time ‘doing nothing’. bunch of switches and some connec- an old PC power supply can be used to
There may be up to 24 tracks on the CD tors. The heart of the circuit is a 40-pin power the CD-ROM drive directly. In
(the PIC chip is storing the table of con- PIC16F871 microcontroller which fortu- this case it is recommended to retain
tents data in its limited RAM). The mul- nately has enough input/output pins to the 7805s and use 12 V from the pc
tiple trigger inputs should be left open. connect to all of the necessary ATA power supply for the controller board.
interface lines with enough left over to A heatsink will still be necessary.
Multiple-trigger mode handle the trigger inputs, option selec- Resistors R10 and R11 provide current
In this mode you can have a maximum tions and the switching outputs. As limiting for the digital outputs and
of eight separate triggers (for instance, can be seen from the schematic, only a have been given the nominal value of
push buttons). Pressing button 1 will handful of extra components are 1 kΩ. The PIC chip can source/sink an
always play track 1, button 2 will required. Note that the single trigger absolute maximum of 25 mA for each
always play track 2, etc., up to and input RB0 (K3) and the option select pin, so the value of these resistors can
including track 8. It can be used with inputs RB1-RB4 (S9) make use of inter- be changed so long as this maximum
normally-open contacts only. If, for nal, that is, invisible, pull-up resistors. is not exceeded. In any case, it is suf-
example, there are only three tracks on All other port lines of the PIC16F871 ficient to drive a transistor/relay com-
the CD then pressing buttons 4 – 8 will are connected to the drive’s IDE bination for example.
have no effect. (ATAPI) interface via connector K4. The PCB shown in Figure 2 was
Together with R2, resistors R3–R9 pro- designed for ease of use by you, the
DIL switch 1 must be configured as vide a simple potential divider network constructor. It is available ready-
normally open and the single trig- connected to input A0 on the PIC. The made through our Readers Services
ger input left open. upshot is that a different voltage is under number 030402-1. Alterna-
DIL switch 2 is not relevant. applied to A0 depending on which but- tively, you may decide to make your
DIL switch 3 has the same function as ton is pressed (multiple-trigger mode). own board using the artwork file that
above. This voltage is read by an internal A/D can be downloaded free of charge
DIL switch 4 has the same function as converter. It is assumed here that it is from our website.
above. not necessary to distinguish multiple As there are only regular components
simultaneous button presses. If multi- to fit on the board we doubt the con-
Digital switching outputs ple trigger mode is not required then struction will present any problems.
Pandora’s Sound & Music Box has two resistors R3–R9 and switches S2-S8 The simplest and cheapest component
digital outputs for control of external can be omitted, but R2 must be on the board, however, is often the one
devices like sounders, lamps, ampli- retained to keep input A0 pulled high. that’s forgotten, causing major
fiers, signal routers, door locks, you The PIC ticks at 4 MHz as determined headaches and dozens of unnecessary
name it, anything can be controlled as by quartz crystal X1 and its usual pair emails of the ‘Help it don’t work’ type!
long as it has a simple 0/5 V (TTL) dig- of small satellite capacitors, here iden- We’re talking about the infamous wire
ital control input, or can be switched on tified as C7 and C8. The user-defined link. There are seven of them on the
and off with a few mA of drive current. settings are read from DIL switch S9. board and they are best fitted before
The ‘Output Immediate’ output goes One LED, D1, has been included to any other component so they’re not
high immediately after triggering and acts as a ‘PIC awake’ indicator (very forgotten. Bolt the voltage regulators
remains high until end of playback. useful!). Capacitors C5 and C6, finally, onto a common heatsink (see Figure 3
The other output called ‘Output Delay’ ensure the 5-V supply voltage to the and the parts list), insulating washers
goes high only after playback has PIC remains as clean as possible. are not required as all metal tabs are
started (that is, after any spin-up delay) The circuit has been designed to oper- connected to ground. The PIC being
and remains high until end of playback. ate from a single 15-18V DC supply, the most expensive part, it deserves to
which should be ‘heavy’ enough to also be fitted into a 40-way DIL socket with
supply the drive’s 12-V line. Two paral- good quality contacts.
Circuit and leled 7805 fixed voltage regulators, IC3 Although the circuit diagram suggests
construction and IC4, provide +5 V for the PIC and that there are rather a lot of wires and
The circuit diagram shown in Figure 1 the CD-ROM drive’s 5 V line. The 12- other things to connect to the board, in
has few surprises, basically showing a volt supply is realised in a similar way reality the situation is not that bad as
microcontroller sitting between a by two 7812s in parallel. Alternatively, you can see from Figure 4. The cables
IC3
IC4
IC1
C9 C10
0V
C11
C12
C13
C14
C2
C3
C4
K5
+
+5V
+12V
0V
0V
K1
030402-1
C1
0
C7
C8
C6
K4
R12
X1
R1
IC5
C5
R9
R8
R7
R6
R5
R4
R3
S9
R2
R11
R10
D1
K3
K2
S8
S7
S6
S5
S4
S3
S2
S1
DELAY
TRIG
0V
IMM
8xS
between the board and the CD-ROM CD-ROM drive inactivity timeout).
initialisation drive, for example, are ready-made The READ SUBCHANNEL command is
ones pulled from the junkbox or an old used at various points in the above
wait a computer. sequence, whenever the program
few seconds
needs to know if playback is currently
in progress or if playback has finished.
Program
READ TOC The program that runs inside the PIC
error
? micro has been written in assembly Testing
language. The source code and hex file As usual, check for the presence of 5-V
store TOC in are available on floppy disk (anyone before inserting the PIC chip. The mod-
RAM
out there still using these?) or as free ule can then be tested without con-
downloads from the Publishers’ web- necting to a CD-ROM drive. Simply
send SEEK
site. If you wish to program your own power up and check that the LED on
trigger
detected command PIC, please feel free to do so using the pin A4 flashes a few times. Nothing
? if appropriate
files supplied. Alternatively a pre-pro- else will happen, but this confirms that
grammed PIC is available from Read- the PIC is up and running. Switch off,
select track based
on ers Services, the order code being connect to CD-ROM drive, power up.
mode and options 030402-41. The LED should flash a few times and
The source code supplied by Ken then continue to flash until a disc is
get track start
and end point Bromham is well worth studying, even inserted, the tray is closed and the TOC
from stored TOC if you do not build the project. Ken suc- (table of contents) successfully read.
ceeded in including plenty of com- When the LED stops flashing, the mod-
send ments so if you are familiar with this ule is ready to respond to a trigger and
PLAY AUDIO MSF
command assembly language it should be possi- the different options can be experi-
ble to follow the program, despite mented with.
some classic spaghetti code. If not, you Note that the CD-ROM drive must be
error
? may still want to grasp the ‘broader configured as a MASTER device, and
lines’ offered by the flowchart of the pin 1 on the PCB socket (K4) must go
main program shown in Figure 5. to pin 1 on the CD-ROM ATA interface
playback starts
The actual ATAPI commands used by socket (usually indicated by a red wire
the PIC firmware are: in the ribbon cable). When used with a
check DIL switch single 12-V DC supply make sure this
#4
PLAY AUDIO MSF (play from specified supply can provide a minimum of
start to end location. MSF = Min- about 1.2 A. The audio output can be
wait for playback
to finish utes, Seconds, Frames, 75 Frames taken from the analogue out on the
030402- 13 = 1 Second). back of the CD-ROM drive or from the
READ TOC (get the table of contents). headphone jack a the front. To continue
READ SUBCHANNEL (used to get the the low-cost theme, we recommend a
Figure 5. Use this flowchart of the current audio status). cheap pair of active ‘multimedia’
main program if you don’t fancy SEEK (position the head at start of speakers (whatever that means),
reading assembly code but still want to track 1, but will also cause the disc unless, of course, you really want to
understand how the software works. to spin up, so used to defeat the build your own amplifier!
– a voice message system employing the public address sound – a language training aid.
equipment in a large building. Very useful for guiding the pub-
lic to fire exits in case of an emergency, when written notices – a spoken Callsign / ‘CQ Contest’ generator for radio ama-
are hardly ever seen, let alone read. teurs.
– an electronic dog barking in response to your doorbell; a track For all of the above applications, you will need to burn your own
with More & Fiercer Dogs for really persistent callers that music CD. Programs to compile music or sound samples onto
push the bell a second time (Pandora must have heard of your own CDs abound in PC land, CoolEdit being one of the best
Cerberus), gunfire for a third time, then police sirens, and so known. Note however that you can’t use MP3 files just like that
on. — a suitable decoder will have to be added.