Step 5: Download Waveform Generator Application

If you are using the EVAL-USB-64, you can download the waveform generator .hex file and move on to the next step

Alternative Path:

If you are using an alternative platform you will need to download and compile the source code. All the code is in a single .c file which is written to be compiled with AVR-GCC. If you are running on a Windows PC you can download the following two packages and compile and program the application on to your board.
1) Download WINAVR
2) Download AVR Studio IDE
3) Create new avr-gcc project in AVR Studio and paste the source code into the initial .c file
4) Compile (creates .hex file to load onto target device)

<p>Hi!</p><p>(sorry for my english)<br>It's a great site and instruction but c source file is missing. I will be very grateful for reload this file.<br>Best regards - piotr </p>
<p>Broken link. I will try to fix this evening. Sorry about that!</p>
<p>Hi!</p><p>Seem to be missing the source code. Is the link broke?</p><p>-Andy</p>
<p>Broken link. I will try to fix this evening. Sorry about that!</p>
My usbasp(atmega8) having an error,How can i solve it? <br>Executing: &quot;C:\Users\god\AppData\Local\Temp\RSIF5F2.tmp&quot; -p m8 -c usbasp -C &quot;C:\Users\god\AppData\Local\Temp\RSIF5F3.tmp&quot; -P usb -U flash:w:&quot;C:\Users\god\Desktop\TimerSchool.asm&quot;:i <br> <br>RSIF5F2.tmp: AVR device initialized and ready to accept instructions <br> <br>Reading | ################################################## | 100% 0.02s <br> <br>RSIF5F2.tmp: Device signature = 0x1eff1e <br>RSIF5F2.tmp: Expected signature for ATMEGA8 is 1E 93 07 <br> Double check chip, or use -F to override this check
<p>hi, i'm from M&eacute;xico. this instructable is very interesting for me, because i need to construct an ultrasonic frequency generator. i actually work in a project of the called smart windows, and i use a ultrasonic frequency generator and an atomizer nozzle in order to deposit thin films of NiO on ITO substrates. The generator that i'm utilizing is on the range of 0-130 kHz. so, i need to know if this instructable could be useful to me for construct my own generator with those characteristics. Thanks, C&eacute;sar.</p>
Hi wandererwolf, Iare quieted to generate 20khz sine wave using xmega128a1 board. I read one of your post that your code might work with xmega128a1 board. Can I have your code and project files? I would like to give it a try. Thanks.
This is an excellent instructable; the arbitrary waveform generator specifications are quite impressive for a such a low cost of implementation. I'm writing because Boston Android is no longer making development boards, and I'm not seeing alternatives via a Google search, other than a $199 Atmel development kit. Could you recommend a dev board?
Check out the boards from Mattair Tech (http://www.mattairtech.com/). They offer various Xmega development boards and the code should be portable to their boards with a little effort. Let me know if you need help; I can send you the source code and project files.
how would I boost the voltage amplitude of the frequency from 3V to 20V? if it uses opamps then what opamps would be best for boosting voltage which would cover all or most of its frequency ranges from 1hz ~ 500khz?
The output of the Xmega DAC can generate 0-3.3V and a few mA of current. To get higher voltage you will need (as you suggest) an opamp (low current only) or a linear amplifier circuit capable of driving your load. <br><br>What are you attempting to drive up to 20V? Is it a speaker? Any requirements for efficiency? Do you have a 20V supply to drive the output?<br><br><br>
Basically I would be using it for all kinds of experiments, speaker, radio,EM , even experimental motor. but id be using the arbitrary waveform feature in most of these experiments, im wondering what is the range of the arbitrary function is it 140hz to 500KHz?
An LM386 would be a cheap and easy way to amplify the lower end of that frequency spectrum, and it can output a reasonable amount of power (I seem to remember 0.5 watts for SMD and 1 watt for the DIP version). <br> <br>An OPA132 has a GBP of 20Mhz (gain of 40 at 500khz)... and if I recall can output 25 millamps, which is pretty good for an opamp of that bandwidth. They're nice and stable too, but like 6$ a pop. <br> <br>Those are the simplest solutions that come to mind.
In theory the DAC can run up to 2MHz, but the example code here can only reach about 100KHz. For 500KHz you will be limited to square waves and need to write your own code to drive the DAC that fast.<br><br>As for the output stage going up to 20V you should do a search for linear amplifiers. You could probably just use an Audio Amplifier circuit. They have some at http://www.sparkfun.com/ which can boost the signal output from this board to the power levels you're talking about. I've used an amplifier off ebay (search for TA2024 amplifier about $9) to generate high frequency signals to drive a small speaker. Don't ask why. ;-)<br><br>
You could definitely use an opamp amplifier circuit to boost the output voltage to 20V over that frequency range. The only limit of an opamp is that it generally is only used for low current applications. For example you wouldn't use an opamp circuit to generate a signal to drive a motor, etc.<br><br>If you do a web search there are lots of example opamp circuits to choose from. I would breadboard them and try them out.<br><br>Best of luck!
Is it possible to use the code for an Xmega128A1?
Atmel worked very hard to make all the Xmega chips in the family derivatives of the Xmega128A1. So for example an Xmega128A3 just has fewer pins and fewer peripherals, but the ones it does have reside at the same addresses as the bigger Xmega128A1 chip. They also arranged memory at the same start addresses regardless of memory size. In theory all this means binary compatibility between chips (as long as the peripherals are available), so you MIGHT be able to load compiled code for the Xmega64A3 on to an Xmega128A1 and have it work, but there may be some catch. Certainly worth a try!
Ok, thanks for fast support. But I have an another question. Im using an STK600 board and I have no serial terminal. Which parameters can change the frequency? I need 20 khz sinewave.
Very nice, thank you. Do you think it would be possible to extend this design to use an external 16-bit DAC, like the TI DAC8830, for improved 16bit resolution and better drift stability? Most DACs use SPI as the interface, what would it take to hook these up?
There are several dedicated SPI interfaces on the Xmega chip you could use to interface with an external DAC. You can also configure the USARTS on every port to master SPI mode.<br><br>If you need more help let me know.
how can i program the at89s52,,can you help
This instructable is specific to the Atmel Xmega microcontroller which includes an integrated DAC. I believe if you search you can find examples of waveform generation on an Atmel 8bit microcontroller such as the at89s52 using a resistor ladder.
I loaded C program seems to be missing h file got 37 errors and 19 warnings. Can you help.
The only header files included in xmega-waveform-serial.c are provided by WinAVR/AVR-GCC. Could it be AVRStudio (or whatever build environment you are using) is having trouble finding the path to the header files? Usually, the compiler will tell you if it can't find a particular header file. If you email me your AVRStudio project file, I will check if everything is setup correctly.
I found it necessary to tweak the baud rate in order to get reliable communication with hyperterminal &nbsp;- Here's the code.&nbsp;<br> <br> <br> // 9600 @ 32Mhz as calculated from ProtoTalk Calc<br> // see web page at: <a href="http://prototalk.net/forums/showthread.php?t=188">http://prototalk.net/forums/showthread.php?t=188</a><br> <br> &nbsp;USARTF0.CTRLC = USART_CHSIZE_8BIT_gc | USART_PMODE_DISABLED_gc;<br> <br> int bsel = 3317;<br> uint8_t bscale = 12;<br> <br> USARTF0.BAUDCTRLA = (uint8_t) bsel;<br> USARTF0.BAUDCTRLB = (bscale &lt;&lt; 4) | (bsel &gt;&gt; 8);<br> &nbsp;
Cool Stuff, also check out my own XMEGA oscilloscope, arbitrary waveform generator and calculator: Xmegalab<br> <a href="http://www.gabotronics.com/development-boards/avr-xmegalab.htm" rel="nofollow">http://www.gabotronics.com/development-boards/avr-xmegalab.htm</a><br>
How do I do this on OS X 10.5.8?
So I tried this on my mac first and I thought that my terminal program wasn't working... So I tried it on a winxp box with hyperterm and I'm getting the same issue. When I connect to the device and type 'h' an 'o' shows up and pressing enter gives me a 'm'. I wrote the program to the device with AVRDUDE on my mac and I didn't get any errors. What could be my problem?
Woohoo got it working with the new hex file:<br> http://www.bostonandroid.com/binaries/xmega-waveform-serial2.hex<br> <br> When I tried uploading with avrdude on my mac I got:<br> <br> avrdude: verifying ...<br> avrdude: verification error, first mismatch at byte 0x0000<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x0c != 0xff<br> avrdude: verification error; content mismatch<br> avrdude done. Thank you.<br> <br> but using avrdude in win xp worked.<br> I was able to connect and control with my mac though using screen:<br> <br> sexybeast:avrdude aaron$ screen /dev/tty.usbserial-A800cAoo 9600
I haven't tried this on a Mac, but as long as you have AVRDUDE installed you should be able to load the code over the serial port using the OSX commandline and then use whatever terminal program you have handy to open a terminal connection over the serial port to the board. I'm not sure how OSX names serial ports (in windows and linux they are COM1 COM2, etc) When you get it working post any tips or tricks you used. :-)
Nice job.&nbsp; I just studied waveforms as part of my Amateur Extra class Ham license.&nbsp; Now I can make them.&nbsp; Like the evaluation board.&nbsp; I was unaware of this source.&nbsp; Thaks.
I&nbsp;believe the Arduino family is based entirely on Atmel ATmega chips which do not include a DAC. One of the nice features of the XMega family is that Atmel finally put a DAC on an 8bit micro. I&nbsp;wouldn't be surprised though if someone is already working on porting the Arduino environment to XMega for future boards.<br />
Really nice.&nbsp; I was just wondering whether you could use an Arduino for that.&nbsp; Thanks for sharing.<br />
<br /> Nice - Make an Empire State building waveform!!<br /> <br />
To generate the elusive Empire state building waveform execute the following command:<br /> <br /> <strong>w 1000 20 0 0 0 0 0 800 3000 3300 3400 4095 3400 3300 3000 800 0 0 0 0 0 0</strong><br /> <br /> <a href="http://www.bostonandroid.com/examples/esb.bmp" rel="nofollow">pic</a><br />
<br /> Awesomeness&nbsp;knows no bounds!!<br /> <br />

About This Instructable




Bio: I grew up in upstate NY where I speant many hours with my brothers playing with legos (I once attempted to test relativity by connecting ... More »
More by wandererwolf:Atmel Xmega USB/Serial Arbitrary Waveform Generator Easy Atmel Xmega Sine Wave / Waveform Generator 
Add instructable to: