Professional Documents
Culture Documents
Login(/account/login)
Create
| SignUp(/account/gopro?sourcea=header&sourceaUrl=/id/ArduinoWaveformGenerator/?ALLSTEPS)
(/about/submit.jsp)
Contests
Community (/community/)
let's make (/contest/)
(/)
(/)
(/id/intel/)
(/tag/typeid/categoryliving/channelreuse/?sort=FEATURED)
(/tag/typeid/categoryoutside/channelcamping/?sort=FEATU
(/tag/typeid/categorytechnology/chann
(http://cdn.instructables.com/F3W/JXSF/H4VQNVIY/F3WJXSFH4VQNVIY.LARGE.jpg)
AboutThisInstructable
365,883views
License:
415favorites
amandaghassaei
(/member/amandaghassaei/)
(http://cdn.instructables.com/FFL/7Q4N/H1ZG8ODC/FFL7Q4NH1ZG8ODC.LARGE.jpg)
uhmanduhgusseyedotcom
(http://www.amandaghassaei.com)
(/member/amandaghassaei/)
Follow
2516
Bio: I'magradstudentattheCenterfor
BitsandAtomsatMITMediaLab.Before
thatIusedtoworkatInstructables,writing
codeforthewebsiteandiOSappsand
makingstuffinourshop.
(http://cdn.instructables.com/FQS/EI5W/H5035QET/FQSEI5WH5035QET.LARGE.jpg)
Waveformgenerators(alsocalledfunctiongenerators)areusefulfortestingand
debuggingcircuits.Ioftenusethemtotestthefrequencyresponseof
electronicscomponentslikeopampandsensors.Thiswaveformgeneratoris
Morebyamandaghassaei
(/id/9DegreesofFreedom
IMU)
poweredbyanArduino.Itoutputsfourwaveshapes:sine,triangle,pulse,and
saw,eachwaveshaperangesinfrequencyfrom1Hz50kHz.Thefrequency,
pulsewidth,andoverallamplitude(gain)ofthewaveformsiscontrolledbythree
potentiometers.I'vealsoincluded(optional)indicatorLEDsthatletyouknow
whichtypeofwaveiscurrentlybeingsenttotheoutput.
(/id/SugarcubeMIDI
Controller)
(http://cdn.instructables.com/F80/02PO/H9T4R08A/F8002POH9T4R08A.LARGE.jpg)
(/id/BeginnerArduino)
Tags:
functiongenerator(/tag/typeid/category
technology/keywordfunction+generator/)
waveform(/tag/typeid/categorytechnology/keyword
waveform/)
arduino(/tag/typeid/categorytechnology/keyword
arduino/)
signal(/tag/typeid/categorytechnology/keyword
signal/)
sine(/tag/typeid/categorytechnology/keywordsine/)
wave(/tag/typeid/categorytechnology/keyword
wave/)
PartsList:
(4x)MiniSPST1.5AmpMomentaryPushbuttonSwitch(2packages)
Radioshack#2751556(http://www.radioshack.com/product/index.jsp?
productId=2062543)
(8x)10KOhm1/4WattCarbonFilmResistor(2packages)Radioshack#271
1335(http://www.radioshack.com/product/index.jsp?productId=2062347)
(9x)20KOhm1/4WattCarbonFilmResistor(2packages)
(1x)50KOhmLinearTaperPotentiometerRadioshack#2711716
(http://www.radioshack.com/product/index.jsp?productId=2062355)
(1x)10KOmhAudioTaperPotentiometerRadioshack#2711721
(http://www.radioshack.com/product/index.jsp?
productId=2062357&filterName=Type&filterValue=Potentiometers)
(1x)10KOhmAudioControlPotentiometerwithSPSTSwitchRadioshack#271
215(http://www.radioshack.com/product/index.jsp?productId=2062298)
(1x)1/8"StereoInLineAudioJackRadioshack#274274
(http://www.radioshack.com/product/index.jsp?productId=2104044)
(1x)10.01f50VCeramicDiscCapacitorRadioshack#
(http://www.radioshack.com/product/index.jsp?productId=12579917)55047551
(http://www.radioshack.com/product/index.jsp?productId=12579917)
(1x)4.7KOhm1/4WattCarbonFilmResistorRadioshack#2711330
(http://www.radioshack.com/product/index.jsp?
productId=2062346&filterName=Type&filterValue=1%26amp%3Bamp%3B%230
47%3B4watt+resistors)
(1x)8PinSocketRadioshack#2761995
(http://www.radioshack.com/product/index.jsp?productId=2062604)
(1x)LM386LowVoltageAudioPowerAmplifierRadioshack#2761731
(http://www.radioshack.com/product/index.jsp?productId=2062598)
(2x)220F35V20%RadialleadElectrolyticCapacitor(oranythingbetween
200and300uF)Radioshack#2721029
(http://www.radioshack.com/product/index.jsp?productId=2103623)
(1x)ArduinoUnoREV3Radioshack#276128
(http://www.radioshack.com/product/index.jsp?productId=12268262)
(1x)ArduinoProtoShieldRadioshack#276140
(http://www.radioshack.com/product/index.jsp?productId=12369524)
(4x)WhiteSuperbrightLEDIndicatorRadioshack#55050633
(http://www.radioshack.com/product/index.jsp?productId=12582716)
(4x)740ohm1/4W5%CarbonFilmResistor(1package)Radioshack2711317
(http://www.radioshack.com/product/index.jsp?productId=2062342)
(1x)300Ohmresistor
AdditionalMaterials:
HeatShrinkRadioshack#2781611
(http://www.radioshack.com/product/index.jsp?productId=2062662)
22GaugeWireRadioshack#2781224
(http://www.radioshack.com/product/index.jsp?productId=2049745)
SolderRadioshack#64013(http://www.radioshack.com/product/index.jsp?
productId=2062717)
Drill
Related
iOSControlledArduino
waveformgenerator
(/id/iOSControlled
Arduinowaveform
generator/)
SignalSynthesiswithIntel
Edison(/id/Signal
SynthesiswithIntel
Edison/)
bypacman_pereira
THESIMPLESTFUNCTION
GENERATORBUILTONA
BREADBOARD(/id/THE
SIMPLESTFUNCTION
GENERATORBUILTONA
AtmelXmegaUSB/Serial
ArbitraryWaveform
Generator(/id/Atmel
XmegaUSBSerial
ArbitraryWaveform
ArduinoFrequency
Detection(/id/Arduino
FrequencyDetection/)
byamandaghassaei
(/member/amandaghassaei/)
SeeMore(/tag/typeid/?q=)
HotGlue
Glue
Blackdiffusormaterial(tissuepaper,plastic,etc)
ComprarPLC
arduino
ComprarPLCbasadoen
Arduino
PLClowcosthardware
libre
Msinformacin
RemovetheseadsbySigningUp(/account/gopro?
sourcea=removeads&nxtPgName=Arduino+Waveform+Generator&nxtPg=/id/ArduinoWaveformGenerator/?ALLSTEPS)
Step1:PrepareArduinoProtoShield
(http://cdn.instructables.com/F47/9BJJ/H0FLRO45/F479BJJH0FLRO45.LARGE.jpg)
(http://cdn.instructables.com/FF7/WLIR/H0FLRO46/FF7WLIRH0FLRO46.LARGE.jpg)
(http://cdn.instructables.com/FHI/OWYF/H0FLBLJO/FHIOWYFH0FLBLJO.LARGE.jpg)
(http://cdn.instructables.com/FYI/3OEL/H0FLRO47/FYI3OELH0FLRO47.LARGE.jpg)
TheArduinoProtoShieldsareaconvenientwaytoattachcircuitstoanArduino,
butIliketotrimthemdownalittlebitfirstsotheydonottakeupsomuchroom
intheprojectenclosure.Startbytrimmingthepinsdownwithapairofwire
cutters.Next,cutoffthesixpinsocket.Finally,cutthesocketsfromthetopof
theboard.
(http://cdn.instructables.com/FGS/U2GL/H0FLRO48/FGSU2GLH0FLRO48.LARGE.jpg)
Step2:Enclosure
(http://cdn.instructables.com/F5K/IKSN/H1EMHXEN/F5KIKSNH1EMHXEN.LARGE.jpg)
(http://cdn.instructables.com/F1L/M0E9/H1EN042T/F1LM0E9H1EN042T.LARGE.jpg)
(http://cdn.instructables.com/F6F/RPLN/H1ERN09W/F6FRPLNH1ERN09W.LARGE.jpg)
Idecidedtolasercutacustomenclosureformyproject.Idesignedthe
enclosureusingAutoCAD,Autodesk123DMake,andCorelDraw,andI've
(http://cdn.instructables.com/FC0/LQYB/H1EN042W/FC0LQYBH1EN042W.LARGE.jpg)
includedcoreldrawandadobeillustrator2DfilesaswellastheSTL,andDWG
filesfromthisprocessbelow.Ifyoudonothaveaccesstoalasercutter,you
(http://cdn.instructables.com/FF8/CY87/H1EN6W6P/FF8CY87H1EN6W6P.LARGE.jpg)
canusemy2Dfilesaguideanddrillthenecessaryholesinaprojectenclosure
ofsomekind.Figure4showstheholesthatshouldbedrilledonthefrontpanel:
(3x)7mmholesforgain,freq,andPWMpots
(3x)7mmholesforfourpushbuttonssin,saw,tri,andpulse
(1x)10mmholeforaudioout
(http://cdn.instructables.com/F5H/5XO9/H1EN0483/F5H5XO9H1EN0483.LARGE.jpg)
IcutoutshapesofallfourwaveformsinthefrontoftheenclosuresothatIcould
backlightthemwithindicatorLEDs,youmaychoosetojustdrillfour5mmholes
fortheseLEDsinthefrontpaneloftheenclosure,placeoneLEDundereach
momentaryswitch.
Alsoincludearectangular(11mmtall,12mmwide)cutoutsomewhereonthe
sideoftheenclosureforthearduino'susbport.
Imademyprojectenclosureoutofwood,soIhadtoglueallthepieces(except
thebottom)togetherwithwoodglue.Iwillattachthebottompanelonlaterin
thisinstructable.
enclosure.stl(/files/orig/F1T/L28A/H4VQ6PA4/F1TL28AH4VQ6PA4.stl)
Printwith3DHubs!
enclosure.stl
(/files/orig/F1T/L28A/H4VQ6PA4/F1TL28AH4VQ6PA4.stl)1KB
functiongeneratorenclosure.ai
(/files/orig/FJE/0X52/H5035Q7U/FJE0X52H5035Q7U.ai)32
KB
functiongeneratorenclosure.cdr
(/files/orig/FMQ/TZKJ/H4VQ6PA5/FMQTZKJH4VQ6PA5.cdr)23KB
enclosure.dwg
(/files/orig/FV1/D83I/H4VQ6PAA/FV1D83IH4VQ6PAA.dwg)228KB
Step3:SolderButtonLeads
(http://cdn.instructables.com/FZY/GVPY/H142A3TQ/FZYGVPYH142A3TQ.LARGE.jpg)
Soldera10kOhmresistortooneleadofeachofthefourpushbuttons.As
showninthesecondimage,solderagreenwiretothejunctionbetweenthe
buttonandtheresistorandaredwiretotheotherendoftheresistor.Soldera
(http://cdn.instructables.com/FBG/OPQN/H1426G3L/FBGOPQNH1426G3L.LARGE.jpg)
blackwirethethesecondleadofthepushbutton.It'sagoodideatocover
theseconnectionswithabitofheatshrinktopreventshortcircuits(fig2).
Step4:InstallAudioJack
(http://cdn.instructables.com/F7X/9QIS/H142A3UU/F7X9QISH142A3UU.LARGE.jpg)
(http://cdn.instructables.com/FYR/EDJV/H0KL4FHY/FYREDJVH0KL4FHY.LARGE.jpg)
(http://cdn.instructables.com/FAC/OUI4/H0KR942R/FACOUI4H0KR942R.LARGE.jpg)
(http://cdn.instructables.com/FPD/1ZZK/H1EN6W6Q/FPD1ZZKH1EN6W6Q.LARGE.jpg)
(http://cdn.instructables.com/FK3/BLOX/H1EMHXFS/FK3BLOXH1EMHXFS.LARGE.jpg)
Unscrewtheplasticcasingfromtheaudiojack.Solderaredwiretothetwo
stereooutpinsandsolderablackwiretothegroundpin(fig3).Iusedhotglue
topreventshortcircuitingthejackandtogivethesolderingjointssomeextra
support.Finally,mounttheaudiojackintheenclosurewithsuperglue.
Step5:InstallButtons
(http://cdn.instructables.com/F5C/5LVW/H1EMHXI9/F5C5LVWH1EMHXI9.LARGE.jpg)
(http://cdn.instructables.com/FS5/BPOD/H1G700GC/FS5BPODH1G700GC.LARGE.jpg)
(http://cdn.instructables.com/F4U/VBE2/H1YOHHBQ/F4UVBE2H1YOHHBQ.LARGE.jpg)
Snapthetopofthebuttonoffandfitthemintothewoodenenclosure.Secure
withhotglue.Oncedried,snaptheblackbuttontopsbackon.
Step6:R2RDAConArduinoShield:Part1
(http://cdn.instructables.com/FR6/NWYD/H1YOAYLM/FR6NWYDH1YOAYLM.LARGE.jpg)
(http://cdn.instructables.com/F1X/KPX7/H1YONE0Y/F1XKPX7H1YONE0Y.LARGE.jpg)
Soldereight20kOhmresistorstothearduinoprotoshield.Oneendofeach
resistorshouldconnecttodigitalpins07.
Step7:R2RDAConArduinoShield:Part1
(http://cdn.instructables.com/F5I/FOV9/H1YOAYLN/F5IFOV9H1YOAYLN.LARGE.jpg)
(http://cdn.instructables.com/F3I/RYFE/H1YOKGMI/F3IRYFEH1YOKGMI.LARGE.jpg)
Solder710kOhmresistorstotheprotoboardsothattheybridgetheleadsofthe
820kPhmresistorsyouhavejustsoldered.
Step8:R2RDAConArduinoShield:Part3
(http://cdn.instructables.com/FO5/9AIQ/H1YOKGLO/FO59AIQH1YOKGLO.LARGE.jpg)
(http://cdn.instructables.com/F7J/RZC6/H1ZG6M3O/F7JRZC6H1ZG6M3O.LARGE.jpg)
Soldera20kOhmresistortotheprotoshieldsothatoneendisconnectedtothe
10kOhmresistorattachedtodigitalpin0andtheotherendisconnectedtoa
jumperwiretoground.
Step9:ICsocket
(http://cdn.instructables.com/F03/D4VV/H1YOAYLQ/F03D4VVH1YOAYLQ.LARGE.jpg)
(http://cdn.instructables.com/FMQ/MXO5/H1YOHIAY/FMQMXO5H1YOHIAY.LARGE.jpg)
It'sagoodideatousesocketsforyourICs,thiswayyouwon'triskburningthe
ICwithyoursolderingironandyoucaneasilyreplacetheICifitbreaks.Solder
an8pinsockettotheprotoboardasshownintheimage.
Step10:LowPassFilter
(http://cdn.instructables.com/FBU/EK6X/H2073J6J/FBUEK6XH2073J6J.LARGE.jpg)
(http://cdn.instructables.com/FEO/OQ8N/H1YOHIB9/FEOOQ8NH1YOHIB9.LARGE.jpg)
Usearesistorandcapacitorinseriestocreatealowpassfilter.Lowpassfilters
letlowfrequenciespassthroughandsilence(attenuate)highfrequencies.
Connectingalowpassfiltertotheoutputfromthedacwillsmoothoutthesteps
inthewave.
Here'showIcalculatedthevalueofthecomponentsinmylowpassfilter:
cornerfrequency=1/(2*pi*R*C)
AccordingtoNyquist'sTheorum,signalscannotcontainfrequencieshigherthan
halftheirsamplingrate.IfIusedasamplingrateof100kHz,thenthehighest
frequencyIcanproduceis50kHz.
ifIusea300OhmresistorandIwantacornerfrequencyof50kHz:
50000=1/(6.28*300*C)
C=1.06*10^8F
roundthisto:
C=0.01uF
Connectoneendofthethe300Ohmresistortothe10kOhmresistorconnected
todigitalpin7.Connectthecapacitortotheotherendofthe300Ohmresistor.
Theothersideofthecapshouldconnecttoground.
Step11:Amplifier:Part1
(http://cdn.instructables.com/F63/XKSG/H1YOKGMC/F63XKSGH1YOKGMC.LARGE.jpg)
(http://cdn.instructables.com/FBI/PHQC/H1YOAYLX/FBIPHQCH1YOAYLX.LARGE.jpg)
Connectthepositiveleadofthe220uFcapacitortothejunctionbetweenthe
resistorandcapacitorofthelowpassfilter.Theotherendofthe220uF
capacitorconnectstoa20kOhmresistorthatisconnectedtopin3oftheIC
socket.A4.7kOhmresistorbridgespins3and4oftheICsocket.
(http://cdn.instructables.com/F0G/OU8N/H1YOAYLZ/F0GOU8NH1YOAYLZ.LARGE.jpg)
Step12:Amplifier:Part2
(http://cdn.instructables.com/FCR/EEF9/H1YOHN7K/FCREEF9H1YOHN7K.LARGE.jpg)
(http://cdn.instructables.com/FNO/N6BX/H2073J6L/FNON6BXH2073J6L.LARGE.jpg)
(http://cdn.instructables.com/F25/VRYW/H1YOKGMD/F25VRYWH1YOKGMD.LARGE.jpg)
Connectgroundtopin4oftheICsocket.
Step13:Amplifier:Part3
(http://cdn.instructables.com/F0N/X6BH/H1YOHIBC/F0NX6BHH1YOHIBC.LARGE.jpg)
(http://cdn.instructables.com/FO1/QW4G/H1YONE15/FO1QW4GH1YONE15.LARGE.jpg)
Connectthepositiveleadofasecond200uFcapacitortopin5oftheICsocket.
Theotherendofthecapwillbeconnectedtothegainpotinalaterstep.
Step14:Amplifier:Part4
(http://cdn.instructables.com/FPZ/C1NY/H1ZG6LVK/FPZC1NYH1ZG6LVK.LARGE.jpg)
(http://cdn.instructables.com/FPG/3LSB/H1YONE16/FPG3LSBH1YONE16.LARGE.jpg)
Connectpin6oftheICsockettoVin,pin2toground,andsnaptheICintothe
socket.
Step15:WireGainPot
(http://cdn.instructables.com/FYP/2CNA/H1YOKGMF/FYP2CNAH1YOKGMF.LARGE.jpg)
(http://cdn.instructables.com/F8G/DI75/H1YOKHRJ/F8GDI75H1YOKHRJ.LARGE.jpg)
(http://cdn.instructables.com/FR5/NQ8Y/H1YOKHRK/FR5NQ8YH1YOKHRK.LARGE.jpg)
Volumeorgainoftheaudiosignalwillbecontrolledwiththe10kaudiotaperpot
withswitch.Connecttheaudiooutfromtheamplifierandgroundtoeitherside
ofthepotentiometerasindicatedinthepicture.Themiddleisaudioout,itwill
behookedupdirectlytotheaudiojack.
Alsoconnectawiretothebottomandleftleadsonthebackofthepot(figure
2).Thisistheswitchthatwillbeusedtoconnecttopowerinthenextstep.
(http://cdn.instructables.com/FWO/FLZ4/H1YOAZFD/FWOFLZ4H1YOAZFD.LARGE.jpg)
Step16:ConnecttoBattery
ArduinoWaveformGenerator byamandaghassaei(/member/amandaghassaei/)
Download(/id/ArduinoWaveformGenerator/?download=pdf)
(/id/ArduinoWaveformGenerator/)
Collection
(http://cdn.instructables.com/F7G/BWO3/H2073JG4/F7GBWO3H2073JG4.LARGE.jpg)
ConnecttheblackwirefromthebatterycliptogroundontheArduinoShield.
Connectoneleadfromthegainpotswitchtotheredwirefromthebatteryclip
andconnecttheothergainpotleadtoVinontheArduinoShield.
Leavethebatterydisconnectedfornow.
Step17:ConnectOutputtoHeadphoneJack
(http://cdn.instructables.com/F1H/SVCQ/H1YOAZFE/F1HSVCQH1YOAZFE.LARGE.jpg)
29Steps
IMadeit!
Favorite
Share
Connecttheoutputfromtheamplifier(thenegativeleadofthecapconnectedto
theICatpin5)totheredwireweattachedtothegainpotentiometerinan
earlierstep.Connectthegreenwirefromtheamplitudepottotheredwire
connectedtotheaudiojack.Connecttheblackwirefromtheaudiojackandthe
blackwirefromthepottogroundontheArduinoShield.
Step18:WireButtons
(http://cdn.instructables.com/F6F/BOEJ/H1YONEOR/F6FBOEJH1YONEOR.LARGE.jpg)
(http://cdn.instructables.com/FB0/339Y/H1YOHIZ9/FB0339YH1YOHIZ9.LARGE.jpg)
Connectallreadleadsfromthebuttonto5Vandalltheblackwirestogroundon
thearduinoshield(fig1).Connectthegreenwirestoanalogin03inthe
followingorder:
analog0=pulse
analog1=triangle
analog2=saw
analog3=sine
(http://cdn.instructables.com/FYA/EH0V/H2073JG5/FYAEH0VH2073JG5.LARGE.jpg)
Step19:WireFrequencyandPWMPots
(http://cdn.instructables.com/F2I/WYJE/H1KHAYU7/F2IWYJEH1KHAYU7.LARGE.jpg)
(http://cdn.instructables.com/F7T/UE0X/H1KHAYU9/F7TUE0XH1KHAYU9.LARGE.jpg)
Connectared,black,andgreenwiretothe10kOhmand50kOhm
potentiometersasshownintheimages.Connecttheredleadto5Vandthe
blackleadstogroundonthearduinoshield.Connectthecentergreenwiresto
analogpins4(PWM)and5(frequency).
Step20:InstallPots
(http://cdn.instructables.com/F70/2JTU/H1YOAZFG/F702JTUH1YOAZFG.LARGE.jpg)
(http://cdn.instructables.com/FNG/Y9FG/H2073JG7/FNGY9FGH2073JG7.LARGE.jpg)
(http://cdn.instructables.com/FZU/RK65/H0OJ5RV4/FZURK65H0OJ5RV4.LARGE.jpg)
Removethesidetabonallofthepotsbeforeinstallingintheenclosure,thiswill
allowthemtositflushagainstthewood.Removewasherandnutfromeachof
thepots,placepotthroughholeinenclosure,andsecurewithnut.Installall
threepotsintheenclosure.
Step21:WireLEDs:Part1
(http://cdn.instructables.com/F1W/C3K2/H0OJ2DNO/F1WC3K2H0OJ2DNO.LARGE.jpg)
(http://cdn.instructables.com/FL5/EDR8/H1YOHWYG/FL5EDR8H1YOHWYG.LARGE.jpg)
(http://cdn.instructables.com/FI7/4LWO/H1YOB2J5/FI74LWOH1YOB2J5.LARGE.jpg)
Attacha470OhmresistortothecathodeofeachofthefourLEDs.Soldera
blackwiretotheotherendoftheresisotrandaredwiretotheanodeofthe
LED.Covertheseconnectionswithshrinkwraptopreventshortcircuiting.
Step22:WireLEDs:Part2
(http://cdn.instructables.com/FO9/LGNP/H21MJHRX/FO9LGNPH21MJHRX.LARGE.jpg)
(http://cdn.instructables.com/FZ4/T3KP/H1YOKNXL/FZ4T3KPH1YOKNXL.LARGE.jpg)
SoldertheblackleadsfromallfourLEDstogroundonthearduinoshield.
Soldertheredleadstodigitalpins811.
Step23:BlackDiffuser
(http://cdn.instructables.com/F9C/PA8G/H21CGJ6J/F9CPA8GH21CGJ6J.LARGE.jpg)
Gluealightdiffusingmaterialbehindthewavecutoutsinthefrontpanel.Iused
apieceofablackplasticgarbagebag.
Step24:GlueLEDs
(http://cdn.instructables.com/FHX/LQ7P/H27LREIS/FHXLQ7PH27LREIS.LARGE.jpg)
GluetheLEDsintheenclosuresothattheyareeachpointedtowardsoneofthe
cutoutsymbolsonthefrontpanel.Hereisatableforreference:
digital8=pulse
digital9=triangle
digital10=saw
digital11=sine
Step25:Firmware
(http://cdn.instructables.com/F57/OWUR/H1ZG6MSQ/F57OWURH1ZG6MSQ.LARGE.jpg)
UploadthecodeatthebottomofthisstepontotheArduino.Thecodeusesa
timerinterrupt(http://www.instructables.com/id/ArduinoTimerInterrupts/)ata
frequencyof100kHztosendnewdataouttotheDAC.Therestofthecode
monitorsthestateofthebuttonsandknobsandadjustsvariablesaccordingly.
Sincetheinterruptsoccuratsuchahighfrequency,Ihadtokeeptheinterrupt
routine,thepieceofcodeencapsulatedintheISR(TIMER1_COMPA_vect){}as
shortaspossible.Timeintensiveoperationslikemathematicaloperationswith
floatsandusingthesin()functiontaketoomuchtimetocomplete.Iused
severalworkaroundtogetbythis:
FortriangleandsawIcreatedthevariablessawByte,triByte,sawInc,andtriInc.
EverytimethefrequencychangedIcalculatedtheamountthatthetriangleand
sawfunctionwouldhavetoincrementatasamplingrateof100kHz:
triInc=511/period
if(triInc==0){
triInc=1
}
sawInc=255/period
if(sawInc==0){
sawInc=1
}
thenalltheneededtobedoneintheinterruptroutinewassomesimplemath:
case1://triangle
if((periodt)>t)
if(t==0){
triByte=0
}
else{
triByte+=triInc
}
}
else{
triByte=triInc
}
if(triByte>255){
triByte=255
}
elseif(triByte<0){
triByte=0
}
wave=triByte
break
case2://saw
if(t=0){
sawByte=0
}
else{
sawByte+=sawInc
}
wave=sawByte
break
Forthesinefunction,Iwroteasimplepythonscriptwhichoutputs20000values
of127+127sin(x)foronecompletecycle:
importmath
forxinrange(0,20000):
printstr(int(127+127*math.sin(2*math.pi*x*0.00005)),)+str(","),
IstoredthisarrayintheArduino'smemorycalledsine20000[]andrecalledthe
valuesIneededtosendtotheDAC.Thisismuchfasterthancalculatingthe
valuesindividually.
function_generator.ino.zip
(/files/orig/F3R/KWWY/H5408DAN/F3RKWWYH5408DAN.zip)3KB
Step26:LastFewConnections
(http://cdn.instructables.com/FBC/41ZV/H1YONF73/FBC41ZVH1YONF73.LARGE.jpg)
PlugtheArduinointoyourshield.Connecta9Vbatterytothebatteryclip.
Securetheseitemsinsidetheenclosure.MakesurethattheArduino'susbport
(http://cdn.instructables.com/FZ3/WZWN/H1YOKNZ1/FZ3WZWNH1YOKNZ1.LARGE.jpg)
isaccessiblefromtheoutsideoftheenclosure.Uponstartupyoushouldsee
thesinewaveLEDlightup.
Step27:ScrewBackPanel
(http://cdn.instructables.com/F57/BX1O/H1YOKNZJ/F57BX1OH1YOKNZJ.LARGE.jpg)
(http://cdn.instructables.com/F4F/NR3B/H4AFSEVM/F4FNR3BH4AFSEVM.LARGE.jpg)
Drillfourholesinthebackpanelandsecurewithscrews.
Step28:AddKnobs
(http://cdn.instructables.com/FFL/7Q4N/H1ZG8ODC/FFL7Q4NH1ZG8ODC.LARGE.jpg)
Screwknobsonthethreepotentiometers.
Step29:Test
(http://cdn.instructables.com/FF7/XVJJ/H4VQ6AFK/FF7XVJJH4VQ6AFK.LARGE.jpg)
(http://cdn.instructables.com/FBJ/3MZB/H51ASJOU/FBJ3MZBH51ASJOU.LARGE.jpg)
(http://cdn.instructables.com/FY1/DHW2/H4ZN5CHT/FY1DHW2H4ZN5CHT.LARGE.jpg)
Turnupthegainknobtoturnonthefunctiongenerator.Pluganeighthinchjack
(http://cdn.instructables.com/FDN/QKO7/H4VQNRAO/FDNQKO7H4VQNRAO.LARGE.jpg)
intotheoutputandhookupthefunctiongeneratortoanoscilloscope
(http://www.instructables.com/id/OscilloscopeHowTo/).Testouteachofthe
waveformsandadjustthefrequencyandgaintomakesuretheyareworking
properly.Switchtheoutputtopulseandcheckifthepulsewidthmodulation
(http://cdn.instructables.com/FJ4/VQZI/H4ZN5CSV/FJ4VQZIH4ZN5CSV.LARGE.jpg)
knobworks(figs46).
Youwillnoticethatthepulsewaveistheonlywavewhichtrulyrangesfrom1Hz
to50kHz.Sincethesamplingrateis100kHz,thesine,triangle,andsawwaves
starttobecomesomewhatunrecognizableatabout25kHz(theyareonly
comprisedof4samplespercycle100kHz/25kHz).Thesawandtrianglewaves
onlygodowntoabout100Hz,thisisbecausethevaluesoftriIncandsawIncget
(http://cdn.instructables.com/FYF/9L09/H4VQKNPC/FYF9L09H4VQKNPC.LARGE.jpg)
solowthattheyareroundedtozerobelowthisfrequency.Thesinewave
reachesallthewayto1HZbuttheresolutionstaysthesameforanythingunder
5Hz,sincetheArduinoonlyhasenoughmemorytostoreabout20thousand
samples.
Wehaveabenicecommentpolicy.
Pleasebepositiveandconstructive.
140of
139
IMadeit!
AddImages
MakeComment
Next(http://www.instructables.com/id/ArduinoWaveformGenerator/?
&sort=ACTIVE&limit=40&offset=40#DISCUSS)
daudahmad(/member/daudahmad/)
1monthago
Reply
Arduino:1.6.1(WindowsXP),Board:"ArduinoUno"
(/member/daudahmad/)
function_generator.ino:30:8:error:'sine20000'doesnotnameatype
InfileincludedfromC:\ProgramFiles
(x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,
fromfunction_generator.ino:30:
function_generator.ino:Infunction'void__vector_11()':
function_generator.ino:227:31:error:'sine20000'wasnotdeclaredinthis
scope
Errorcompiling.
Thisreportwouldhavemoreinformationwith
"Showverboseoutputduringcompilation"
enabledinFile>Preferences.
IgetthefollowingerrorwhileicompilethecodeinarduinoIDE.Itriedalot.but
could'tsolvetheproblem.Wouldanybodypleasehelpme?
(http://cdn.instructables.com/FM5/AT01/I9GWAY50/FM5AT01I9GWAY50.LARGE.jpg)
adeel.asghar.1466(/member/adeel.asghar.1466/)
2monthsago
Reply
Helloamanda..imadethisprojectnutwheniuploadthegivencodeitgives
(/member/adeel.asghar.1466/)
mefollowingerror
fromfunction_generator.ino:30:
function_generator.ino:30:18:
error:variable'sine20000'mustbeconstinordertobeputinto
readonlysectionbymeansof'__attribute__((progmem))'Canyupleasehelp
meout
PaulS20(/member/PaulS20/) adeel.asghar.1466
2monthsago
Reply
Justnow,IcompiledthesketchwithArduino1.0.6settoUno,andit
(/member/PaulS20/)
didn'thaveaproblem.SoIcan'tproveI'vefoundyouranswer.What
boardareyoucompilingforthatgaveyouthiserror?
SometimesIaccidentlytypesomethingintoasketchwithoutknowing
it,thatcausesittocrash.Youcouldtryreloadingthesketchfromthe
original"untouched"source.
The"30:18"inyourerrormessagemeansithappenedonline30,and
the18thcharaccterinfromtheleft.Theerrormessagestatestheline
shouldbea"const",soIdidthat,Iaddedtheword"const"sotheline
startswith"constbytesine20000"insteadofjust"bytesine20000",and
again,itcompiledjustfineforme.
Givethatatry.
"const"meansthevaluesinthatlinewillnotbechanged,whichI
beleiveiscorrectsinceit'sonlyreadoverandoveragaintomake
thesinewave.
PaulS20(/member/PaulS20/)
2monthsago
Reply
Aftergooglingfor"SineWaveCircuit",Iwasdelightedtofindthis"Arduino"
(/member/PaulS20/)
sinewavecircuit,becauseIloveworkingwithArduinoandit'scompatible
modules.Also,thelazercutterusedherewasawonderfuldiscoveryforme
too!Ididn'tevenknowtherewassuchathing,butnowmusthaveonetoadd
aprofessionallooktotheprojectsIsell.
However,thearticlehasroomforimprovement,whichisthereasonforthis
comment.Herearemysuggestions:
1.Theseveralplacesthetextreferingto"300Ohm",and"470Ohm"needa
spacetomakeit"300ohm"and"470ohm,soitdoesn'tlooklikeavalueten
timeslargerthanintended.
2.Oneschematicshowsthe300ohmresistorandcapforthelowpassfilter.
Buttheotherschematicomitsthiscircuit.
3.Althoughthephotographyisveryclear,noonepictureshowsallthewiring
whereit'seasytounderstandeverythingatonce.Takealookat
http://1.bp.blogspot.com/
FLaRrce1svE/VFtEWeuSL0I/AAAAAAAAANI/1GbkconjhXU/s1600/bluetoothcontrol_bb.jpg
Everywireandwhereitconnectsiseasytoseeinonepicture.Andlikein
thispicture,Ialwaystryoutmyprojectsonawhitebreadboardfirstforit'sfar
easiertotryoutalternativesandcorrectmistakeswhereallpartsplugand
unplug,thanitisonaprojectboardwhereyouhavealreadysolderedtheparts
permanentlyinplace.
4.Thetextsays,"A4.7kOhmresistorbridgespins3and4oftheICsocket."
Yettheschematicshowsthisasbeinga2.2kohmresistor.Whichvalueis
correct?
5.Itwouldhelptohaveanoteonthepictures,explainingyoucanmouseover
therectanglestopopupnotesonwhat'sinsidetherectangle.I'dnearly
finishedtheprojectbeforediscoveringthis.
6.Onesuchrectangle(overastraightsectionofwireinaschematic)saysa
resistorshouldhavebeenhere.Whynotjustaddtheresistortotheimageand
reloadit?Thenoteiseasytomiss(andthustheneedfortheresistor.)
7.Anothermouseoverrectanglesaysthecolorcodeontheresistorshownis
wrong.Sowhynotjustuseanartprogramtopaintthecorrectcolorsonthe
resistor,andreuploadtheimage?
IthinkthisisaGREATprojectexactlywhatIneeded.Buttheaboveseven
itemsmakeithardtofollowcorrectly.Forthebenefitofothers,I'dLOVEtosee
thesemodificationsmade.
adeel.asghar.1466(/member/adeel.asghar.1466/) PaulS20
2monthsago
HelloPaul..imadethisprojectnutwheniupload
(/member/adeel.asghar.1466/)
thegivencodeitgivesmefollowingerror
Reply
fromfunction_generator.ino:30:
function_generator.ino:30:18:error:variable
'sine20000'mustbeconstinordertobeputinto
readonlysectionbymeansof
'__attribute__((progmem))'
Canyupleasehelpmeout
adeel.asghar.1466(/member/adeel.asghar.1466/)
2monthsago
Reply
3monthsago
Reply
(/member/adeel.asghar.1466/)
AdiM(/member/Adi+M/)
Isthereapointinstoring20000samples?IfourDACcanonlyrepresent2^8
(/member/Adi+M/)
values?Surely256samplesshouldbethemaximumsampleresolution?Ima
bitconfused.Niceproject:)
Cheeseduck(/member/Cheeseduck/) AdiM
2monthsago
Reply
Thinkofasinewaveinthexyplane.Thereareonly256yvalues
(/member/Cheeseduck/)
available,becausethat'stheresolutionofthearduino'sanalogoutput
pins.However,wecanhaveasmanyxvaluesasweneed,tosome
extent.
Sothequestionbecomeswhatisthesmallestnumberofxvaluesyou
needforittostilllooklikeasinwave.Theauthorchose20k,butyou
coulddomoreorlessifyouwantedto.AsIseeit,theonlyreasonto
domoreisforhigherresolutionatlowerfrequencies,andtheonly
reasontodolessistosavestoragespace.
wgrabarz(/member/wgrabarz/)
2monthsago
Reply
Hey,woulditbepossibletoconvertthisprojecttoasynthesizerdualDCO?
(/member/wgrabarz/)
MidicontrolledandwithoneoutputforeachDCOwhereDCO2frequencyis
DCO1*detuneFactor(setbyapotonananalogpin,range+/1octaveso
detuneFactorwouldhavetogofrom0,5to2)
fariha.abid.980(/member/fariha.abid.980/)
3monthsago
Reply
heyihavetotaketheoutputofthearduinothroughearphonesinsteadof
(/member/fariha.abid.980/)
speaker..myarduinooutputisworkingprettyfinewithspeaker..butihaveto
switchitnowtoearphones.canyoupleaseguide
PaulS20(/member/PaulS20/) fariha.abid.980
2monthsago
Reply
Theproblemwithearphonesisthattheyputallthatpowerrightinto
(/member/PaulS20/)
yourears!Justconnectaresistorinserieswitheachearphonewire.If
theyare8ohmearphones,atenohmresistorwouldreducethepower
aboutinhalf,a33ohmresistorwouldreduceitto1/4thasloud,etc.
ashish.gujarati(/member/ashish.gujarati/)
3monthsago
Reply
2monthsago
Reply
HelloAmanda,
(/member/ashish.gujarati/)
caniusearduinoatmega2560inplaceofuno???
thankyou!
PaulS20(/member/PaulS20/) ashish.gujarati
Ifyoualreadyhaveyouratmega2560,justtryloadingthesoftware
(/member/PaulS20/)
sketchthisinstructableprovidedintoyourAdruino.IfthetheArduino
tellsyouit'shappywithit,thatshouldbveyouranswer.
tony.kupcho(/member/tony.kupcho/)
3monthsago
Reply
Isthereanyparticularreasonforthe35Vratingonthe220microF
(/member/tony.kupcho/)
capacitors?Ialreadyhaveasetof16Vandwaswonderingiftherewouldbe
anyreasonIcouldn'tusethem
PeterPaulV(/member/PeterPaulV/) tony.kupcho
3monthsago
Reply
No,noreasonwhyyoucannotuseyour16Vcaps.Iguessthe35V
(/member/Peter
voltoneswaswhattheauthorhadavailableatthatmoment.Asa
PaulV/)
generalrule:aslongasthecapacitorvoltageratingishigherthanthe
supplyvoltageofyourcircuit,itwillbeOK.
pepeSpeculum(/member/pepeSpeculum/)
3monthsago
Reply
HowcanIchangetheR2RresistorsetforaDAC08(http://docs
(/member/pepeSpeculum/)
europe.electrocomponents.com/webdocs/0...(http://docs
europe.electrocomponents.com/webdocs/077f/0900766b8077fe46.pdf))in
ordertosavecomponents?WhatconnectionsdoIhavetodo?
Thankyou
Greatproject
ashish.gujarati(/member/ashish.gujarati/)
HiAmanada.
(/member/ashish.gujarati/)
caniusearduinoatmega2560inolaceofuno???
3monthsago
Reply
thanks..
MatthewT7(/member/MatthewT7/)
4monthsago
Reply
soimnot100sureonthemathbutimshortafew10kresistors..ifIjustdo2
4.7kresistorsinserieswillthatbecloseenough?willthatjustaffectthe
(/member/MatthewT7/)
amplitudeasmallbit?
aplavins(/member/aplavins/)
4monthsago
Reply
4monthsago
Reply
Amazingandwelllaidout!Ilookforwardtomakingone!
(/member/aplavins/)
AlxDroidDevA(/member/AlxDroidDevA/)
Greatwork!Verywellthoughtoutandquiteuseful.UsinganArduinoinstead
(/member/AlxDroidDevA/)
ofaprofessionalarbitrarywaveformgeneratorcansaveusabunchofmoney.
Ihaveonesuggestion,however:addabuttonthat,whenpressed,willsend
justonecycleoftheselectedwaveformintheselectedconfiguration(oneshot
trigger).
Pythag(/member/Pythag/)
1yearago
Reply
Hitherethishasbeenagreatprojectsofar!
(/member/Pythag/)
Ijustwantedtoaskaboutonehiccupimhaving.Forsomereason,thesignal
comingoutfrommyampisclippedcleaninhalf,onlygoinguptoabouthalf
thevoltageitshouldbebeforejustflatteningoff.Thesignalcomingintothe
ampisniceandclean,andimfairlysureivegoteverythingwiredupwiththe
samecomponentsyouused,althoughmyampisanlm386n1doyou
supposethatcouldbewhat'smakingthedifference?Icouldntfindanything
differentaboutit'sspecs,butI'mreallyjustabeginner,soIwouldntknowfor
sure.
Anyway,thanksforabrillianttutorial!
Pythag(/member/Pythag/) Pythag
1yearago
Reply
Ah,mymistakeactuallygotconfusedwiththeACreadingsfrommy
oscilloscope.Itactuallyisgettingthefullvoltagefromtheamp,butit's
(/member/Pythag/)
stillclipping.Iput320kresistorsinserieswiththefrequencycoming
fromthearduino,andit'sfixedtheclipping,butithardlyseemsanideal
solution.IstheresomethingelseIcouldbedoingtolowerthegainon
theamplifier?
guygibbs(/member/guy+gibbs/) Pythag
4monthsago
Reply
Itooamhavingaclippingproblem...canyoupleasetellmewhereto
hookto20kresistorstoresolvethis?
(/member/guy+gibbs/)
amandaghassaei(/member/amandaghassaei/)(author) Pythag
1yearago
whatopampareyouusing?
Reply
(/member/amandaghassaei/)
amandaghassaei(/member/amandaghassaei/)(author) amandaghassaei
Reply
1yearago
ohisee,alm386.youshouldwireituplikethis:
http://letsmakerobots.com/node/4870
(/member/amandaghassaei/)
astein1(/member/astein1/)
7monthsago
Reply
arethemomentarysqitchesnormalyOpenornormallyclosed?
(/member/astein
1/)
amandaghassaei(/member/amandaghassaei/)(author) astein1
7monthsago
normallyopen
(/member/amandaghassaei/)
astein1(/member/astein1/) amandaghassaei
Reply
7monthsago
Reply
7monthsago
Reply
8monthsago
Reply
thnxurawesome!
(/member/astein
1/)
astein1(/member/astein1/)
thatresistorlookslikea10knota20k
(/member/astein
1/) whatdoido??
dimaris(/member/dimaris/)
HiAmanda,Imadeyoursignalgenerator.
(/member/dimaris/)
WhythentheoutputsignalfromtheLM386truncatedvertices,inwhatcould
bethereason?ArduinoitselfgivestherightsignalandthissignalLM386
spoils.
jasper500(/member/jasper500/)
9monthsago
Reply
HiAmanda,Iseethatyouhaveanamazing20,000valuesforthesine
(/member/jasper500/)
function.Sinceyouonlyhavean8bitDACwith256levels,isthisactually
necessary.Canyouexplainhowthisaddsresolution?
jasper500(/member/jasper500/)
9monthsago
Reply
AmIrightinthinkingthatbecausethefrequencyissetbyreadingthevoltage
(/member/jasper500/)
atoneoftheanalogueinputs,thattherewillonlybe1024stepsinfrequency
between1Hzand50Khz?Isthereanywayofbeingabletosetthefrequencyin
code?
lopsan931(/member/lopsan931/)
9monthsago
Reply
anysuggestionsofhowtoimplementaLCDdisplayingthefrecuency
(/member/lopsan931/)
***FREQUENCYMETER**
JoshS2(/member/JoshS2/)
10monthsago
Reply
Ineededafunctiongeneratorfortestingcircuits,butcouldn'taffordtospend
(/member/JoshS2/)
severalhundred(ormore)dollars.Thisoneworkedperfectly.Iupgradedafew
oftheparts(formoreaccurategainandfrequency,Ihavea10turn
potentiometer),andalsohaveanoptiontoconnectanexternalvoltagesupply
insteadofusingabatteryforprojectsthatIknowwilltakeawhile.Havingthe
9vbatteryavailableforquickaccessandportabilityisverynice.Ichangedthe
codearoundjustabitsothattheinitialwaveformissineinsteadofsquare,
andtoallowalowerfrequency(about15hz).IchangedfreqToleranceto1
sinceIupgradedthepots.Ialsousedanactualswitchforpower(noreason
otherthanjustpersonpreference).Iusealotofotherequipmentwhichhas
bananaplugrecepticals,sothatiswhatIusedhereinsteadofaphoneplug
foruniversality.Myenclosureisa6.5"x4.5"x2.5"blackplasticbox.Allofmy
parts,includingtheenclosureandarduinowerepurchasedonNewarkfor
about$75.
Myonlyconcernisthatitdoesn'toutputmuchcurrent,butI'msureIcancome
upwithsomethingtoworkaroundthat.Greatproject,easytobuild,works
great!Thanks!
(http://cdn.instructables.com/F8W/6BZ0/HZNYIDEE/F8W6BZ0HZNYIDEE.LARGE.jpg)
jim_lewis1(/member/jim_lewis1/)
2yearsago
Reply
Fantasticinstructableandreallyusefuldeviceproduced.Anychanceyoucan
offerakitofthis?
(/member/jim_lewis1/)
amandaghassaei(/member/amandaghassaei/)(author) jim_lewis1
2yearsago
Reply
enriqueO(/member/enriqueO/) amandaghassaei
Reply
thanks!Iwasactuallyjusttalkingaboutmakinga
shieldyesterday.staytuned,hopefullyIcangetit
(/member/amandaghassaei/)
doneinthenextmonthorso.
10monthsago
andifIwantedtoaddamorewavesignalaswould,?Ineedtomake
(/member/enriqueO/)
onebutIaskedtobe5signs...pleasehelp
AlecD(/member/AlecD/)
11monthsago
Reply
Partnumber8needsarevision.10.01f50VCeramicDiscCapacitordoesnot
(/member/AlecD/)
exsist.Howeveryourlinkpointsto1000pf.Imgoingtobuildwiththe1000pf.
ggaldino(/member/ggaldino/)
11monthsago
Reply
anysuggestionsofhowtoimplementaLCDdisplayingthewaveparameters?
(/member/ggaldino/)
allthesetiminginterruptsmaycausethelibtonotfunction!
1yearago
hemalchevli(/member/hemalchevli/)madeit!
Reply
(/member/hemalchevli/)
Hereismyversion.Imadeastandalonesystem,noshields,blog
http://blackelectronics.com/blog/arduinowaveformgenerator/
(http://cdn.instructables.com/FMR/8SKA/HX41RFLG/FMR8SKAHX41RFLG.LARGE.jpg)
140of
139
Next(http://www.instructables.com/id/ArduinoWaveformGenerator/?
&sort=ACTIVE&limit=40&offset=40#DISCUSS)
Wehaveabenicecommentpolicy.
Pleasebepositiveandconstructive.
IMadeit!
AboutUs
AddImages
MakeComment
FindUs
WhoWeAre(/about/)
Facebook(http://www.facebook.com/instructables)
Advertise(/advertise/)
Youtube(http://www.youtube.com/user/instructablestv)
Contact(/about/contact.jsp)
Twitter(http://www.twitter.com/instructables)
Jobs(/community/PositionsavailableatInstructables/)
Help(/id/howtowriteagreatinstructable/)
Pinterest(http://www.pinterest.com/instructables)
Google+(https://plus.google.com/+instructables)
Tumblr(http://instructables.tumblr.com)
enteremail
Join!
TermsofService(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
PrivacyStatement(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079)
|
Resources
Mobile
LegalNotices&Trademarks(http://usa.autodesk.com/legalnoticestrademarks/) | MobileSite(http://m.instructables.com)
ForTeachers(/teachers/)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
ArtistsinResidence(http://www.autodesk.com/artistinresidence/home)
2015Autodesk,Inc.
DownloadournewappsforiOS,
AndroidandWindows8!
GiftProAccount(/account/give?sourcea=footer)
Forums(/community/)
Answers(/tag/typequestion/?sort=RECENT)
Sitemap(/sitemap/)
Android
(https://play.google.com/store/apps/details?
id=com.adsk.instructables)
iOS
(https://itunes.apple.com/app/instructables/id586765571)
Windows
(http://apps.microsoft.com/windows/en
us/app/7afc8194c771441a9590
54250d6a8300)
GoProToday(/account/gopro?sourcea=footer)
We'reHiring!(/community/PositionsavailableatInstructables/)