Step 2: Enclosure

I decided to laser cut a custom enclosure for my project.  I designed the enclosure using AutoCAD, Autodesk 123D Make, and Corel Draw, and I've included corel draw and adobe illustrator 2D files as well as the STL, and DWG files from this process below.  If you do not have access to a laser cutter, you can use my 2D files a guide and drill the necessary holes in a project enclosure of some kind.  Figure 4 shows the holes that should be drilled on the front panel:

(3x) 7mm holes for gain, freq, and PWM pots
(3x) 7mm holes for four push buttons- sin, saw, tri, and pulse
(1x) 10mm hole for audio out
I cut out shapes of all four waveforms in the front of the enclosure so that I could backlight them with indicator LEDs, you may choose to just drill four 5mm holes for these LEDs in the front panel of the enclosure, place one LED under each momentary switch.
Also include a rectangular (11mm tall, 12mm wide) cutout somewhere on the side of the enclosure for the arduino's usb port.

I made my project enclosure out of wood, so I had to glue all the pieces (except the bottom) together with wood glue.  I will attach the bottom panel on later in this instructable.
<p>hi, i have this error:</p><p>Arduino: 1.6.5 (Windows 7), Board: &quot;Arduino Nano, ATmega328&quot;</p><p>In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,</p><p> from function_generator.ino:30:</p><p>function_generator:30: error: variable 'sine20000' must be const in order to be put into read-only section by means of '__attribute__((progmem))'</p><p>variable 'sine20000' must be const in order to be put into read-only section by means of '__attribute__((progmem))'</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p><p>pleaseeeeee help me </p>
<p>Try using Arduino IDE 1.0.5 -- that fixed my problems for me.</p>
<p>Hello amanda .. i made this project nut when i upload the given code it gives me following error <br></p><p><br> from function_generator.ino:30:<br><br>function_generator.ino:30:18: <br> error: variable 'sine20000' must be const in order to be put into <br>read-only section by means of '__attribute__((progmem))'Can yu please help me out</p>
<p>Try using Arduino IDE 1.0.5 -- that fixed my problems for me.</p>
<p>Just now, I compiled the sketch with Arduino 1.0.6 set to Uno, and it didn't have a problem. So I can't prove I've found your answer. What board are you compiling for that gave you this error?</p><p>Sometimes I accidently type something into a sketch without knowing it, that causes it to crash. You could try reloading the sketch from the original &quot;untouched&quot; source.</p><p>The &quot;30:18&quot; in your error message means it happened on line 30, and the 18th characcter in from the left. The error message states the line should be a &quot;const&quot;, so I did that, I added the word &quot;const&quot; so the line starts with &quot;const byte sine20000&quot; instead of just &quot;byte sine20000&quot;, and again, it compiled just fine for me.</p><p>Give that a try.</p><p>&quot;const&quot; means the values in that line will not be changed, which I beleive is correct since it's only read -- over and over again -- to make the sine wave.</p>
<p>Arduino: 1.6.5 (Windows 8), Board: &quot;Arduino Uno&quot;</p><p>In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,</p><p> from function_generator.ino:30:</p><p>function_generator:30: error: variable 'sine20000' must be const in order to be put into read-only section by means of '__attribute__((progmem))'</p><p>variable 'sine20000' must be const in order to be put into read-only section by means of '__attribute__((progmem))'</p><p>Please help me out!!</p>
<p>Try using Arduino IDE 1.0.5 -- that fixed the problems for me.</p>
<p>Arduino: 1.6.1 (Windows XP), Board: &quot;Arduino Uno&quot;</p><p>function_generator.ino:30:8: error: 'sine20000' does not name a type</p><p>In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,</p><p> from function_generator.ino:30:</p><p>function_generator.ino: In function 'void __vector_11()':</p><p>function_generator.ino:227:31: error: 'sine20000' was not declared in this scope</p><p>Error compiling.</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences. </p><p>I get the following error while i compile the code in arduino IDE. I tried alot. but could't solve the problem. Would anybody please help me ?</p>
<p>Try using Arduino IDE 1.0.5 -- that fixed my problems for me.</p>
<p>After googling for &quot;Sine Wave Circuit&quot;, I was delighted to find this &quot;Arduino&quot; sine wave circuit, because I love working with Arduino and it's compatible modules. Also, the lazer cutter used here was a wonderful discovery for me too! I didn't even know there was such a thing, but now must have one to add a professional look to the projects I sell.</p><p>However, the article has room for improvement, which is the reason for this comment. Here are my suggestions:</p><p>1. The several places the text refering to &quot;300Ohm&quot;, and &quot;470Ohm&quot; need a space to make it &quot;300 ohm&quot; and &quot;470 ohm, so it doesn't look like a value ten times larger than intended.</p><p>2. One schematic shows the 300 ohm resistor and cap for the low pass filter. But the other schematic omits this circuit.</p><p>3. Although the photography is very clear, no one picture shows all the wiring where it's easy to understand everything at once. Take a look at</p><p>http://1.bp.blogspot.com/-FLaRrce1svE/VFtEWeuSL0I/AAAAAAAAANI/1GbkconjhXU/s1600/bluetoothcontrol_bb.jpg</p><p>Every wire -- and where it connects -- is easy to see in one picture. And like in this picture, I always try out my projects on a white breadboard first; for it's far easier to try out alternatives and correct mistakes where all parts plug and unplug, than it is on a project board where you have already soldered the parts permanently in place.</p><p>4. The text says, &quot;A 4.7kOhm resistor bridges pins 3 and 4 of the IC socket.&quot; Yet the schematic shows this as being a 2.2k ohm resistor. Which value is correct?</p><p>5. It would help to have a note on the pictures, explaining you can mouse-over the rectangles to pop up notes on what's inside the rectangle. I'd nearly finished the project before discovering this.</p><p>6. One such rectangle (over a straight section of wire in a schematic) says a resistor should have been here. Why not just add the resistor to the image and reload it? The note is easy to miss (and thus the need for the resistor.)</p><p>7. Another mouse-over rectangle says the color code on the resistor shown is wrong. So why not just use an art program to paint the correct colors on the resistor, and re-upload the image?</p><p>I think this is a GREAT project; exactly what I needed. But the above seven items make it hard to follow correctly. For the benefit of others, I'd LOVE to see these modifications made.</p>
<p>Hello Paul .. i made this project nut when i upload the given code it gives me following error</p><p><br> from function_generator.ino:30:<br><br>function_generator.ino:30:18: error: variable 'sine20000' must be const in order to be put into read-only section by means of '__attribute__((progmem))'</p><p>Can yu please help me out<br></p>
<p>What version of the Arduino IDE are you using? Try using 1.0.5 -- that fixed the problem for me.</p>
<p>Hi My name is anto , I am building a sig gen for a project in college. I planned to have a large array and increment by different values to give me different frequencies so that that the frequency resolution will be intergral multiples of the lowest frequency. I presumme that is what u did . My problem is that if make the array too big the lowest frequency sine wave is very distorted. the lowest frequency i can get is about 400Hz any lower it is not good. Also I dont use a timer interupt i am just using a tight loop with a quick check on PINB for button presses.</p><p>I used a ladder DAC like yours and it is smoothing out my signal without a lowpass filter. </p><p>Did you have any problems like these yourself , I would really appreciate help.</p><p>Thanks so much Anthony</p>
<p>Why don't you account for the 10K equivalent resistance of the R2R ladder when dimensioning the RC filter?</p>
<p>how can i upload this on attiny4312 ?</p>
<p>I have been disappointed with it.</p>
<p>Is there a point in storing 20000 samples? If our DAC can only represent 2^8 values? Surely 256 samples should be the maximum sample resolution? Im a bit confused. Nice project :)</p>
<p>Think of a sine wave in the x-y plane. There are only 256 y values available, because that's the resolution of the arduino's analog output pins. However, we can have as many x values as we need, to some extent.</p><p>So the question becomes what is the smallest number of x values you need for it to still look like a sin wave. The author chose 20k, but you could do more or less if you wanted to. As I see it, the only reason to do more is for higher resolution at lower frequencies, and the only reason to do less is to save storage space.</p>
<p>Hey, would it be possible to convert this project to a synthesizer dual DCO? Midi controlled and with one output for each DCO where DCO2 frequency is DCO1*detuneFactor (set by a pot on an analog pin, range +/- 1 octave so detuneFactor would have to go from 0,5 to 2)</p>
<p>hey i have to take the output of the arduino through earphones instead of speaker.. my arduino output is working pretty fine with speaker.. but i have to switch it now to earphones. can you please guide </p>
<p>The problem with earphones is that they put all that power right into your ears! Just connect a resistor in series with each earphone wire. If they are 8 ohm ear phones, a ten ohm resistor would reduce the power about in half, a 33 ohm resistor would reduce it to 1/4th as loud, etc. </p>
<p>Hello Amanda,</p><p>can i use arduino atmega2560 in place of uno???</p><p>thank you!</p>
<p>If you already have your atmega2560, just try loading the software sketch this instructable provided into your Adruino. If the the Arduino tells you it's happy with it, that should bve your answer.</p>
<p>Is there any particular reason for the 35 V rating on the 220 microF capacitors? I already have a set of 16V and was wondering if there would be any reason I couldn't use them</p>
<p>No, no reason why you cannot use your 16 V caps. I guess the 35 V volt ones was what the author had available at that moment. As a general rule: as long as the capacitor voltage rating is higher than the supply voltage of your circuit, it will be OK.</p>
<p>How can I change the R 2R resistor set for a DAC08 (<a href="http://docs-europe.electrocomponents.com/webdocs/077f/0900766b8077fe46.pdf" rel="nofollow">http://docs-europe.electrocomponents.com/webdocs/0...</a>) in order to save components? What connections do I have to do?</p><p>Thank you</p><p>Great project</p>
<p>Hi Amanada.</p><p>can i use arduino atmega2560 in olace of uno???</p><p>thanks..</p>
so im not 100 sure on the math but im short a few 10k resistors.. if I just do 2 4.7k resistors in series will that be close enough? will that just affect the amplitude a small bit?
<p>Amazing and well laid out! I look forward to making one!</p>
<p>Great work! Very well thought out and quite useful. Using an Arduino instead of a professional arbitrary waveform generator can save us a bunch of money. <br>I have one suggestion, however: add a button that, when pressed, will send just one cycle of the selected waveform in the selected configuration (one-shot trigger). </p>
Hi there; this has been a great project so far! <br> <br>I just wanted to ask about one hiccup im having. For some reason, the signal coming out from my amp is clipped clean in half, only going up to about half the voltage it should be before just flattening off. The signal coming into the amp is nice and clean, and im fairly sure ive got everything wired up with the same components you used, although my amp is an lm386n-1; do you suppose that could be what's making the difference? I couldnt find anything different about it's specs, but I'm really just a beginner, so I wouldnt know for sure. <br> <br>Anyway, thanks for a brilliant tutorial!
Ah, my mistake actually; got confused with the AC readings from my oscilloscope. It actually is getting the full voltage from the amp, but it's still clipping. I put 3 20k resistors in series with the frequency coming from the arduino, and it's fixed the clipping, but it hardly seems an ideal solution. Is there something else I could be doing to lower the gain on the amplifier?
I too am having a clipping problem ... can you please tell me where to hook to 20k resistors to resolve this ?
what op amp are you using?
oh i see, a lm386. you should wire it up like this: <br />http://letsmakerobots.com/node/4870
<p>are the momentary sqitches normaly Open or normally closed?</p>
normally open
<p>thnx ur awesome!</p>
<p>that resistor looks like a 10k not a 20k</p><p>what do i do??</p>
<p>Hi Amanda, I made your signal generator. </p><p>Why then the output signal from the LM386 truncated vertices, in what could be the reason? Arduino itself gives the right signal and this signal LM386 spoils.</p>
<p>Hi Amanda, I see that you have an amazing 20,000 values for the sine function. Since you only have an 8-bit DAC with 256 levels, is this actually necessary. Can you explain how this adds resolution?</p>
<p>Am I right in thinking that because the frequency is set by reading the voltage at one of the analogue inputs, that there will only be 1024 steps in frequency between 1Hz and 50Khz? Is there anyway of being able to set the frequency in code?</p>
<p>any suggestions of how to implement a LCD displaying the frecuency ***FREQUENCY METER**</p>
<p>I needed a function generator for testing circuits, but couldn't afford to spend several hundred (or more) dollars. This one worked perfectly. I upgraded a few of the parts (for more accurate gain and frequency, I have a 10-turn potentiometer), and also have an option to connect an external voltage supply instead of using a battery for projects that I know will take a while. Having the 9v battery available for quick access and portability is very nice. I changed the code around just a bit so that the initial waveform is sine instead of square, and to allow a lower frequency (about 15hz). I changed freqTolerance to 1 since I upgraded the pots. I also used an actual switch for power (no reason other than just person preference). I use a lot of other equipment which has banana plug recepticals, so that is what I used here instead of a phone plug for universality. My enclosure is a 6.5&quot; x 4.5&quot; x 2.5&quot; black plastic box. All of my parts, including the enclosure and arduino were purchased on Newark for about $75.</p><p>My only concern is that it doesn't output much current, but I'm sure I can come up with something to work around that. Great project, easy to build, works great! Thanks!</p>
Fantastic instructable and really useful device produced. Any chance you can offer a kit of this?
thanks! I was actually just talking about making a shield yesterday. stay tuned, hopefully I can get it done in the next month or so.
<p>and if I wanted to add a more wave signal as would,? I need to make one but I asked to be 5 signs ... please help</p>
<p>Part number 8 needs a revision. 10.01&micro;f 50V Ceramic Disc Capacitor does not exsist. However your link points to 1000pf. Im going to build with the 1000pf.</p>
<p>any suggestions of how to implement a LCD displaying the wave parameters? all these timing interrupts may cause the lib to not function!</p>

About This Instructable


469 favorites


Bio: I'm a grad student at the Center for Bits and Atoms at MIT Media Lab. Before that I worked at Instructables, writing code for ... More »
More by amandaghassaei: OTCA Metapixel - Conway's Game of Life "9 Degrees of Freedom" IMU Twitter Controlled Pet Feeder
Add instructable to: