Está en la página 1de 13

let's make

Explore(/tag/typeid/)

Publish(/about/create.jsp)
Login(/account/login/) | SignUp(/account/gopro)

Classes(/classes/)
Featured: share what
(/id/intel/)
IntelIoT(/id/intel/)
you make
(/)
(/tag/typeid/categorytechnology/channelarduino/) Arduino(/tag/typeid/categorytechnology/channelarduino/)
(/tag/typeid/categorycraft/channelknittingandcrocheting/) Yarn(/tag/typeid/categorycraft/channelknittingandcrocheting/)
(/tag/typeid/categoryworkshop/channellighting/) Lighting(/tag/typeid/categoryworkshop/channellighting/)

AboutThisInstructable
8 324,072 views

License:

490 favorites
amandaghassaei
(/member/amandaghassaei/)
uhmanduhgusseyedotcom
(http://www.amandaghassaei.com)

(/member/amandaghassaei/)
Follow
3240

(/file/F8GZNXPH7KZ2FVW/)

GeneratesoundoroutputanalogvoltageswithanArduino.ThisInstructablewill
showyouhowtosetupareallybasicdigitaltoanalogconvertersoyoucanstart
generatinganalogwavesofallshapesandsizesfromafewdigitalpinsonan
Arduino.(ThisarticleisacompaniontoanotherInstructableI'vewrittenabout
sendingaudiointoanArduino,findthathere
(http://www.instructables.com/id/ArduinoAudioInput/))
Someideasthatcometomind:
samplebasedinstrumentstoresamplesontheArduinooronanSDcardand
triggerplaybackwithbuttonsorothertypesofcontrols.CheckoutmyArduino
drumsampler(http://www.instructables.com/id/ElectronicInstrument/)foran
ideaofhowtogetstarted.
digitalsynthesizermakesaw,sine,triangle,pulse,orarbitrarywaveshapes
checkoutmywaveformgenerator
(http://www.instructables.com/id/E7T6UN2H12SVHY8/)togetstarted
MIDItocontrolvoltagemodule/MIDIsynthesizerreceiveMIDImessages
(http://www.instructables.com/id/SendandReceiveMIDIwithArduino/)and
translatethemintoavoltagesoyoucancontrolananalogsynthesizerwith
MIDI,orusetheMIDIdatatooutputaudioofacertainfrequency
analogoutputyoumayfindyourselfneedingtogenerateanalogvoltagesfrom
yourArduinoatsomepoint,maybetocommunicatewithananalogdevice
effectsbox/digitalsignalprocessingincombinationwithamicrophone/audio
input(http://www.instructables.com/id/ArduinoAudioInput/)youcanperformall
kindsofdigitalsignalmanipulationsandsendtheprocessedaudiooutto
speakers.Checkoutmyvocaleffectsbox
(http://www.instructables.com/id/ArduinoVocalEffectsBox/)foranexample.
audioplaybackdevicemakeyourownipod.WiththeadditionofanSDshield
youcouldcreateyourownArduinomp3player(checkoutthewaveshield

Bio:I'magradstudentattheCenterfor
BitsandAtomsatMITMediaLab.Before
thatIworkedatInstructables,writingcode
for...More(/member/amandaghassaei/)
Morebyamandaghassaei:

(/id/OTCA

MetapixelConwaysGameofLife/)

(/id/9Degreesof

FreedomIMU/)

(/id/TwitterControlledPetFeeder/)

Related

(/id/Speech

SpeechRecognitionand
SynthesiswithArduino
(/id/SpeechRecognitionand
SynthesisWithArduino/)
byleandro4b
HowtouseanICDAC
(/id/HowtouseanICDAC/)
byJColvin91

(/member/JColvin91/)

(http://www.adafruit.com/products/94)documentationforanideaofhowtoget
startedwiththecode).Thecircuitsandcodeprovidedherearecompatiblewith
SDshieldsthatcommunicateviaSPI.
Feelfreetouseanyoftheinfoheretoputtogetheranamazingprojectfor
theDIYAudioContest(http://www.instructables.com/contest/audio/)!
We'regivingawayanHDTV,someDSLRcameras,andtonsofothergreat
stuff!ThecontestclosesNov26.
PartsList:
(x9)1/4Watt20kOhmResistorsDigikey0KQBKND
(http://www.digikey.com/productdetail/en/CFR25JB5220K/20KQBKND/880)
(x7)1/4Watt10kOhmResistorsDigiikeyCF14JT10K0CTND
(http://www.digikey.com/productdetail/en/CF14JT10K0/CF14JT10K0CT
ND/1830374)
(x2)TS922INDigikey49730495ND
(http://www.digikey.com/scripts/dksearch/dksus.dll?
vendor=0&keywords=ts922in)Ilikethesebecausetheycanbepoweredoffthe
Arduino's5Vsupply(one924workstoo,buttheydon'tseemtobeavailableon
digikey(http://www.digikey.com/productdetail/en/TS924IN/TS924IN
ND/1040358)atthemoment)
(x1)10kOhmpotentiometerlinearDigikey9871308ND
(http://www.digikey.com/productdetail/en/P160KN0QD15B10K/9871308
ND/2408885)
(x1)0.01uFcapacitorDigikey4455252ND(http://www.digikey.com/product
detail/en/FK28X7R1H103K/4455252ND/2256732)
(x1)220uFcapacitorDigikeyP5183ND(http://www.digikey.com/product
detail/en/ECA1HM221/P5183ND/245042)
(x1)0.1uFcapacitorDigikey4455303ND(http://www.digikey.com/product
detail/en/FK18X7R1H104K/4455303ND/2256783)
(x1)1/4Watt3kOhmResistorDigikeyCF14JT3K00CTND
(http://www.digikey.com/productdetail/en/CF14JT3K00/CF14JT3K00CT
ND/1830361)
(x1)1/4Watt10OhmResistorDigikeyCF14JT10R0CTND
(http://www.digikey.com/productdetail/en/CF14JT10R0/CF14JT10R0CT
ND/1830306)
(x1)ArduinoUnoAmazon(http://amzn.to/1JGTEPT)
AdditionalMaterials:
(1x)usbcableAmazon(http://amzn.to/1TRcNz2)
(1x)breadboard(thisonecomeswithjumperwires)Amazon
(http://amzn.to/1JGTTup)
(1x)jumperwiresAmazon(http://amzn.to/1JGTUOV)

Step1:DigitaltoAnalogConverter

ArduinoAudioInput
(/id/ArduinoAudioInput/)
byamandaghassaei
(/member/amandaghassaei/)
(/id/Arduino

(/file/FGYC0NCH742FUAL/)

(/file/FDST2OAH7431PG5/)

(/file/FKGRU1UH74326MJ/)

DACstandsfor"digitaltoanalogconverter."SincetheArduinodoesnothave
analogoutcapabilities,weneedtouseaDACtoconvertdigitaldata
(numbers/ints/bytes)toananalogwaveform(oscillatingvoltage).Asimple,easy
toprogram,andcheapwaytodothisistousesomethingcalledanR2Rresistor
ladder(http://en.wikipedia.org/wiki/Resistor_ladder).Essentially,ittakes
incomingdigitalbits(0Vand5VfromArduino),weightsthem,andsumsthemto
produceavoltagebetween0and5volts(seetheschematicinfig2,takenfrom
theWikipediaresistorladderpage(http://en.wikipedia.org/wiki/Resistor_ladder)).
Youcanthinkofaresistorladderasamultileveledvoltagedivider
(http://en.wikipedia.org/wiki/Voltage_divider).
TheresistorladderI'llbedemonstratinginthistutorialisan8bitDAC,this
meansitcanproduce256(2^8)differentvoltagelevelsbetween0and5v.I
connectedeachofdigitalpins07toeachofthe8junctionsinmy8bitDAC
(showninfigs1and3).
IlikeusingtheseresistorladderDACsbecauseIalwayshavethematerials
around,they'recheap,andIthinkthey'rekindoffun,buttheywillnotgiveyou
thehighestqualityaudio.Youcanbuyachipthatworksintheexactsamewas
asanR2RDAC(andwillworkwithallthecodeinthisinstructable),buthas
internal,highlymatchedresistorsforbetteraudioquality,Ilikethisone
(http://www.digikey.com/productdetail/en/TLC7528CN/29618715ND/277516)
bcitrunsoffasingle5Vsupply(youcanevendostereoaudio
(http://www.instructables.com/id/StereoAudiowithArduino/)withit),butthere
aremanymoreavailable,lookfor"parallelinput,8bit,dacic".
Alternatively,therearechipsthattakeinserialdatatoperformdigitaltoanalog
conversion.Thesechipsaregenerallyhigherfidelity(definitelybetterqualitythat
theresistorladderDAC)andtheyonlyusetwoorthreeoftheArduino'soutput
pins(asopposedto8).Downsidesaretheyarealittlemorechallengingto
program,moreexpensive,andwillnotworkwiththecodeinthisInstructable,
thoughI'msuretherearesomeothertutorialsavailable.Afteraquicksearchon
digikey,these(http://www.digikey.com/productsearch/en?
pv243=79&pv243=87&pv243=23&pv243=78&FV=fff40027%2Cfff80184%2C114

0050%2C2640002&k=dac&mnonly=0&newproducts=0&ColumnSort=0&page=1
&quantity=0&ptm=0&fid=0&pageSize=25)lookedgood,forArduino,trytofind
somethingthatwillrunoffasingle5Vsupply.
Onemorenotethereseemstobekindofamisconceptionabut8bitaudio
thatitalwayshastosoundlikethesoundseffectsfromaMariogamebut8bit
audiowiththisreallybasicDACcanactuallyreplicatethesoundsofpeople's
voicesandinstrumentsreallywell,I'malwaysamazedatthequalityofsound
thatcancomefromabunchofresistors.

Previous

Next(/id/ArduinoAudioOutput/step2/SetupDACandTest/)
Download

ViewAllSteps(/id/ArduinoAudioOutput/?ALLSTEPS)

Wehaveabenicecommentpolicy.

Pleasebepositiveandconstructive.

wIMadeit!

AddImages PostComment

adrianio(/member/adrianio)

9daysago

Reply

Hello!Nicetutorial.IwanttomakealowpassfilterlikeyouforArduino
toneAC().WithtoneAC,we'resendingoutofphasesignalsontwopins.How
willIconnecttheresistorandcapacitor?Ineedtworesistorsandtwocapacitors
connectedbetweeneverypinandground?Orissufficientoneresistorandone
capacitorbetweenonepinandground?

DebojitK(/member/DebojitK)

5monthsago

Reply

Ididatestonthetimingsofdirectportwrite.Iusedthefollowingpins:
PB1,PB0,PD7,PD6,PD5,PD4,PD3,PD2()leavingPD1andPD0forrx/tx).
PORTD=(PORTD&B00000011)|((input<<2)&B11111100)
PORTB=(PORTB&B11111100)|((input>>6)&B00000011)
Thesetwolinessettheinputontheaforementionedpinswithdirectbitbanging
writemethoddescribed.TheresultisastonishingItonlytakes~1.6usecto
executethesetwolines.Soforinterruptserviceroutineyougetampletimeto
dootherprocessing.
Hereisthecode:
#include"Arduino.h"
//Thesetupfunctioniscalledonceatstartupofthesketch
uint8_tinput=100
StringinputString=""
voidsetup()
{
//Addyourinitializationcodehere
Serial.begin(115200)
}
//Theloopfunctioniscalledinanendlessloop
voidloop()
{
//Addyourrepeatedcodehere
testSerialEvent()

longsTime=millis()
for(longi=0i<100000i++){
PORTD=(PORTD&B00000011)|((input<<2)&B11111100)
PORTB=(PORTB&B11111100)|((input>>6)&B00000011)
}
longeTime=millis()sTime
Serial.println(eTime)
Serial.print("[")
for(inti=1i>=0i){
Serial.print(((PORTB&(1<<i))>>i))Serial.print("")
}
for(inti=7i>=2i){
Serial.print(((PORTD&(1<<i))>>i))Serial.print("")
}
Serial.println("]")
delay(1000)
//outputeverylooptakes170msecthatmeanoneiterationtakes~1.7usec.Its
toogood.
}
voidtestSerialEvent(){
while(Serial.available()){
charc=(char)Serial.read()
inputString+=c
if(c=='\n'){
input=inputString.toInt()
inputString=""
Serial.print("Input>")Serial.println(input)
break
}
}
}

chrisdefrancisci(/member/chrisdefrancisci)

5monthsago

Reply

Hello,Ithinkthistutorialiswonderful,thankyousomuchforpostingit,however
I'verunintoaproblemnow.WhenIhooktheArduinouptoanoscilloscope,it
showsaperfectsinewave.However,whenIplugmyArduinointomyaudio
interface,soIcanrecordtheoutputonmycomputer,thesignalbecomes
truncatedandonlyhasapeaktopeakvoltageof80mV.Couldyoupleasehelp
meunderstandwhythisishappening,andwhatIcandotofixit?
Thankyou.

AndreaS76(/member/AndreaS76)

8monthsago

Reply

HiAmanda,
thankyouverymuch,allthisisgreat.
Iwouldusethisprojecttogenerateawaveandsplitthesignalfromoneoutput
tomultipleguitarampsthroughsomethinglikeaplugboard(Ibelieveitwillbe
connectedinparalel),doineedtochangesomethingintheschemetosenda
goodsignaltoallthespeakers?
Thankyou:)

gabor64(/member/gabor64)madeit!

10monthsago

Reply

HiAmanda,
thxforthebrilliantproject.Isentthe6mostsignificantbitstoPORTDand2to
PORTB.Iusedthefollowingcommandstodecreasethediscontinuitiesas
muchaspossibleandalsospeeduptheoutputbyusingjustoneinstructionper
port:

PORTD=x[i]&B11111100|PORTD&(x[i]|B00000011)
PORTB=x[i]&B00000011|PORTB&(x[i]|B11111100)
NowIgoontotheanalogpart.
Thx,rgds,
Gabor

(https://cdn.instructables.com/FS0/32M2/IKA08HFK/FS032M2IKA08HFK.LARGE.jpg)

PaulC175(/member/PaulC175)

11monthsago

Reply

11monthsago

Reply

thankyouforthisexcellentproject

LucianM4(/member/LucianM4)

Hiamandaghassaei(http://www.instructables.com/member/amandaghassaei/)!
Nicework!
Itryingtodothisprojectbutihaveonebigproblem.Ican'thindTS922IN/24in
mycountry!andidon'thaveenoughtimetobuyfromotherone.Isn'tan
alternativeforTS922IN/24?

henroljeo.gutierrez(/member/henroljeo.gutierrez)

ayearago

Reply

HelloSir,IwanttooutputananalogSignalusingthistutorial,butmyproblemis
Iwantmyinputtobedigital,whatImeanis,someoneisgoingtosendmea
bunchofbitsandthenIwanttooutputthemintoanalog,MyproblemisIdont
knowhowtoreadthatincomingbitsinmyarduino.Doyouhaveanycodesfor
readingabitsinthepinofarduino.?

syikas93(/member/syikas93)

henroljeo.gutierrez(/member/henroljeo.gutierrez)
ayearago

Reply

ayearago

Reply

2yearsago

Reply

NeeravP(/member/NeeravP) 2yearsago

Reply

diduhvegettheans,ifyes...canushareit=)

JuanSebastianO1(/member/JuanSebastianO1)

NeeravP(/member/NeeravP)

heycaniuse8analogoutputfromArduinoUNO.

PaulS20(/member/PaulS20)

Interestingquestion,butIseethreeproblemswithit:
1)TheUnoonlyhas6analogoutputpins3,5,6,9,10,and11.
2)Thearenottrueanalog,butinsteadusesquarewavesfor"PulseWidth
Modulations",Asaresult,they'dbeplayingtonesofapproximately490Hz
and980Hzintoyoursound.
3)Youneedtouseeightpinsthatareallpartofaneightbitportsothat
youcanenteronenumber,suchasPORTD=125settingalleight
pinsatonce.Otherwise,you'dhavetosetonepinatatimewith

digitalWrite()(oranalogWrite)whichwouldtaketoomuchtimetokeepup
withyoursoundwaves.

KaushikK1(/member/KaushikK1)

2yearsago

Reply

Hey..
Firstoff,thankyouforthegreattutorials.
I'mtryingtoincorporateyourinstructableintomy"Arduinoshortrangewalkie
talkie"project.
I'musingamemsmic(https://www.sparkfun.com/products/9868)torecordmy
voice.Canyouhelpmeoutwithhowtoreducelagduringtranmission?
I'vetrieddecreasingdelayduringinputbutthatrallydoesntseemtodothejob.

m_osik(/member/m_osik)

2yearsago

Reply

HIall,
atfirstiwouldliketoTHNXforcooltutorial.
ItriedtouseasoutputconverterMCP4921(withAH_MCP4921.h)butiamnot
abletogetany"audible"sounds.HaveanybodytriedthisD/Aconverterwith
thissolution?
Bestregards
Jan

zacaj(/member/zacaj)

3yearsago

Reply

Hi,thanksforthisgreattutorial!
I'vegotlimitedinputs,soIwaslookingatusingaserialinDACchipinsteadof
usingaladder,doyouthinkthatthishttp://www.digikey.com/product
detail/en/MCP4901E...(http://www.digikey.com/productdetail/en/MCP4901
E%2FP/MCP4901E%2FPND/2332819)(MCP4901E/P)wouldwork?CouldI
justdropitintoyourschematicaslongasIhandletheprogrammingcorrectly?
Also,Ihopetopowersomecomputerspeakers(withtheirownamp/volume
control)usingthiscircuit.Sincethey'dhavetheirownvolume,IassumeIdon't
needtoinstallapotentiometer?Wouldthesamebufferwork,orwouldIneed
somethingbiggertosupportlouder/largerspeakers?
Thanks

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

zacaj(/member/zacaj)
3yearsago

Reply

Yeahthatchiplooksgood,but(asyoumentioned)the
codewillhavetochangeabit.Ifyourspeakershavetheirownamp,you
canprobablygetawaywithconnectingtheoutputofthebuffertotheinput
ofyourspeaker'samp.It'spossibleyoumayneedalittlepreampinthere,
inthatcaseyoucanusetheampinmyschematicwaresistorinplaceof
thepotentiometer.

zacaj(/member/zacaj)

amandaghassaei(/member/amandaghassaei)

Reply

2yearsago

ItalsoseemsI'mgoingtoneedtorunoff3Vinsteadof5V.I
knowI'llneedadifferentDAC,butotherthanthat:IassumeI'llneeda
differentDCoffsetcapacitor?ArethereanyothercomponentsI'llneedto
change?

somethingsmart(/member/somethingsmart)

Hey,thanksforthetutorial!

3yearsago

Reply

Theinputtutorialworksgreat.Forthisone,though,TS922INDigikey4973049
5ND(http://www.digikey.com/scripts/dksearch/dksus.dll?
vendor=0&keywords=ts922in)isobsolete.IcalledDigikeyand
http://www.digikey.com/productdetail/en/TS922IDT/...
(http://www.digikey.com/productdetail/en/TS922IDT/49760351ND/1632064)
istheclosest,butit'sasurfacemountchip.Wearejustgonnasoldersome
wiresandgiveitago.

lynettequek(/member/lynettequek)

3yearsago

Reply

CouldthebitmanipulationbeusedtofreeupDigitalpins0and1forserial
communication?IhaveonlyoneserialcommunicationusedsoIcan'tuse
softwareserialforthat.Ihavethiscodesofar:
//bitmanipulation,sendingnumber36to0and1.PORTB:digitalPin813
//definevariables:
booleanbit0state
booleanbit1state
//inyourmainloop():
bit0state=(36&B00000001)>>0//getthezerobitof36
bit1state=(36&B00000010)>>1//getthefirstbitof36
//senddatatoportdw/odisruptingpins0and1
PORTD|=(36&B11111100)//sethighpinshighusingthenumber36withzeros
replacingbits0and1
PORTD&=(36|B00000011)//setlowpinslowusingthenumber36withones
replacingbits0and1

//senddatatoportbw/odisruptingpins9,10,and11,affect8,12and13???
PORTB|=0|(bit3state)|(bit5state<<4)|(bit6state<<5)//sethighpins
PORTB&=255&~(1bit3state)&~((1bit5state)<<4)&~((1bit6state)<<5)//set
lowpins
i'mstuckatthelastpartwhereisenddatatoportb,whichionlywanttoaffect
pins11and12,inreplacementofpins0and1.AmIontherighttracktodo
this?Thankssomuch!

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

lynettequek
3yearsago

(/member/lynettequek)

Reply

isthenumber36justanexample?youcansendoutnumberslessthan
64usingonlysixbits,soyouwouldn'tevenhavetoworryaboutpins8,
12,and13.
//senddatatoportdw/odisruptingpins0and1
PORTD|=((36<<2)&B11111100)
PORTD&=((36<<2)|B00000011)

lynettequek(/member/lynettequek)

amandaghassaei(/member/amandaghassaei)
3yearsago

Reply

thanksforyourreply!yup36isjustanexample.
followingwhatyoudidfortheinstructable:)whatifIwantto"shift"pins0
and1backtopins11and12?doIhavetoincludethispart?

//senddatatoportbw/odisruptingpins9,10,and11,affect8,12and13
PORTB|=0|(bit3state)|(bit5state<<4)|(bit6state<<5)//sethighpins
PORTB&=255&~(1bit3state)&~((1bit5state)<<4)&~((1bit6state)
<<5)//setlowpins

X
|
8

amandaghassaei(/member/amandaghassaei)(author)
(/member/lynettequek)

lynettequek
3yearsago

PORTB|=0|(bit0state<<4)|(bit1state<<5)//sethighpins

Reply

PORTB&=255&~((1bit0state)<<4)&~((1bit1state)<<5)//setlowpins
I'mprettysurethatwillworkforpins12and13

lynettequek(/member/lynettequek)

amandaghassaei(/member/amandaghassaei)

thankssomuch!willtryitout!

AbdulW87(/member/AbdulW87)

3yearsago

Reply

3yearsago

Reply

Thanksforthisinstructable,veryhelpful.CaniuseanAD712KNZsincethey
dontmakethe922anymore.

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

AbdulW87
3yearsago

(/member/AbdulW87)

Reply

yes,youmightalsocheckoutthelm386bcitdoesn'trequireadualpower
supply.

hopkinskong(/member/hopkinskong)

3yearsago

Reply

Hello,
Thanksforyourinstructable!Iamnowmanagedtousethistrickononeofmy
8051microcontroller!

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

(/member/hopkinskong)

hopkinskong
3yearsago

Reply

3yearsago

Reply

nice!

starock(/member/starock)

Tnankyousomuch~\()/~
1QuestionPlz:
HowcanIgenerateasoundlikeMarioGmae?ILove8Bitmusic.Makea8Bit
synthesizerismydream.T_T

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

(/member/starock)

starock
3yearsago

Reply

3yearsago

Reply

http://arduino.cc/en/Reference/tone

Reddyco(/member/Reddyco)

HeyAmanda!Greatjobonthisinstructable,I'musingittoembasemyworkon
aeletronicdrumsoundgeneratorwithArduino(hopefully,onedayI'llposthere
howtodoit).
I'mwritingtoaskabuotthat0.01uFand10ohmresistorinparallelwiththe
speakerandtheDCoffsetcapacitor.Whataretheyusedfor?
Thanksinadvance!

X
|
8

amandaghassaei(/member/amandaghassaei)(author)
(/member/Reddyco)

Reddyco
3yearsago

Reply

thanks!they'rejustthreretoreducenoise,notabigdealifyoudon'thave
them

flowirin(/member/flowirin)

3yearsago

Reply

what'stheupperlimitonthesamplingfrequencyforthearudino?canigetitup
to80kHz?

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

flowirin
3yearsago

(/member/flowirin)

Reply

definitely,youcouldgetuptoafewhundredkHzwithnoproblem.
OneconcernisthattheresistorladderdacthatIshowinthisiblemight
notrespondfastenoughasyouincreasethesamplingratethismight
endupapplyingalowpassfilteronyouroutput.Iupdatedstep1witha
littlemoreinfoaboutalternativeDACs,youmightcheckouttheR2RDAC
IC(http://www.digikey.com/productdetail/en/TLC7528CN/29618715
ND/277516)IdemonstratedinthisInstructable
(http://www.instructables.com/id/StereoAudiowithArduino/)(youcan
wireituptoonlyuseonechannelifyouneed),ithasmuchbetterquality
controlthenjustthrowingabunchofresistorstogetheronabreadboard
andIthinkitwillgiveyoubetterresults.Itsaysthesettlingtimeforthat
DACis100ns,whichshouldworkfinefor80kHzsamplingrate.
youwillalsohavetochangethefrequencyoftheinterrupt.For40kZI
usedthisline:
OCR0A=49//=(16*10^6)/(40000*8)1
trythisinstead:
OCR0A=24//=(16*10^6)/(40000*8)1

ibirnam(/member/ibirnam)

3yearsago

Reply

Justwantedtoconfirmthis:sincetheTS922INisnowobsolete,wouldthis
(http://www.mouser.com/Search/ProductDetail.aspx?
qs=UqMwQYdMOTar844FDvZpSw%3d%3d)beasufficientreplacement?
Thankyou!

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

ibirnam
3yearsago

(/member/ibirnam)

Reply

that'sgoingtobereallyhardtoworkwbcit'ssurfacemount.Justgetthe
lm386chipandacoupleofresistorsandcapacitorsandwireituplike
this:
http://www.hobbyhour.com/electronics/lm38620.gif
itmayneeda9vsupplyinsteadof5v,Ican'tremember.

heymarky(/member/heymarky)

amandaghassaei(/member/amandaghassaei)
3yearsago

Reply

I'mworkingmywaythroughthistryingtosubstitutethe
lm386atStep3.Thegifyoulinkedlookslikethereplacementforthe
amplifier.Icanseethepartthatreplacesthelowpassfilter(thanksto
yourexcellentexplanationofwhatthatis)butIdon'tseeanythingthatI
recognizeasbeingtheDACbuffer.Isthebufferunnecessarywiththe
lm386,orisitthereandIdon'trecognizeit?
Thanks!
PSI'masoftwareengineer,sousesmallwords.:)

X
|
8

amandaghassaei(/member/amandaghassaei)(author)
(/member/heymarky)

heymarky
3yearsago

Reply

actually,aresistorandcapacitoronlyactasalowpassfilterwhenthe
outputsignalisconnectedtothejunctionbetweenthem,here
(http://tuxgraphics.org/toolbox/circuitdesignrc.gif)isapic.Youcansee
thatswitchingtheorderofthecomponentswillturnitintoahighpass
filter.Thelm386circuitisnotwiredupthesameway,soitwon'tactasa
lowpassfilter.Sohere'swhatIwoulddo:
arduinodaclm386lowpassfilteroutput
youcouldalsouseatl1072ortl082toreplacebothts922's,butthese
requirea+/9vsupply,whichisannoying.

ibirnam(/member/ibirnam)

amandaghassaei(/member/amandaghassaei)

Reply

3yearsago

Awesome,thanksforthehelp!

waqarahmed236(/member/waqarahmed236)

ibirnam(/member/ibirnam)

IbirnamIsLM386workinginsteadofusingTS922IN?

joshuaphua1(/member/joshuaphua1)

3yearsago

Reply

3yearsago

Reply

neartheendofthecircuit,what'sthe0.1uFcapacitorand10Ohmresistorfor?
anotherkindoffilter?

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

(/member/joshuaphua1)

joshuaphua1
3yearsago

Reply

3yearsago

Reply

notafilter,justhelpsmaketheDCoffsetmorestable.

joshuaphua1(/member/joshuaphua1)

CanyouexplaintheDCoffsetmore?Iunderstandhowa+2.5VDCoffsetworks
butamconfusedaboutthisone.Thanks!

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

joshuaphua1
3yearsago

(/member/joshuaphua1)

Reply

Ialwaysthinkofitlikethis:thesignalgoingintoonesideofthecapacitor
causesanalternatingexcessofpositiveornegativechargeononesideof
thecap.Theothersideofthecapreactsbyaccumulatingoppositecharge
thiscausesanalternatingvoltageontheoppositesideofthecap.Since
nocurrent(oranegligibleamount)actuallygetspassedacrossthecap,
theDCvoltageononesidedoesnottransferovertotheotherside,sothe
alternatingvoltageiscenteredaround0.

joshuaphua1(/member/joshuaphua1)
(/member/amandaghassaei)

amandaghassaei
3yearsago

Reply

3yearsago

Reply

thanks!!

punk1290(/member/punk1290)

IhadtoreplacetheTS922withanLM386.Iamtryingtogetstep3working.
UnfortunatelyIdon'thaveanoscillatortoverifyIdidthingsrightinstep2.My
issueisthatwhenIconnectmyAdruinotomybreadboardwiththiscircuitthe
powerLEDdimsandmycomputernolongerseestheArduino.Itried
unhookingthebreadboardandthenloadingtheprogramtomyArduino.That
workedfine.WhenIconnectedeverythingbackup,theLEDcameon
immediatelywithoutrampingup.Anythoughtsorideasforme?

amandaghassaei(/member/amandaghassaei)(author)

X
|
8

punk1290
3yearsago

(/member/punk1290)

Reply

soundslikeyou'reshortingoutoneofthearduino'spowerpins(thestrip
ofpinsneartheanaloginputs).Doublecheckthose.

Ploopy(/member/Ploopy)

X
|
8

3yearsago

Reply

Howdidyouwriteyourcodeinthosesquaresthatyouscroll?

amandaghassaei(/member/amandaghassaei)(author)

X
|
8

Ploopy
3yearsago

(/member/Ploopy)

Reply

it'safeaturethat'sactuallynolongersupported,sorry!we'relookingat
newwaystomakecodeeasiertoembedintheeditor,itwillhappen.

avionics2(/member/avionics2)

3yearsago

Reply

ThankyousomuchformakingitclearnowIunderstandeverythingveryclearly
andthankyouformakingsuchaconcisetutorial.Myhatofftoyou.
takecareandpleasegiveusmoretutorials.

X
|
8

amandaghassaei(/member/amandaghassaei)(author)

avionics2
3yearsago

(/member/avionics2)

Reply

thanks!

I MoreComments

FEATURED CHANNELS

Woodworking

Paper

KitchenHacks

Puzzles

LaserCutting

Space

Homesteading

3DPrinting

Sewing

(/tag/type

(/tag/type

(/tag/type

(/tag/type

(/tag/type

(/tag/type

(/tag/type

(/tag/type

(/tag/type

id/category
id/category
id/keyword
id/category
workshop/channelcraft/channel kitchen%20hacks/?play/channel
woodworking/)

paper/)
Newsletter

sort=FAVORITES)

Join2million+toreceiveinstant
DIYinspirationinyourinbox.
enteremail

I'min!

id/category
id/keyword
workshop/channel astronomy/?

puzzles/)

lasercutting/)
AboutUs

id/category
id/category
id/category
home/channel technology/channel
craft/channel

sort=FAVORITES)homesteading/)

WhoWeAre(/about/)
Advertise(/advertise/)
Contact(/about/contact.jsp)
Jobs(/community/PositionsavailableatInstructables/)
Help(/id/howtowriteagreatinstructable/)

FindUs

Resources

Facebook(http://www.facebook.com/instructables)

ForTeachers(/teachers/)

Youtube(http://www.youtube.com/user/instructablestv)

ArtistsinResidence(/air)

Twitter(http://www.twitter.com/instructables)

GiftPremiumAccount(/account/give?sourcea=footer)

Pinterest(http://www.pinterest.com/instructables)
Google+(https://plus.google.com/+instructables)

Forums(/community/)
Answers(/tag/typequestion/?sort=RECENT)
Sitemap(/sitemap/)

3DPrinting/)

sewing/)

TermsofService(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
PrivacyStatement(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
LegalNotices&Trademarks(http://usa.autodesk.com/legalnoticestrademarks/) | MobileSite(http://www.instructables.com)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
2016Autodesk,Inc.