Está en la página 1de 8

Arduino MIDI Synthesizer

Paul Halpin

BSc Music, Multimedia and Electronics

ELEC2645 Embedded Systems Project

School of Electronic and
Electrical Engineering
FACULTY OF ENGINEERING




Session 2010 / 2011
Student ID 200481604

Contents
1. Abstract 2
2. Introduction 2
3. Software Overview 2
4. Hardware Overview 4
5. Testing 5
6. Conclusion 6
7. References 7
1
!" $%&'()*'
1he basls of Lhls module was Lhe deslgn and creauon of a mlcroconLroller-based embedded
sysLem - ln my case a Mlul-conLrolled synLheslser. 1hls ls a compleLe self-conLalned producL LhaL
can lnLerpreL an lncomlng Mlul slgnal from a 3-pln uln connecuon and LranslaLe lL lnLo a plLched
square-osclllaLor. 1he sound ouLpuL ls Lhen elLher senL Lhrough an ln-bullL speaker or senL Lo a
3.3mm audlo ouLleL LhaL can be plugged lnLo many devlces (mlxer, headphones). 1he ouLpuL can
be selecLed by Lhe user by a Loggle swlLch. 1he user can furLher manlpulaLe Lhe sound by denlng
a noLe lengLh uslng Lhe knob on Lhe Lop of Lhe enclosure. 1hls reporL ouLllnes Lhe dlerenL sLages
lnvolved ln Lhe compleuon of Lhls pro[ecL.
+" ,-'(./0*1.-
1he Ardulno ls a popular devlce for proLoLyplng pro[ecLs LhaL lnLegraLe hardware and soware by
programmlng a mlcroconLroller. 1he devlce ls accompanled by a plece of slmple deskLop soware
LhaL allows Lhe user Lo creaLe programs for Lhe mlcroconLroller ln an easy program language called
Wlrlng", a modled verslon of C/C++ LhaL makes deslgnlng lnpuL/ouLpuL appllcauons much
easler.
[1]
1hls meLhod of deslgnlng embedded sysLems can brlng LogeLher many dlerenL areas of
elecLronlcs wlLhouL havlng Lo creaLe new lnLerfaces beLween Lhem. 1he Ardulno mlcroconLrollers
can operaLe a varleLy of componenLs from servos Lo LCu dlsplays - mosL commonly uslng loglc
funcuons ln and ouL of Lhe mlcroconLroller plns or a sLream of serlal daLa from a slngle pln.
1he facL LhaL l am enrolled as an M.M.L sLudenL was ma[or facLor ln Lhe process of decldlng
whaL my pro[ecL was golng Lo be. l LhoughL lL would be lnLeresung Lo research dlerenL muslcal
opporLunlues avallable uslng Lhe Ardulno. 1here are many webslLes where people share and
dlscuss ldeas relaung Lo Ardulno pro[ecLs, and a large selecuon of Lhese are muslcally relaLed. ln
Lhe wlrlng llbrary for Lhe Ardulno.
2" 3.45)(6 786(8965
1he mosL baslc form of muslcallLy ls avallable ln Lhe form of Lhe Lone() funcuon, Lhls ls a modled
verslon of wlrlng's pulse-wldLh modulauon llbrary, where lnsLead of belng able Lo ad[usL Lhe duLy
cycle, Lhe user can change Lhe frequency and lengLh values of a noLe aL a parucular ouLpuL pln.
1hls ls Lhe maln funcuon LhaL my pro[ecL uullses.
1he soware secuon of Lhe code relles on a small secuon of Lhe Ardulno Mlul llbrary.
[2]
1hls
llbrary makes lL easy Lo seL Lhe baud raLe Lo 31230 (Mlul-compllanL), lnLerpreL and generaLe Mlul
serlal daLa. 1he only Mlul daLa l am concerned wlLh ln my pro[ecL ls noLe daLa. 1hls comes as Lwo
byLes ln Lhe serlal.
llrsLly, my program analyses all lncomlng Mlul messages and lLers ouL noLeCn'
messages. When a noLeCn" message ls recelved, Lhe sound()" funcuon ls called. lf Lhe second
byLe (Mlul.geLuaLa2 - Lhls conLalns Lhe veloclLy and durauon lnformauon) ls noL greaLer Lhan 0,
Lhe funcuon wlll end.
Slnce Lhe Lone() ouLpuL only has one veloclLy, l don'L use Lhe daLa from Lhe second byLe.
lnsLead l have a poLenuomeLer Lo ad[usL Lhe durauon of Lhe noLes. 1he program Lhen analyses Lhe
rsL byLe (Mlul.geLuaLa1) Lo geL Lhe plLch of Lhe noLe (beLween 0-127). 1he correspondlng
frequency ls Lhen deLermlned from my array declared aL Lhe sLarL of Lhe code (lnL Mlul[128]). 1hls
frequency, comblned wlLh Lhe currenL mapped value of Lhe poLenuomeLer ls applled Lo a Lone()
funcuon wlLh Lwo varlables and Lhe noLe lndlcaLor LLu ls acuvaLed. Pere ls an overvlew of Lhe
program:

2
!"#$"%!"&'
()*+#$) -+&.#+
/#$0#.+)1
203" 45(56789:;<
1)"='2<
>=3*?&3
+&&'2<
>=3*?&3
()*+#$) @&*#+
/#$0#.+)1
5A 45(5BC)"(#"#8
D E
(0C0"#+
F03 8 G
H5-H
(0C0"#+ F03
9 G 3&I&3)
JK!
45(5B$)#L
45(5BC)"IM')
5A "M') G
N&")O3
(0C0"#+
F03 8 G
@OP
NO
!)" O="'="1Q 53'="1
1&=3L2<
>=3*?&3
JK!
+&&'2<
>=3*?&3
1&=3L2<
>=3*?&3
03" 3 G
45(5BC)"(#"#7
03" '0"*R G S0L063:
#3#+&CT)#L F03 E
G 1=1"#03
1=1"#03 G
S#'21=1"#03Q
EQ7E8UQUEQ7EEE<
"&3)
'03 9
A$)V=)3*M G '0"*R
L)+#M G 1=1"#03
!"&'
!"#$"
2N&") @K(<
2N&") @K(<
2!')#W)$ F03<
2X&3Y)$" 45(5 3=S.)$
"& A$)V=)3*M<
2F&")3?&S)")$ 03'="<
2!=0"#.+) /#+=)1 A&$ L)+#M<
24#03 1&=3L &="'="<
NO
XR)*W1 "& 1)) 0A "R)$) 01
03*&S03C 3&") L#"#
3
8efore decldlng on uslng an array Lo sLore Lhe frequency values, l experlmenLed wlLh an algorlLhm
LhaL converLed Lhe Mlul number lnLo Lhe acLual frequency:
frequency = 440 * 2^((n-69)]12)
(Where n" ls Lhe Mlul number)
1hls gave a frequency accuraLe Lo as many declmal places as you need buL l ran lnLo errors when
Lesung lL ouL on Lhe hardware. l belleve LhaL lL ls because of physlcal llmlLauons ln Lhe
mlcroconLroller, LhaL lL can'L calculaLe lndlces of LhaL scale on Lhe y.
4. nardware Cverv|ew
MosL of Lhe componenLs ln my pro[ecL are housed ln Lhe enclosure, away from Lhe board.
OUTSOURCED COMPONENTS
-On switch
-Output toggle
-MIDI connector
-Audio jack
-Speaker
-Potentiometer
-Red LED
-Blue LED
-Battery Clip / 9V Battery
CIRCUIT BOARD COMPONENTS
-Voltage regulator (9V -> 5V)
-16MHz crystal oscillator
-ATMega328P chip
-Op amp
-Resistors / Capacitors
19 connections
1hls secuon of Lhe schemauc ouLllnes
Lhe power regulauon ln Lhe clrculL.
1he lC ln Lhe cenLre converLs a 9v
bauery's volLage Lo 3v - a safe
operaung level for Lhe A1Mega328.
4
Pere, you can see Lhe resL of my clrculL. LxcepL for Lhe op amp, osclllaLor and a few reslsLors, Lhe
componenLs LhaL appear Lo be auached Lo Lhe maln lC are [usL Lhrough-holes for exLernal
componenLs.
1he poLenuomeLer ls connecLed beLween ground and +3v so Lhe user can dene a volLage
beLween Lhe Lwo polnLs, lL ls processed by Lhe 10 blL analog Lo dlglLal converLer on-board Lhe
A1Mega328 and mapped Lo deslred values ln Lhe programmlng code.
1he Cp amp clrculL requlred no feedback or blas reslsLors as lL nauvely gave a galn of 20,
and Lhls was a reasonable volume for Lhe bullL -ln speaker. 1he alLernauve ouLpuL aL Lhe 3.3mm
[ack has a 220U reslsLor ln serles Lo reduce Lhe volume aL Lhe ouLpuL. lL creaLes a comforLable
volume for headphones and a decenL llne volume also.
1he power and noLe lndlcaLor LLus have 220U currenL-reduclng reslsLors ln serles Lo supply
Lhem wlLh Lhe approprlaLe currenL level. 1he 8eseL swlLch works as a pull-up reslsLor when Lhe
swlLch ls pressed.
1he serlal lnpuL from Lhe Mlul sockeL ls allocaLed Lhe Lhe 8x" pln on Lhe A1Mega328, Lhls
ls Lhe only pln LhaL can read lncomlng serlal daLa Lhere ls also a 1x" pln LhaL ls reserved for
Lransmlmng serlal daLa.
S. 1esnng
When assembllng Lhe pro[ecL, l dlscovered Lhere were errors wlLh Lhe C8, largely due Lo Lhe facL l
mls-labelled slgnal paLhs. l LesLed Lhe clrculL wlLh baslc programs Lo swlLch on LLus or make a
nolse Lhrough Lhe speaker. When l dlscovered Lhe clrculL was noL playlng any of Lhe LesL programs,
l knew Lhere was someLhlng wrong wlLh Lhe C8, so l LranslaLed Lhe deslgn lnLo veroboard LhaL
worked as planned. l correcLed my C8 deslgn for Lhls reporL:
5
Cne dlerence beLween Lhe Lwo clrculLs ls Lhe absence of Lhe op amp ln Lhe veroboard
deslgn. l used a dlerenL volLage regulaLor Lo Lhe one used on Lhe C8. 1hls new regulaLor
provlded less currenL Lhan Lhe orlglnal and wasn'L qulLe enough Lo fuel Lhe amp wlLhouL Lurnlng
Lhe whole synLh o. 1he speaker sull glves a reasonable volume and Lhe 3.3mm sockeL dldn'L use
Lhe op amp, so LhaL sull works as lL should.
1o LesL Lhe acLual funcuonallLy of Lhe synLheslser, l connecLed up a Mlul cable from my
lapLop and had a compleLe range of noLes playlng aL varlous speeds, l LesLed boLh Lhe speaker
ouLpuL and Lhe 3.3mm [ack ouLpuL. 1he connecuon ln Lhe [ack was a llule loose, so you have Lo
play around wlLh Lhe cable Lo geL sound Lhrough boLh channels. l also LesLed a dlrecL Mlul
connecuon from my keyboard Lo Lhe synLh, Lhls worked [usL as well.
6. Conc|us|on
lf l were Lo conunue on Lhls pro[ecL and lmprove lL somehow, l would Lry Lo lncorporaLe some
furLher slgnal processlng Lo creaLe umbres oLher Lhan a square wave. 1hls would probably requlre
oLher lCs Lo process Lhe pulse wave. subLracuve synLhesls would be a vlable opuon. l could creaLe
modular eecLs LhaL Lhe user could dene, such as an LlC or envelope.
1he ouLpuL slgnal could also be modled Lo be aL a more sulLable level for dlglLal audlo by
uslng a blased op amp Lo llmlL Lhe ouLpuL d8.
l qulLe llke Lhe ldea of a pro[ecL-ln-progress Lo be on veroboard, as Lhls ls much easler Lo
expand on and creaLe new secuons - unless Lhe pro[ecL uses surface mounL componenLs or lL
requlres a hlgh componenL denslLy, veroboard ls a good way Lo deslgn. A C8 would be preferable
once lL ls compleLe because lL can be repllcaLed wlLh Lhe soware deslgn and Lhey are usually of a
hlgher bulld quallLy Lo veroboard, meanlng Lhey wlll lasL longer.
6
!"#"$"%&"'
[1] "!"#"$% '($%)(%* +,-./". 17 May 2011. < hup://wlrlng.org.co/reference/ >.
[2] ",#0)"$1 2.3. '"4#(#5". 17 May 2011. <hup://sourceforge.neL/pro[ecLs/ardulnomldlllb/ >.
7

También podría gustarte