Instructables
loading
loading
Picture of Arduino Waveform Generator
IMG_4724.jpg
function generator_schem.png
Screen shot 2012-11-29 at 12.32.37 PM.png
Waveform generators (also called function generators) are useful for testing and debugging circuits.  I often use them to test the frequency response of electronics components like op amp and sensors.  This waveform generator is powered by an Arduino.  It outputs four waveshapes: sine, triangle, pulse, and saw, each waveshape ranges in frequency from 1Hz-50kHz.  The frequency, pulse width, and overall amplitude (gain) of the waveforms is controlled by three potentiometers.  I've also included (optional) indicator LEDs that let you know which type of wave is currently being sent to the output.



Parts List:

(4x) Mini SPST 1.5-Amp Momentary Pushbutton Switch (2 packages) Radioshack #275-1556
(8x) 10K Ohm 1/4-Watt Carbon Film Resistor  (2 packages) Radioshack #271-1335
(9x) 20K Ohm 1/4-Watt Carbon Film Resistor (2 packages)
(1x) 50K-Ohm Linear-Taper Potentiometer Radioshack #271-1716
(1x) 10K-Omh Audio-Taper Potentiometer Radioshack #271-1721
(1x) 10K-Ohm Audio Control Potentiometer with SPST Switch Radioshack #271-215
(1x) 1/8" Stereo In-Line Audio Jack Radioshack #274-274
(1x) 10.01µf 50V Ceramic Disc Capacitor Radioshack #55047551
(1x) 4.7K Ohm 1/4-Watt Carbon Film Resistor Radioshack #271-1330
(1x) 8 Pin Socket Radioshack #276-1995
(1x) LM386 Low Voltage Audio Power Amplifier Radioshack #276-1731
(2x) 220µF 35V 20% Radial-lead Electrolytic Capacitor (or anything between 200 and 300 uF) Radioshack #272-1029
(1x) Arduino Uno REV 3 Radioshack #276-128
(1x) Arduino Proto Shield Radioshack #276-140
(4x) White Super-bright LED Indicator Radioshack #55050633
(4x) 740 ohm 1/4W 5% Carbon Film Resistor (1 package) Radioshack 271-1317
(1x) 300Ohm resistor


Additional Materials:

Heat Shrink Radioshack #278-1611
22 Gauge Wire Radioshack #278-1224
Solder Radioshack #64-013
Drill
Hot Glue
Glue
Black diffusor material (tissue paper, plastic, etc)
 
Remove these adsRemove these ads by Signing Up

Step 1: Prepare Arduino Proto Shield

Picture of Prepare Arduino Proto Shield
IMG_1779 1.JPG
IMG_1781 copy.jpg
IMG_1783 copy.jpg
IMG_1782 1.JPG
The Arduino Proto Shields are a convenient way to attach circuits to an Arduino, but I like to trim them down a little bit first so they do not take up so much room in the project enclosure.   Start by trimming the pins down with a pair of wire cutters.  Next, cut off the six pin socket.  Finally, cut the sockets from the top of the board.
1-40 of 131Next »

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

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.

Hello Amanda,

can i use arduino atmega2560 in place of uno???

thank you!

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.

tony.kupcho19 days ago

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

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.

How can I change the R 2R resistor set for a DAC08 (http://docs-europe.electrocomponents.com/webdocs/0...) in order to save components? What connections do I have to do?

Thank you

Great project

Adi M1 month ago

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 :)

Hi Amanada.

can i use arduino atmega2560 in olace of uno???

thanks..

MatthewT71 month ago
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?
aplavins1 month ago

Amazing and well laid out! I look forward to making one!

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.
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).

Pythag1 year ago
Hi there; this has been a great project so far!

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.

Anyway, thanks for a brilliant tutorial!
Pythag Pythag1 year ago
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?
guy gibbs Pythag2 months ago
I too am having a clipping problem ... can you please tell me where to hook to 20k resistors to resolve this ?
amandaghassaei (author)  Pythag1 year ago
what op amp are you using?
amandaghassaei (author)  amandaghassaei1 year ago
oh i see, a lm386. you should wire it up like this:
http://letsmakerobots.com/node/4870
astein-15 months ago

are the momentary sqitches normaly Open or normally closed?

amandaghassaei (author)  astein-15 months ago
normally open

thnx ur awesome!

astein-15 months ago

that resistor looks like a 10k not a 20k

what do i do??

dimaris5 months ago

Hi Amanda, I made your signal generator.

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.

jasper5006 months ago

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?

jasper5006 months ago

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?

lopsan9317 months ago

any suggestions of how to implement a LCD displaying the frecuency ***FREQUENCY METER**

JoshS27 months ago

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" x 4.5" x 2.5" black plastic box. All of my parts, including the enclosure and arduino were purchased on Newark for about $75.

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!

20140904_163441.jpg
jim_lewis12 years ago
Fantastic instructable and really useful device produced. Any chance you can offer a kit of this?
amandaghassaei (author)  jim_lewis12 years ago
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.

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

AlecD8 months ago

Part number 8 needs a revision. 10.01µf 50V Ceramic Disc Capacitor does not exsist. However your link points to 1000pf. Im going to build with the 1000pf.

ggaldino8 months ago

any suggestions of how to implement a LCD displaying the wave parameters? all these timing interrupts may cause the lib to not function!

hemalchevli made it!9 months ago

Here is my version. I made a standalone system, no shields, blog

http://black-electronics.com/blog/arduino-waveform-generator/

IMG_20140701_160248412.jpg
amandaghassaei (author)  hemalchevli9 months ago
Nice!
TAGAPAW12 months ago

can i use this method to make a synth :)

amandaghassaei (author)  TAGAPAW12 months ago

yes it could be a starting point, that was my thought

When I open these files, all I see is a box. I don't see any of the laser cuttable panels. Could you please make these available, or, alternatively, if they are there and I'm just not able to see them, could you please show me how to access them?

amandaghassaei (author)  maxwelljets1 year ago

try the .cdr, you may have to instal corel draw.

Are the resistors for the four LEDs 740 ohm or 470 ohm? The instructions and part list are inconsistent so I'm not sure.

It doesn't really matter.

Everything between 100 and 1k ohm will do the job.

sorry about that, anything between 220 and 1k is fine, I think I actually used 470.
1-40 of 131Next »