Arduino Due Arbitrary Waveform Generator

Create arbitrary waves, classic waves, noise or even music - and the Due will generate it.

Dec 23, 2017

47332 views

45 respects

Components and supplies

1

Arduino Due

Project description

Code

IMPORTANT: Don't click the "Download as zip" button.

To download the files click "Read More" below. NOTE: Clicking "Download as zip" will only download a readme file.

Downloadable files

OPTIONAL output protection circuitry

This circuitry can be completely omitted, but if used it should protect the Arduino against accidentally connecting the outputs to voltages of up to at least plus and minus 25V without significantly increasing rise and fall times. D2 and D3 need to be high current, fast recovery diodes - I found that schottky diodes were too slow. The fuses (F1 and F2) can be polyfuses.

OPTIONAL output protection circuitry

OPTIONAL output protection circuitry

This circuitry can be completely omitted, but if used it should protect the Arduino against accidentally connecting the outputs to voltages of up to at least plus and minus 30V without significantly increasing square wave rise and fall times. The diodes need to be high current types. D2 and D3 (for the square wave only) also need to be fast recovery diodes if using at very high frequencies - I found that schottky diodes were a bit slow. The fuses (F1 and F2) can be polyfuses. If only using the analogue output for connection to an amplifier (e.g. for music) only ZD1 and R1 are needed for static protection (before the coupling capacitor). ZD1 can then be a low current type and a considerably higher voltage if necessary but not lower, and make R1 a much higher value (approx. 1 – 5k). Only two non-critical components needed, so don’t risk destroying your Arduino! (Note: A second similar resistor, in series with the coupling capacitor, would protect ZD1 if it’s a low current type.)

OPTIONAL output protection circuitry

Comments

Only logged in users can leave comments

BruceEvans

2 years ago

These comments are all mixed up and some missing. To view a proper list of comments visit the hackster website. Hopefully Arduino Project Hub will eventually correct this. Currently I can't even edit this project!

konzen8

2 years ago

Hi Bruce, is there a way in the code to externally trigger/synchronize the arb, from a pin? From using an external stable TTL source? The Arduino Duo would then give out the arb signal pattern synchronized to the external source, with wait till trigger. Would be a great powerful feature! Kon

Anonymous user

2 years ago

Hello, Could you please provide links where I can download the AWV files for the waveforms? Thanks!

BruceEvans

2 years ago

Hi, The .awv files are in the "Abitrary Waves" folder which should be created when you extract the .rar file you download following the instructions on this page. Regards, Bruce.

Anonymous user

2 years ago

Bruce A newbie will appreciate your help! Your project looks like the perfect tool to help solve a dying tree problem!!!!!! Running W10Pro 64/Ryzen5/8Gb, when I try to run 64bit AWG, the GUI panel appears and then closed, no fill. Same on laptop. Both have Java 8, latest. Downloaded 32 bit version. Runs on desktop but when I load sketch into Arduino and try to sent to Due, I get error in line 8 "import does not name a type" I read through the comments but no one else mentioned this problem ( probably smarter than me:))

BruceEvans

2 years ago

Hi Donald, Thanks for your reply, and good to hear you managed to create the waveform you required. Please let me know whether the genuine Due solves the reset at start-up issue. And if you have the time later, I'd love to know how you get on with curing the tree root problem. Good luck, Bruce.

BruceEvans

2 years ago

You're welcome. Regarding the tree root problem, what (low) frequency signal do you need and what wave-shape? And how do you intend to apply or broadcast it; as sound, vibrations, R.F. or what? Quite interesting. Regards, Bruce.

BruceEvans

2 years ago

Hi dhmcn, Sorry for the delay answering, I only just saw your comment today. Please make sure you are opening the DueArbitraryWaveformGenerator.ino in the Arduino IDE and not the AWGControllerWin.pde in the source folder. (You have to download the .ino file separately. Note: I've updated my Github page to make this clearer.) If that's not the problem, then: If I understand you correctly, the 32 bit GUI is running okay (on your PC), but you're getting errors in the Arduino IDE (on your PC) when you try to send the .ino sketch from the Arduino IDE to the DUE board. Is that correct? If so, can you send other (sample) sketches to it okay? Is the problem the same on the laptop? Regards, Bruce. PS: I'm curious about your "dying tree problem."

BruceEvans

2 years ago

Hi Donald, Yes, sometimes it's not worth it, but I have tried this AWG on a couple of cheap Chinese Dues and they were okay, so maybe you were just unlucky anyway. (Or perhaps I was just lucky!) Cheers, Bruce.

Anonymous user

2 years ago

Thanks for direction, all up and running. I am using up to 4 frequencies between 10 Hz and 1KHz. I used Excel and calculated the values for the sine based on one full wave of the lowest frequency ( then have the Arduino repeat the composite waveform at that frequency) and added the higher frequency components. Output that to a CSV per help file, realised that all of the number had to be positive up to 4096, redid the number and sent the composite curve to the Arduino. Scope on output shows exactly what is expected. We are looking at RF and vibration at the moment. The guys I'm working with are fixed on the idea of RF but I feel the power requirement is too high and, more importantly, the FCC and military are going to take a dim view of us pumping out RF under 1 KHz. My view is mechanical vibration may be the key are seismological equipment is available off the shelf. It also fits well with some of the papers I've read on plants internal signalling systems. I did encounter 1 problem, which has been referred to earlier. I have to cycle the reset button on the Arduino when starting you software to get the board recognised. I am using an OSOYOO clone ( which even has "made in Italy" on it!) I have ordered a genuine Due which will be here in a couple of days. In the meantime I'm going to try an external power source for the board to see if it could be a USB power issue. Thanks again for your project and for your help and guidance Donald

Anonymous user

2 years ago

Thank you, your help appreciated. I will now download the correct ino file and then go from there. I told you I was a newbie so this is a sort of " you have to plug it in first" moment. I am confident that I will go on to make far more complex mistakes! There is a fungus that attacks the roots of some trees and prevents them from taking up water and so they die. There has been a lot of research on the systems within plants. I have learned that there is a chemical, electrical and hydraulic system within plants. There are a number of low frequency signals that appear to help or cure the problem. I am looking at ways to treat areas rather than individual trees. I already know that the single tree treatment works but when you are faced with a few hundred ( On the Isle of Arran, off Scottish West coast, they are having to remove 500,000 larch trees because of a pathogen) I need some sort of broadcast. I'll follow you instructions and post results in the next day or two.

Anonymous user

2 years ago

Bruce Real Due arrived today, set it up ,uploaded sketch, loaded DueAWG and all worked first time. I should know better that to buy the Chinese fakes. It appears that they think that close enough is good enough. Added advantage to the real thing is that it came with a moulded mounting tray. Hold the due and keepr the board from scratching my desk or shorting out. The Chinese fake was $25 and the real thing was $45. It was not worth the saving to spend several hours faultfinding! Thanks again, next is use the Arduino to run sub woofer amps to gets some watts out there. Donald

Anonymous user

2 years ago

I haven't tried it out yet but it looks very impressive. Recommend a YouTube video to provide an introductory tutorial on using the application. Thanks! W

BruceEvans

2 years ago

Ahhh! so there's only one COM port recognized. I just put that message box in the code to help identify the problem if it still didn't work. It's very hard to figure out the problem without seeing it!! I've just modified the code again, so please download it again and you should see a different message box this time and be able to select COM4. Hopefully it'll connect then. Cheers, Bruce.

BruceEvans

2 years ago

Hi Willie, I still can't replicate the problem here, so I've added to the GUI the ability of manual COM port selection. This will be enabled if automatic connection fails. I hope this solves the problem. Please download the new version (v1.1) to try it out. And would you please let me know the result either way, thanks. Regards, Bruce.

BruceEvans

2 years ago

HI Willie, Thanks for your feedback. I'll investigate it as soon as possible. I assume you mean that the Due resets even when it doesn't connect. If this is not the case please let me know. Thanks, Bruce.

Anonymous user

2 years ago

Hi Bruce, Same result but now I do get an error message when it fails to connect. The error message states: "Your PC has recognized only COM4. The Arduino cannot be found there." -W

BruceEvans

2 years ago

Hi Willie, Thanks for your kind comments, too. If you try it you'll find there's a very comprehensive help file, so maybe a YouTube video isn't necessary. Cheers, Bruce.

Anonymous user

2 years ago

Hi Bruce, I reviewed your help file and took a look at your code. I intend to try it. Amazon is delivering my Due on Friday. Thanks! W

Anonymous user

2 years ago

Hi Bruce, My DUE arrived yesterday and I spent a little time to make sure it was functioning and to get familiar with it before trying out your code. I initially started with your serial command interface and had no problem. Like Brian, I encountered a startup initialization problem with the GUI. It appears it is something associated with the startup timing, as I can get the GUI to hook up with the DUE after several attempts of loading the GUI while simultaneously pushing the reset button on the DUE. The GUI does reset the DUE each time I start the GUI. In full disclosure, I also changed the timeout value on line 1143 to ten seconds from one second, but I'm not sure if that is making any difference. See below: else if (InputChar == 'G' && millis() < 10000) // if connecting to GUI: Timeout value changed from 1000 - Willie Aside from the startup issue, I have been able to successfully generate several waveforms with no problems. I am running Windoz 10 with Arduino IDE 1.8.5 from the Windows Store (version 1.8.10.0). I am using the Arduino DUE programming port (COM4). Let me know if you have any questions regarding the problem I am observing. Best regards, Willie

Anonymous user

2 years ago

Hi Bruce, I tried your latest version and your GUI was able to successfully connect with the DUE. Thanks for bearing with me! Best regards, Willie

Anonymous user

2 years ago

Bruce, Yes, it resets every time I start the gui. -W

Anonymous user

2 years ago

Fantastic project - I'm going to have to buy a Due and learn how to use Arduino just for this - so I'll tell my wife to blame YOU! I want to be able to call up a series of sine waves at half a dozen, quickly on-screen-button-selectable frequencies and set their amplitudes on-screen (by controlling the gain on an output buffer op-amp) to preset values also selectable on-screen, but with scaling constants set according to the frequency. This would result in a pretty darn good audiometer! Just letting you know and thanking yopu for your great work! If I progress far enough, I'll let you know.

BruceEvans

2 years ago

Hi chhackm, I only just noticed your reply. I don't seem to be receiving comment notification emails from this site anymore! Thanks for your "fantastic" comments, although I still refuse to accept the blame if it goes belly-up! LOL I'd love to hear how you get on with your project. You'll have to write a new GUI for the PC, I suppose. Regards, Bruce.

Anonymous user

2 years ago

Bruce, Congratulations by the nice project. However, I'm experiencing a problem with it, and I'd like your help. The ARDUINO DUE and the GUI connect without problem, however, just a mouse click on any component of the GUI so that the connection with the board is interrupted. To reconnect I need to close the GUI and restart the board. Any idea what might be happening? Thanks Breno

Anonymous user

2 years ago

Hi Bruce In fact, lowering the COM speed did not work. And yes, I was successful using the DUE command line. If you have any idea what might be happening ... Thanks

Anonymous user

2 years ago

Sorry Bruce. Yes, the GUI works even with a board disconnected. I can draw waveforms normally. Thank you for your attention, I will follow the procedures and post the result. Breno

Anonymous user

2 years ago

Hi Bruce My Arduino DUE drive was the initial suspicion. But we hoped to find another solution. Really, Processing is really cool. I did not know it, but in 3 minutes I was already exporting the executable program. Excellent project. Thank you for your support. Breno

Anonymous user

2 years ago

Hi Bruce I've already tested on another PC, always using the 32-bit version of the GUI, but the problem persists. Maybe the problem is in my DUE unit, which is actually a FREADUINO DUE V1.4 from elecfreaks.com. I thought of lowering the communication rate between the card and the PC to test if this could be the problem, how can I change this parameter in the GUI? Thank you again. Breno

BruceEvans

2 years ago

Hi Breno, Because you have the same trouble on 2 computers, and because nobody else has reported this problem despite many downloads, and because I have run the program successfully on multiple computers with a genuine Arduino Due and have also tried a cheap Chinese Due, but have not tried it with the same Due version as yours, I think you could be right suspecting your Due. It would be good if you had another one to try, wouldn't it? If anyone else has had this problem, we would like to hear from you!! Cheers, Bruce. PS: Did you install Processing 3? It looks really similar to the Arduino GUI, doesn't it?

BruceEvans

2 years ago

Hi Breno, I suppose I should have guessed the answer was yes. I suggest checking if you can control the DUE using Arduino's serial monitor at 115200 baud. If you can, then I would not expect the com rate to be the problem. If you can't, it would be easier to just change the rate in the .ino file at first, to see if it helps (using the monitor).

BruceEvans

2 years ago

Hi Breno, You appear to have forgotten to answer the following question: Will the GUI operate WITHOUT the DUE connected? (just to open or draw waves, or access the help file, etc.) If the answer is no, then your suggestion and question may be irrelevant, but I'll answer it anyway: The GUI program was created using "Processing" - the program that Arduino was originally based on. So in order to change the com rate you would need to install Processing 3 on your PC so you can change the DueArbitraryWaveformGenerator.pde file (found in the source folder). If successful, you could then "export the application" to create the DueArbitraryWaveformGenerator.exe file. (as well as changing the Arduino .ino file)

BruceEvans

2 years ago

Hi Breno, Thanks for your comment. Regarding your question: Will the GUI operate WITHOUT the DUE connected? (just to open or draw waves, or access the help file, etc.) - If the GUI does not operate, make sure the correct folders have been created when extracting the .rar file. Especially the data folder. Make sure the settings.awg file exists in this folder. Did you use the DueAWGController32.rar file? (The DueAWGController64.rar can cause problems.) - If the GUI does operate, this may indicate it's not connecting to the DUE correctly, despite reporting that it IS connected. In this case, the problem could be harder to find. Does everything work okay on a different computer WITH the DUE connected? Cheers, Bruce.

Anonymous user

2 years ago

Hi Bruce My Due (banggood clone) finally arrived and I had some trouble getting the GUI program to connect. My Due (programming port) shows as COM15 on my win10 x64 machine. The GUI program (32bit because 64bit just gives a blank window) gave me the choice of ports, but would never find the Due on any port I chose. I did manage to get it to find the Due by repeatedly pressing the reset button on the Due (at about 2Hz) and then selecting COM15 in the GUI program startup. From then on it appears to all be working. Hope this helps.

Anonymous user

2 years ago

Subsequent connections seem to work ok now without having to do the reset button dance. So that was pretty weird. Anyway I have another question... I need the arb wave and the square wave in sync, but how can I stop it doing the mirrored version of the arbitrary wave when the sync output is high? I can't just set it to 0% duty because I need a sync signal on that square wave output and setting duty to zero completely removes it.

BruceEvans

2 years ago

Hi user1605739, There is no other way to avoid the mirrored effect, but here are two possible solutions to your problem: If the frequency is not important: The arbitrary wave and the UNsynchronized square wave automatically synchronize anyway at certain precise frequencies, for example 1kHz (the start-up frequency). So just select this frequency for both waves with the arbitrary wave set to 0% duty cycle, and then the square wave can be set to a different duty cycle. Please note that when the duty cycle is set to 0% (or 100%) the square wave does NOT disappear, but the resultant 'pulse' may be as short as 48 nano seconds. (see Specifications in the help file, or above on this page.) This pulse can still be used for sync purposes provided you are able to detect such a short pulse duration. Regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, I have downloaded the project and can only see the square signal on pin seven. Nothing on pin 3. Do you have an idea for me ? Thanks and see you

BruceEvans

2 years ago

Hi, Please see my second reply to "djadeski" above. In short, Both pins are used for the square wave output, but at different times (to make full use of the Due's specifications). One pin is disabled when the other is in use. They must be connected together as explained in the installation instructions. Regards, Bruce.

Anonymous user

2 years ago

Hi , After I connect USB to Due .It do ask for the correct port to select as input.But after key in ,it still show " cant Arduino !"Please help.

BruceEvans

2 years ago

Hi, Sorry for the delay answering, but I only just saw your comment. If your problem is still not resolved can you please give me more details, such as which version are you using - whether it's for windows or Linux; and exactly what you typed in - it should be "a" or "b" etc. and please give me any other info you can think of. Also, have you tried it on a different computer? Without more information I have no chance of helping. Regards, Bruce.

Anonymous user

2 years ago

Hi Bruce. My name is William belasco and I like to learn more about your project, if I have a csv file for example, can It reproduce the eletrical signal by csv file? can you help me to understand your project? it is a great project and i like to know if is possible it works with csv file getting by a ociloscope for exemple or maybe matlab. Do you know what I mean?

BruceEvans

2 years ago

Hi William, Yes, you can use a CSV file. However, the format of the data in the CSV file is not compatible with any other program. You will need to create your own CSV file. You should create a CSV file using Excel or Notebook as explained in the help file provided, under the 'Waypoints' heading. Then rename the CSV file as an .awv file. Then use my GUI program to open the file, and then upload it to the Arduino DUE. I suggest you open one of the provided arbitrary .awv files (in the Arbitrary Waves folder) with Notebook for comparison. I hope this this helps. Regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, I bought a toy scope recently as I could not find my old CRT scope any more. When I took out my analog sig gen from the basement, the RF transister on it is not working too well. That transistor was stamped in the 70's, It might be a germanium. I can't find that part number on alldatasheet any more. I have an arduino and this project turns it into a sig gen with a resistor/jumper. That would be great. Howerver when I tried to compile the ino, it hit errors. Then I realized my Mega isn't compatible with Due. Do you see anything that would stop porting your ino from Due into Mega, something like Mega is too slow or doesn't have enough DACs to do the job? Has that been ported already? +++ First 2 errors hit were about resolution. The Due ino asks for 12 bits. The Mega only supports 10. I suppose I can live with a low resolution, my new scope does not have 12 bit resolution anyway. Haven't checked the others. Some of them may be related to timer/clock settings... ++++++ Oops, there are no true analog outputs on Mega (no DACs). Hence it is impossible to port unless we add some hardware outside to do DAC or PWM to analog conversion for the Mega. Placing an order for a Due. It may be long long time before Aliexpress can ship due to cronavirus shut down. Thanks.

BruceEvans

2 years ago

As you've probably realized already, the DUE Arduino uses a completely different and faster CPU than the Mega, and the DUE also has DMA. This sketch is especially written to take advantage of all these DUE features with some code that only the ARM CPU in the DUE will recognize. The reason I did this is to increase the sample rate and hence the maximum usable analogue output frequency. So it can't possibly work with anything other than the DUE. Let me know how you get on when you receive the DUE you ordered.

Anonymous user

2 years ago

Hi Brian, nice project. I would like to ask, is there is a way to change default generated signal parameters (freq, duty circle, shape) or store the last used? It always starts at 1 kHz, sine wave. Is there a way to control signal amplitude? Or I need to make an external voltage divider? Regards, Anton

Anonymous user

2 years ago

Thank you Bruce, It will help me a lot. Anton

BruceEvans

2 years ago

Hi gagarinui, Thanks for your kind comments. You can change the start-up freq by editing the .ino file: Line 83: int Pot0 = 1000; // <<<<<<< DETERMINES START-UP FREQUENCY<<<<<<<< Change the "1000" to whatever freq you wish, BUT YOU MUST ALSO EDIT LINE 165 ACCORDINGLY: Line 165: volatile int FastMode = 0; // -1 = BELOW 1kHz (slow mode), 0 = BELOW 10kHz, 1 = BELOW 20kHz, 2 = BELOW 40khz, 3 = up to 100kHz For example: If you set the freq below 1KHz the "0" must be changed to "-1" The start-up wave-shape can be set here: Line 158: byte WaveShape = 0; // 0 = Sinewave, 1 = Triangle / Sawtooth, 2 = Arbitrary The amplitude cannot be changed so easily, and doing so would reduce the resolution anyway; so better to use a voltage divider as you suggested. Cheers, Bruce.

Anonymous user

2 years ago

Hey! I haven't tested it yet but I want to place a question: Does the Arduino start outputting the waveform immediately after power on (without having a computer connected) and continues forever or does it need a trigger? Thanks, Chris

BruceEvans

2 years ago

Hi Christian_key Both waveform outputs DO start immediately after power on, with or without having a computer connected, and continue forever. Cheers, Bruce.

Anonymous user

2 years ago

Hello, I like this application of the Due. Looks like it will make a good test instrument - very flexible. I can get it to work fine with the serial Monitor, but no joy with the PC GUI - just cannot find the Arduino. I tried both the 32bit and 64bit versions. I can see the TX LED flicker as it probes the board, but no action on the RX. I know they both works as they are active when programming. If I have Serial Monitor running, then the GUI reports serial port busy. I changed the code 'bool UsingGUI = 1;' to try force the GUI - no luck! Seems like the Due is not returning data to the GUI? Any advice? Rgds, Brian

Anonymous user

2 years ago

OK, So I found the problem, it does not like COM8. On another machine where the USB registers as COM3, it finds the Due perfectly. I'll look at the JAVA code and change it to search up to 10 just to leave some headroom. Now to hook it up to some buttons and pots to play with the other stuff.

BruceEvans

2 years ago

...... to be more precise, the Due sends a message during setup (line 196) which the GUI recognizes and then initiates connection.

BruceEvans

2 years ago

Hi Brian, The problem seems to be corrected now. Just download the latest version. Cheers, Bruce.

BruceEvans

2 years ago

Hi Brian, Thanks for your kind comments. Regarding your problem, this is the first time I've encountered it so could you please answer the following so I can try to figure it out? 1. Which Windows version / system are you using? 2. Which Arduino IDE version are you using to upload the sketch? 3. Does the Due reset when you start up the Windows PC GUI? Find out by using the serial monitor to change the frequency or wave-shape etc. Then close the serial monitor, and then start up the PC GUI. If the wave viewed on the oscilloscope changes back to the default 1kHz sine-wave then the Due has reset. (Note that it should reset.) 4. If you have another PC / laptop does it work okay on that? (Easy to try, as the GUI doesn't need installing.) Regards, Bruce.

BruceEvans

2 years ago

Good, the part of the code you want starts from line 202, but you'll see that the com ports are actually searched up to the number of ports available, it's not limited to any particular number. You didn't say whether the Due was resetting, I think this might be important because the Due only tries to connect during setup.

Anonymous user

2 years ago

Hello, i have read your code, i want to know how to show signal in 2 pin DAC0 and DAC1 (the same frequency) in board DUe. Thank you so much!!!

Anonymous user

2 years ago

I just generate 2 signal sine (range: 2Hz - 20KHz) to show in oxilo, I dont need things same as: GUI, transmit data to PC... Can you help me some solutions with DUE? Thank you so much!!!

BruceEvans

2 years ago

Hi tuandxo, Sorry, if you want a different frequency from each of the DAC pins even if they are the same wave shape, much of the program (Arduino sketch) would still need to be rewritten, and the extra workload would slow it down massively again, reducing resolution. (Regardless of the GUI.) Regards, Bruce.

BruceEvans

2 years ago

Hi tuandxo, This sketch uses direct port manipulation to get the fastest performance possible from the DUE. You can't have an output from both DACs without slowing things down and spoiling performance. If you want a different wave shape from each of the pins even at the same frequency, much of the program would need to be rewritten, and the extra workload would slow it down massively. This is what you need to do to change the output from DAC0 to DAC1. But you can have only one or the other, not both. Find: void dac_setup() Re-comment the following lines ONLY From: // dacc_set_channel_selection(DACC, 1); // dacc_enable_channel(DACC, 1); dacc_set_channel_selection(DACC, 0); dacc_enable_channel(DACC, 0); To: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); // dacc_set_channel_selection(DACC, 0); // dacc_enable_channel(DACC, 0); Next find: void dac_setup2() Replace the single line: DACC->DACC_CHER = DACC_CHER_CH0 << 0 ; // enable chan0 With these 2 lines: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); Regards, Bruce.

Anonymous user

2 years ago

Thanks Bruce for the AWG work. I would like to have an additional feature to it if possible. An external trigger to set on/off the ADC output. Any help in this regard will be very helpful in my work. I'm currently developing a python interface to it as well.

BruceEvans

2 years ago

Hi manasmukherjee, Thanks for your comment. If, as I suspect, you want to disable the DAC output waveform with a trigger voltage on one of the Arduino's I/O pins, then the only way I can think of to achieve that, would be in conjunction with the Controller program by, first of all, setting the arbitrary wave to a straight line by simply clicking FILL in the drawing window, and Upload it. Then enable switches by momentarily switching pin 22 to ground. Then you can feed a negative trigger voltage to pin 40 to cycle through the Wave Shapes. When you reach the Arbitrary waveform you will have a straight line, i.e. no waveform. This is probably not what you really want, but maybe the only option without adding code. However, I'm currently working on version 2 (have been for many months) with heaps of new features. One is amplitude modulation controlled by one of the analogue pins. This might be a better option, but probably still months away! (If you can wait, please note that when modulation is set to zero, this would give you a DC output at half supply voltage, not zero volts. Also, in modulation mode the sample rate will be lower.) Regards, Bruce.

Anonymous user

2 years ago

Hi BruceEvans, Just wanted to let you know this seems to work perfectly for me and its a great project. Have you ever tried to trigger the output based on an input pulse? What Id ideally like to be able to do is fire off one burst of the Arbitrary waveform each time I pulse an input on the Arduino.. I looked at the code hoping it might be fairly simple, but quickly realised I'm in over my head with your code! I'm still planning to look into it but it might take more time than I was looking to spend at this stage. If I do manage it Ill drop the code chanegs in a comment in case anyone else would find it useful. Awesome code though, Thanks Again, Sam

Anonymous user

2 years ago

Hello, I am not can download

BruceEvans

2 years ago

Hi Sam, Thanks for your awesome comment. Regarding you question about triggering: You may be interested to know that the AWG can already be triggered by double clicking "FREQUENCY" in the GUI, but only if the frequency is lower than 0.5 Hz . However, in order to achieve it's wide specification range, the AWG produces waves in completely different ways depending on the frequency, duty cycle and "Exact Mode" so a different way of triggering would also be needed at different frequencies etc, requiring more code than you might expect. Even worse, in order to provide "one burst" of the arbitrary wave it would, of course, be necessary to detect the end of the wave cycle, and usually arbitrary waves (in this AWG) are used at 0 % or 100% duty cycle, so if you wanted to use the pulse from the (synchronized) square wave for this purpose it would be too short for the arduino to detect using normal code in the void loop for example. Therefore, code would most likely have to be put in the DACC_handler and TCO_Handler, but these are VERY time critical and ANY extra code there would use too much time, making a lower overall resolution necessary; and thereby spoiling the specifications of the AWG. I hope this makes sense to you. If the one shot effect is not essential (or resolution unimportant) and only a narrow frequency range etc is needed the idea may be practical. If you'd like to give more details of just what you need I'll see if I can help. Regards, Bruce.

BruceEvans

2 years ago

Hi Adrian, Sorry for the delay; I only just saw your comment. To download click "Read More" above. Then on the next page click "2 releases" and then on the next page click "DueArbitraryWaveformGenerator.ino" and "DueAWGController32.rar." These instructions are also shown on each page. I hope this helps. Regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, The 20Hz lower limit and 20Khz upper limit set by the GUI is very restricting for my purpose, I require an Arbitrary waveform from 1Hz to 70Khz timed to around 8Khz, is this possible by programming it directly and using the serial monitor to confirm the completion of successful code? Kind regards

BruceEvans

2 years ago

Hi, How strange that it connects if both USB cables are connected and Upload pressed! Out of curiosity, I'd be tempted to try it on a different PC to see if it's the same. The uploaded arbitrary wave appears with a mirrored effect if not set to 0% duty-cycle. (Also mentioned in the help file. See "Drawing Waves" section.) Cheers, Bruce.

Anonymous user

2 years ago

Hi Bruce, Thanks for that, would there be any chance of adding a Toggle feature to your GUI to allow scrolling through a frequency sweep, one frequency at a time? Cheers Ian

Anonymous user

2 years ago

Hi Bruce, So here is a thing, if I plug in both USB cables, and press the upload button, your program recognizes the Due, and connects. Also what does, "Set duty cycle to zero to avoid mirrored effect" mean?

Anonymous user

2 years ago

Hi Bruce, I have never used a Due before, not sure what is normal, wondered if anyone else has the same problem? What is "Target not set" referring to? I need to study the "Drawing Waves" section, Cheers Ian

Anonymous user

2 years ago

Hi Bruce, I will try to create the wave forms I require using the Arduino sketch, you have included lots of useful information to enable a person to do this, Great work! Cheers

Anonymous user

2 years ago

Hi Bruce, I will use the serial monitor instead of the GUI.

Anonymous user

2 years ago

Hi Bruce, Thank you for the explanation. I have created the waveform I require for my project very easily using your software, it helped by knowing all the parameters in advance!, my project now progress, Many thanks Ian

Anonymous user

2 years ago

Hi Bruce, Sorry for the misunderstanding, yes, I need to read more before jumping in!, however, looks like the clone Arduino Due is not functioning correctly......surprise!, connected once, then never again.....lesson learned here, I will send for a genuine one, bollocks as we say!

BruceEvans

2 years ago

Hi, Do you mean you will use the serial monitor instead of the GUI, or do you plan to re-write some of the sketch? - Bruce.

BruceEvans

2 years ago

Hi, Nobody has reported this problem to me before. If you try controlling the wave frequency, period, etc. it should become clear what "Target not set" means. It means you have not set the target frequency or period, etc. You can also control these wave settings by first pressing MODE and sliding the mouse along the <<<<>>>> button that appears. (Read "Controlling Waves")

BruceEvans

2 years ago

Hi Ian, Congrats on your success. Good luck with your project. Kind regards, Bruce.

BruceEvans

2 years ago

Hi Ian, If I understand you correctly, I don't really think such a feature would be useful to many users. But actually, the frequency already sweeps in small steps (more noticeable at high frequency) determined by the DUE clock frequency; unless "Exact Mode" is on, in which case resolution suffers especially at high frequency. Regards, Bruce.

BruceEvans

2 years ago

Hello, I don't know what you mean by "timed to around 8KHz" and I can't understand why you get a range of only 20Hz to 20kHz. If you read the specifications in the help file (or on this webpage) you'll see that the AWG has a much wider frequency range than you need. However, the resolution will be very low at 70kHz (only 16 way-points with Exact Mode off) limited by the clock frequency of the DUE, even though it's by far the fastest Arduino available. If it had been possible to make a faster AWG with Arduino it would have been a commercial design, and not given away for free! To ensure you are using it correctly read the "Controlling Waves" section of the help file. Please give me more details of this problem if you still can't solve it. Kind Regards, Bruce. On 9/12/2019 2:18 AM, Hackster.io wrote:

BruceEvans

2 years ago

Hi, It's a pity if your Arduino is faulty. I've tried a number of cheap Chinese Arduinos and they were mostly okay, except for the port driver being different as you've already discovered. Good luck, Bruce.

Anonymous user

2 years ago

Hi Bruce, After many problems in regards to not recognizing my Due clone board I bought 2 genuine Due boards, uploaded the blinky sketch as per usual, still not recognizing the boards, I tried different ports, setting the port speed to 9600, adjusting the buffer speed, no difference!, I noticed when I did manage to get a connection both the rx and tx led light up, can you point me in the right direction? Kind regards

BruceEvans

2 years ago

Hi user601458150, I'm not sure I understand your problem well enough to help. Are you using Windows or Linux? If the Due boards were not recognized how did you manage to upload the blinky sketch? Did that sketch work? If it didn't upload successfully, could you try it on another PC? Did you upload my AWG sketch to the Due successfully? If so, are the waves present at the Due output pins? For my AWG program the baud rate is not 9600, but 115200 as explained in the installation section above. Did you try 115200 with Arduino's serial monitor? Or is it just my GUI (the controller program for your PC) that you cannot connect to the Due? If you can explain your problem in more detail maybe I can offer more useful advice. Regards, Bruce.

Anonymous user

2 years ago

Bruce, I am new but having a ton of fun with this stuff and have perhaps a dumb question about the output protection circuitry - I understand all the components but the last two - the 50mA items F1, F2 - they are what? thanks Dave

Anonymous user

2 years ago

Thanks for the quick reply Bruce, I tried it out and it all works extremely well. The java desktop interface is very cool indeed. One follow up question, I understand the analog signal coming from the DAC and the squarewave from a PWM output - but why the jumper between pins 7 & 3, when the output of the squarewave is on pin 7 - i see where you use PIO_configure to setup pin 3 but its not clear to me what is going on there? If this question is better taken to another forum let me know. Best Regards Dave

BruceEvans

2 years ago

Thanks for your comments. Regarding F1 and F2, they are fuses. They can be polyfuses which "reset" themselves. I have slightly changed the description above which should make this clearer.

BruceEvans

2 years ago

Thanks again for your comments. Regarding your question: To maximize the square wave's specifications, allowing very short duration pulses when set to 0% or 100% duty cycle, both pin 3 & 7 are used as the same output at different times. One is disabled when the other is enabled. Using one of the microprocessor's PWM outputs (pin 7) is better when the target frequency is at least 163Hz. At lower frequencies, using one of the microprocessor's TIO timer pin outputs (pin 3) is better. (See TC1_Handler at line 1845) Pin 3 (TIOA) is always used when the square wave is synchronized with the analogue wave (See ToggleSquareWaveSync at line 1289) allowing pulse times of just nanoseconds even at the minimum frequency.

Anonymous user

2 years ago

Hi Bruce, your project is really amazing. I am looking for a solution to build an 8 channels simple function generator, I am not sure how to incorporate your idea into it. Appreciate your suggestions. Thank you very much.

BruceEvans

2 years ago

Hi Kelvin, Sorry for the delay answering, but I only just noticed your reply. I'm still not receiving comment notification emails from this site! Thanks for your kind comments. Unless you need to make your own "arbitrary" waveforms, you might be able to find something simpler or cheaper elsewhere. This project can only provide 2 channels anyway, so you'd have to buy 4 due arduinos! Regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, This is a great project. I think I have fried DAC0 on my DUE, so I have tried changing the code as you have previously said: Find: void dac_setup() Re-comment the following lines ONLY From: // dacc_set_channel_selection(DACC, 1); // dacc_enable_channel(DACC, 1); dacc_set_channel_selection(DACC, 0); dacc_enable_channel(DACC, 0); To: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); // dacc_set_channel_selection(DACC, 0); // dacc_enable_channel(DACC, 0); This does work for high speed , but not for signals of 1KHz or less. I have tried dac_setup2() with // DACC->DACC_CHER = DACC_CHER_CH0 << 0 ; // enable chan0 DACC->DACC_CHER = DACC_CHER_CH1 << 0; // enable chan1 but this has had no effect. What am I missing? Kind regards Dave

Anonymous user

2 years ago

Thanks Bruce, much appreciated. I will have to be more carfull with the DAC outputs in future!! Kind regards Dave

BruceEvans

2 years ago

Hi Dave, You're welcome. The I/O pins are pretty fragile too. That's why I made the protection PCB. Cheers, Bruce.

BruceEvans

2 years ago

Hi Dave, Thanks for your comments. Just replace the single line: DACC->DACC_CHER = DACC_CHER_CH0 << 0 ; // enable chan0 With the 2 lines: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); This is just an alternative method. I don't know the correct syntax for the other method. I will now edit my earlier comment that you found above. Thanks for bringing this omission to my attention. Kind regards, Bruce.

Anonymous user

2 years ago

Excellent project!!! I was doing some internet research on AD/DA conversion and came across this project then immediately purchased a new official Arduino Due just to load this project and check it out. The project directions were easy to follow and all of the code works perfectly first time right out of the box! Awesome work! The Arduino code is well commented and I was able to follow it. I even made some custom modifications to the Arduino code for my own purposes to extend the capabilities. So, now instead of just sine, triangle and arbitrary I have coded more general equations and have custom parameter control of the sine (i.e. amplitude, vertical shift, phase shift and wave shape) and triangle waves (i.e. vertical shift and slope). All of this is controlled via the Serial Monitor. Also I have added 3 new waves namely Stepped Square Wave and two flavours of Square Root function “wave” which also have custom variables which modify the wave shapes. The code and Due board definitely makes some interesting wave shapes. I connected it to my DIY analogue synthesiser as a digital VCO. I can further processing of the wave forms through all modules on my synth such as voltage controlled filters and voltage controlled ASDR envelopes and more. I am getting some really cool, interesting and wacky sounds out of it which is exactly what I wanted. Thanks for a great project. I definitely learned a lot!!! If you are interested in the code tweaks I have forked your project on Github. Feel free to check out the fork and integrate any lines into your code if you think the code changes are worthwhile. I only modified the Arduino code file and did not modify the GUI. One problem is that when I try to load the GUI with the Arduino code that I wrote on my Due, the GUI no longer can find the Arduino and I get the error message “Can’t find Arduino!” in the GUI. Any thoughts and any suggestions? Regards, Mike

BruceEvans

2 years ago

Hi Mike, I've downloaded your modified .ino file and loaded the sketch into an Arduino Due (genuine one) but although the 1kHz output waves are present I cannot control them in any way with the serial monitor (sending x, X, XX or anything else I tried). Perhaps the .ino file is an old one you have since replaced because, quickly looking at the code, I can't see how it could've ever worked: There seems to be a problem with the code related to your "bReadChar" in the serial read section of the sketch. Perhaps I'm missing something, but I don't have time to check further. If you have an updated .ino file I'd love to try it. Generally, your code looks pretty good. (Also please note that pin 7 is not always used for the unsynchronized square wave output as implied by your comment near the start of your .ino sketch. Pin 3 is used instead below 163Hz. I explained the reason in my second reply to "djadeski" above.) Kind regards, Bruce.

BruceEvans

2 years ago

Hi Mike, Sorry for the delay, I only just saw your reply. The mods you've mentioned sound really interesting. I'll check them out as soon as I can and let you know what I think. Regards, Bruce.

Anonymous user

2 years ago

Love the project... (and I do not want to know how many hours went into it.) I must be doing something wrong. When I load the .ino into PlatformIO on VScode I get over 250 errors and it won't compile, after which it shows over 500 errors.. Main errors: identifiers undefined. I tried to clean up the code, defined prototypes, put setup() and loop() last, plus added bracing, tough the errors won't disappear... Any ideas? [edit_1] I thought I use the original code in the Arduino IDE, just to make sure, same result: it won't compile. Here a few errors to illustrate: /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino: In function 'void setup()': WaveGenerator:194:3: error: 'analogReadResolution' was not declared in this scope analogReadResolution(12); ^~~~~~~~~~~~~~~~~~~~ /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino:194:3: note: suggested alternative: 'analogRead' analogReadResolution(12); ^~~~~~~~~~~~~~~~~~~~ analogRead WaveGenerator:195:3: error: 'analogWriteResolution' was not declared in this scope analogWriteResolution(12); ^~~~~~~~~~~~~~~~~~~~~ /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino:195:3: note: suggested alternative: 'analogWrite' analogWriteResolution(12); ^~~~~~~~~~~~~~~~~~~~~ analogWrite /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino: In function 'void loop()': WaveGenerator:637:9: error: 'REG_PIOC_PER' was not declared in this scope REG_PIOC_PER |= PIO_PER_P28; // PIO takes control of pin 3 from peripheral - similar to pinMode(3, OUTPUT) ^~~~~~~~~~~~ WaveGenerator:637:25: error: 'PIO_PER_P28' was not declared in this scope REG_PIOC_PER |= PIO_PER_P28; // PIO takes control of pin 3 from peripheral - similar to pinMode(3, OUTPUT) ^~~~~~~~~~~ WaveGenerator:638:9: error: 'REG_PIOC_ODR' was not declared in this scope REG_PIOC_ODR |= PIO_ODR_P28; // PIO disables pin 3 (C28) - similar to pinMode(3, INPUT) ^~~~~~~~~~~~ WaveGenerator:638:25: error: 'PIO_ODR_P28' was not declared in this scope REG_PIOC_ODR |= PIO_ODR_P28; // PIO disables pin 3 (C28) - similar to pinMode(3, INPUT) ^~~~~~~~~~~ WaveGenerator:639:29: error: 'PWM_INTERFACE' was not declared in this scope PWMC_DisableChannel(PWM_INTERFACE, g_APinDescription[7].ulPWMChannel); ^~~~~~~~~~~~~

Anonymous user

2 years ago

Thank you kindly for your response. Yes, why I tried the Arduino IDE to confirm. And so I learned that the diecimila atmega328 is not the required 32bit SAM based DUE (duh), and indeed, I selected the wrong board. Ouch. It compiles error free. And yes, 'hours' was a significant understatement! Nevertheless, I appreciate your work and more so sharing it. All the very best! Cheers, Max [edit] And I forgot; VScode is a free (Microsoft) Visual Studio Code Editor with plug-ins for almost all languages; PlatformIO is the development environment to setup projects... I never looked back. It would have been ideal for real-time debugging this project. Give it a try, you will no regret it!

BruceEvans

2 years ago

Hi MaxG, I've had no experience with PlatformIO or VScode, but the only time I remember seeing errors (using the Arduino IDE) like those you've posted was when the IDE was accidentally set to the wrong board, such as MEGA instead of DUE. I assume you know that this script is written exclusively for the DUE. BTW: The time that went into writing this would be counted in months rather than hours. Kind regards, Bruce.

Anonymous user

2 years ago

This is a great project Bruce - and really well documented. I haven't tried it yet (waiting on Due to arrive) but I have a couple of questions.. 1. How slow do you think it would be to generate 2 different (but synchronised) arbitrary waveforms? I want to generate waveforms that emulate the cam and crank pattern of an engine. The worst case scenario would be a crank signal which is basically a sine wave for 71 periods, then one "missing" period. This would represent whats called a 72 minus 1 tooth crank trigger wheel. The cam signal would be a single sine pulse about 1 crank tooth long, then zero for the rest of the period. The cam pulse appears on every 2nd crank sequence, which could be done by concatenating 2 copies of the crank pattern for one cam pattern. Obviously these 2 waveforms need to be in sync the whole time, and able to be frequency modulated together. It would need to run at 20000rpm, so by my calculation the worst case the crank "teeth" would be at 24kHz. And the whole waveforms would repeat at a rate of 160Hz. 2. Do you think this code would work on an ESP32? It has 2 8bit DMA capable DAC outputs. (I can live with the lower resolution). The ESP32 seems to be taking over from the Due and is a bit cheaper. Cheers stuko

BruceEvans

2 years ago

Hi user1605739, Thanks for your comments. 1. Unfortunately this project can only produce one arbitrary wave at a time using only one of the DAC outputs. If it had been designed to use both outputs the resolution would have been seriously compromised. However, if it's acceptable for your cam pulse (with a single 'tooth') to be a square wave at the appropriate duty cycle you could perhaps use the synchronized square wave output for that purpose, and 'draw' the crank (arbitrary) wave to synchronize with it. The most accurate way to 'draw' the wave may be to create a CSV file using Excel or Notebook as explained in the help file provided, under the 'Waypoints' heading. Then just open the CSV file after renaming it as an .awv file. You can open one of the provided arbitrary .awv files with Notebook for comparison. Please let me know if this helps. 2. The .ino sketch has been written especially for the DUE, including some 'direct port manipulation' code that only its ARM processor can understand, in order to enhance resolution which is then maximized by also making use of the DUE's DMA ability. So it can ONLY be used with the Arduino DUE. Kind regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, am having trouble getting a proper outline of this project, maybe i missed something, but specs only show waveform info, where is things like output impedance, & the required device/s to provide 50 ohms out? Is it only single channel ? can it be made 2 channel? is it possible to implement a symmetrical output (to do away with a 600 ohm balancing transformer currently employed on a failing generator) , ie a differential output at 50 ohms..? Is there a sync out? Can it be set to output a burst (of say 10 pulses etc)? Is there a cct diagram available for all connections? Thanks! Qtron

BruceEvans

2 years ago

Hi qtron, This is for the Arduino Due which can only provide a few milliamps of output current, so the load must be high impedance. There are no devices to provide 50 ohms output. If you are referring to the optional 47 to 100 ohms resistor mentioned, this is not related to output impedance. There are 2 DAC outputs but only one can be used with this project, otherwise sample rate and other specifications would've been massively sacrificed. You would need an inverting amplifier and buffer after the output to provide the balanced output you mention. The square wave can be synchronized with the analogue (DAC) output, so that can be used as sync, although the pulse width is very short if duty cycle is set to 0% or 100%, as shown in the specifications. Currently, at least, it cannot be set to output a number of pulses, then stop. The waveform produced is continuous. If you are not already familiar with the Arduino Due I suggest you check it out on the Arduino website (and anywhere else you can find) for connections etc before you consider using it, as the connections are easily damaged, hence the optional protection circuit offered. However, connections are marked on the Arduino. Regards, Bruce.

Anonymous user

2 years ago

Dear Bruce Awesome project and code. I get the square wave from Pin3 but I don't get any analogue wave out of DAC0. Have you heard this problem before? Or am I doing something wrong. I tried both the GUI and serial monitor. Any advice? Thanks

BruceEvans

2 years ago

Hi Amir, No, I've never heard of it before. Maybe DAC0 is faulty. I suggest you try DAC1 instead. You can do this by changing the code as mentioned in my reply to tuandxo 4 comments above. Please let me know how you get on. Regards, Bruce.

Anonymous user

3 years ago

Thanks Bruce for the AWG work. I would like to have an additional feature to it if possible. An external trigger to set on/off the ADC output. Any help in this regard will be very helpful in my work. I'm currently developing a python interface to it as well.

BruceEvans

2 years ago

Hi manasmukherjee, Thanks for your comment. If, as I suspect, you want to disable the DAC output waveform with a trigger voltage on one of the Arduino's I/O pins, then the only way I can think of to achieve that, would be in conjunction with the Controller program by, first of all, setting the arbitrary wave to a straight line by simply clicking FILL in the drawing window, and Upload it. Then enable switches by momentarily switching pin 22 to ground. Then you can feed a negative trigger voltage to pin 40 to cycle through the Wave Shapes. When you reach the Arbitrary waveform you will have a straight line, i.e. no waveform. This is probably not what you really want, but maybe the only option without adding code. However, I'm currently working on version 2 (have been for many months) with heaps of new features. One is amplitude modulation controlled by one of the analogue pins. This might be a better option, but probably still months away! (If you can wait, please note that when modulation is set to zero, this would give you a DC output at half supply voltage, not zero volts. Also, in modulation mode the sample rate will be lower.) Regards, Bruce.

Anonymous user

3 years ago

Hi Bruce, am having trouble getting a proper outline of this project, maybe i missed something, but specs only show waveform info, where is things like output impedance, & the required device/s to provide 50 ohms out? Is it only single channel ? can it be made 2 channel? is it possible to implement a symmetrical output (to do away with a 600 ohm balancing transformer currently employed on a failing generator) , ie a differential output at 50 ohms..? Is there a sync out? Can it be set to output a burst (of say 10 pulses etc)? Is there a cct diagram available for all connections? Thanks! Qtron

BruceEvans

2 years ago

Hi qtron, This is for the Arduino Due which can only provide a few milliamps of output current, so the load must be high impedance. There are no devices to provide 50 ohms output. If you are referring to the optional 47 to 100 ohms resistor mentioned, this is not related to output impedance. There are 2 DAC outputs but only one can be used with this project, otherwise sample rate and other specifications would've been massively sacrificed. You would need an inverting amplifier and buffer after the output to provide the balanced output you mention. The square wave can be synchronized with the analogue (DAC) output, so that can be used as sync, although the pulse width is very short if duty cycle is set to 0% or 100%, as shown in the specifications. Currently, at least, it cannot be set to output a number of pulses, then stop. The waveform produced is continuous. If you are not already familiar with the Arduino Due I suggest you check it out on the Arduino website (and anywhere else you can find) for connections etc before you consider using it, as the connections are easily damaged, hence the optional protection circuit offered. However, connections are marked on the Arduino. Regards, Bruce.

mszoke01

4 years ago

Excellent project!!! I was doing some internet research on AD/DA conversion and came across this project then immediately purchased a new official Arduino Due just to load this project and check it out. The project directions were easy to follow and all of the code works perfectly first time right out of the box! Awesome work! The Arduino code is well commented and I was able to follow it. I even made some custom modifications to the Arduino code for my own purposes to extend the capabilities. So, now instead of just sine, triangle and arbitrary I have coded more general equations and have custom parameter control of the sine (i.e. amplitude, vertical shift, phase shift and wave shape) and triangle waves (i.e. vertical shift and slope). All of this is controlled via the Serial Monitor. Also I have added 3 new waves namely Stepped Square Wave and two flavours of Square Root function “wave” which also have custom variables which modify the wave shapes. The code and Due board definitely makes some interesting wave shapes. I connected it to my DIY analogue synthesiser as a digital VCO. I can further processing of the wave forms through all modules on my synth such as voltage controlled filters and voltage controlled ASDR envelopes and more. I am getting some really cool, interesting and wacky sounds out of it which is exactly what I wanted. Thanks for a great project. I definitely learned a lot!!! If you are interested in the code tweaks I have forked your project on Github. Feel free to check out the fork and integrate any lines into your code if you think the code changes are worthwhile. I only modified the Arduino code file and did not modify the GUI. One problem is that when I try to load the GUI with the Arduino code that I wrote on my Due, the GUI no longer can find the Arduino and I get the error message “Can’t find Arduino!” in the GUI. Any thoughts and any suggestions? Regards, Mike

BruceEvans

2 years ago

Hi Mike, Sorry for the delay, I only just saw your reply. The mods you've mentioned sound really interesting. I'll check them out as soon as I can and let you know what I think. Regards, Bruce.

BruceEvans

2 years ago

Hi Mike, I've downloaded your modified .ino file and loaded the sketch into an Arduino Due (genuine one) but although the 1kHz output waves are present I cannot control them in any way with the serial monitor (sending x, X, XX or anything else I tried). Perhaps the .ino file is an old one you have since replaced because, quickly looking at the code, I can't see how it could've ever worked: There seems to be a problem with the code related to your "bReadChar" in the serial read section of the sketch. Perhaps I'm missing something, but I don't have time to check further. If you have an updated .ino file I'd love to try it. Generally, your code looks pretty good. (Also please note that pin 7 is not always used for the unsynchronized square wave output as implied by your comment near the start of your .ino sketch. Pin 3 is used instead below 163Hz. I explained the reason in my second reply to "djadeski" above.) Kind regards, Bruce.

Anonymous user

4 years ago

Bruce A newbie will appreciate your help! Your project looks like the perfect tool to help solve a dying tree problem!!!!!! Running W10Pro 64/Ryzen5/8Gb, when I try to run 64bit AWG, the GUI panel appears and then closed, no fill. Same on laptop. Both have Java 8, latest. Downloaded 32 bit version. Runs on desktop but when I load sketch into Arduino and try to sent to Due, I get error in line 8 "import does not name a type" I read through the comments but no one else mentioned this problem ( probably smarter than me:))

Anonymous user

2 years ago

Thank you, your help appreciated. I will now download the correct ino file and then go from there. I told you I was a newbie so this is a sort of " you have to plug it in first" moment. I am confident that I will go on to make far more complex mistakes! There is a fungus that attacks the roots of some trees and prevents them from taking up water and so they die. There has been a lot of research on the systems within plants. I have learned that there is a chemical, electrical and hydraulic system within plants. There are a number of low frequency signals that appear to help or cure the problem. I am looking at ways to treat areas rather than individual trees. I already know that the single tree treatment works but when you are faced with a few hundred ( On the Isle of Arran, off Scottish West coast, they are having to remove 500,000 larch trees because of a pathogen) I need some sort of broadcast. I'll follow you instructions and post results in the next day or two.

Anonymous user

2 years ago

Bruce Real Due arrived today, set it up ,uploaded sketch, loaded DueAWG and all worked first time. I should know better that to buy the Chinese fakes. It appears that they think that close enough is good enough. Added advantage to the real thing is that it came with a moulded mounting tray. Hold the due and keepr the board from scratching my desk or shorting out. The Chinese fake was $25 and the real thing was $45. It was not worth the saving to spend several hours faultfinding! Thanks again, next is use the Arduino to run sub woofer amps to gets some watts out there. Donald

Anonymous user

2 years ago

Thanks for direction, all up and running. I am using up to 4 frequencies between 10 Hz and 1KHz. I used Excel and calculated the values for the sine based on one full wave of the lowest frequency ( then have the Arduino repeat the composite waveform at that frequency) and added the higher frequency components. Output that to a CSV per help file, realised that all of the number had to be positive up to 4096, redid the number and sent the composite curve to the Arduino. Scope on output shows exactly what is expected. We are looking at RF and vibration at the moment. The guys I'm working with are fixed on the idea of RF but I feel the power requirement is too high and, more importantly, the FCC and military are going to take a dim view of us pumping out RF under 1 KHz. My view is mechanical vibration may be the key are seismological equipment is available off the shelf. It also fits well with some of the papers I've read on plants internal signalling systems. I did encounter 1 problem, which has been referred to earlier. I have to cycle the reset button on the Arduino when starting you software to get the board recognised. I am using an OSOYOO clone ( which even has "made in Italy" on it!) I have ordered a genuine Due which will be here in a couple of days. In the meantime I'm going to try an external power source for the board to see if it could be a USB power issue. Thanks again for your project and for your help and guidance Donald

BruceEvans

2 years ago

Hi dhmcn, Sorry for the delay answering, I only just saw your comment today. Please make sure you are opening the DueArbitraryWaveformGenerator.ino in the Arduino IDE and not the AWGControllerWin.pde in the source folder. (You have to download the .ino file separately. Note: I've updated my Github page to make this clearer.) If that's not the problem, then: If I understand you correctly, the 32 bit GUI is running okay (on your PC), but you're getting errors in the Arduino IDE (on your PC) when you try to send the .ino sketch from the Arduino IDE to the DUE board. Is that correct? If so, can you send other (sample) sketches to it okay? Is the problem the same on the laptop? Regards, Bruce. PS: I'm curious about your "dying tree problem."

BruceEvans

2 years ago

You're welcome. Regarding the tree root problem, what (low) frequency signal do you need and what wave-shape? And how do you intend to apply or broadcast it; as sound, vibrations, R.F. or what? Quite interesting. Regards, Bruce.

BruceEvans

2 years ago

Hi Donald, Thanks for your reply, and good to hear you managed to create the waveform you required. Please let me know whether the genuine Due solves the reset at start-up issue. And if you have the time later, I'd love to know how you get on with curing the tree root problem. Good luck, Bruce.

BruceEvans

2 years ago

Hi Donald, Yes, sometimes it's not worth it, but I have tried this AWG on a couple of cheap Chinese Dues and they were okay, so maybe you were just unlucky anyway. (Or perhaps I was just lucky!) Cheers, Bruce.

Anonymous user

4 years ago

Love the project... (and I do not want to know how many hours went into it.) I must be doing something wrong. When I load the .ino into PlatformIO on VScode I get over 250 errors and it won't compile, after which it shows over 500 errors.. Main errors: identifiers undefined. I tried to clean up the code, defined prototypes, put setup() and loop() last, plus added bracing, tough the errors won't disappear... Any ideas? [edit_1] I thought I use the original code in the Arduino IDE, just to make sure, same result: it won't compile. Here a few errors to illustrate: /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino: In function 'void setup()': WaveGenerator:194:3: error: 'analogReadResolution' was not declared in this scope analogReadResolution(12); ^~~~~~~~~~~~~~~~~~~~ /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino:194:3: note: suggested alternative: 'analogRead' analogReadResolution(12); ^~~~~~~~~~~~~~~~~~~~ analogRead WaveGenerator:195:3: error: 'analogWriteResolution' was not declared in this scope analogWriteResolution(12); ^~~~~~~~~~~~~~~~~~~~~ /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino:195:3: note: suggested alternative: 'analogWrite' analogWriteResolution(12); ^~~~~~~~~~~~~~~~~~~~~ analogWrite /home/maxg/Arduino/WaveGenerator/WaveGenerator.ino: In function 'void loop()': WaveGenerator:637:9: error: 'REG_PIOC_PER' was not declared in this scope REG_PIOC_PER |= PIO_PER_P28; // PIO takes control of pin 3 from peripheral - similar to pinMode(3, OUTPUT) ^~~~~~~~~~~~ WaveGenerator:637:25: error: 'PIO_PER_P28' was not declared in this scope REG_PIOC_PER |= PIO_PER_P28; // PIO takes control of pin 3 from peripheral - similar to pinMode(3, OUTPUT) ^~~~~~~~~~~ WaveGenerator:638:9: error: 'REG_PIOC_ODR' was not declared in this scope REG_PIOC_ODR |= PIO_ODR_P28; // PIO disables pin 3 (C28) - similar to pinMode(3, INPUT) ^~~~~~~~~~~~ WaveGenerator:638:25: error: 'PIO_ODR_P28' was not declared in this scope REG_PIOC_ODR |= PIO_ODR_P28; // PIO disables pin 3 (C28) - similar to pinMode(3, INPUT) ^~~~~~~~~~~ WaveGenerator:639:29: error: 'PWM_INTERFACE' was not declared in this scope PWMC_DisableChannel(PWM_INTERFACE, g_APinDescription[7].ulPWMChannel); ^~~~~~~~~~~~~

Anonymous user

2 years ago

Thank you kindly for your response. Yes, why I tried the Arduino IDE to confirm. And so I learned that the diecimila atmega328 is not the required 32bit SAM based DUE (duh), and indeed, I selected the wrong board. Ouch. It compiles error free. And yes, 'hours' was a significant understatement! Nevertheless, I appreciate your work and more so sharing it. All the very best! Cheers, Max [edit] And I forgot; VScode is a free (Microsoft) Visual Studio Code Editor with plug-ins for almost all languages; PlatformIO is the development environment to setup projects... I never looked back. It would have been ideal for real-time debugging this project. Give it a try, you will no regret it!

BruceEvans

2 years ago

Hi MaxG, I've had no experience with PlatformIO or VScode, but the only time I remember seeing errors (using the Arduino IDE) like those you've posted was when the IDE was accidentally set to the wrong board, such as MEGA instead of DUE. I assume you know that this script is written exclusively for the DUE. BTW: The time that went into writing this would be counted in months rather than hours. Kind regards, Bruce.

Anonymous user

4 years ago

Hey! I haven't tested it yet but I want to place a question: Does the Arduino start outputting the waveform immediately after power on (without having a computer connected) and continues forever or does it need a trigger? Thanks, Chris

BruceEvans

2 years ago

Hi Christian_key Both waveform outputs DO start immediately after power on, with or without having a computer connected, and continue forever. Cheers, Bruce.

Anonymous user

4 years ago

Hi Brian, nice project. I would like to ask, is there is a way to change default generated signal parameters (freq, duty circle, shape) or store the last used? It always starts at 1 kHz, sine wave. Is there a way to control signal amplitude? Or I need to make an external voltage divider? Regards, Anton

Anonymous user

2 years ago

Thank you Bruce, It will help me a lot. Anton

BruceEvans

2 years ago

Hi gagarinui, Thanks for your kind comments. You can change the start-up freq by editing the .ino file: Line 83: int Pot0 = 1000; // <<<<<<< DETERMINES START-UP FREQUENCY<<<<<<<< Change the "1000" to whatever freq you wish, BUT YOU MUST ALSO EDIT LINE 165 ACCORDINGLY: Line 165: volatile int FastMode = 0; // -1 = BELOW 1kHz (slow mode), 0 = BELOW 10kHz, 1 = BELOW 20kHz, 2 = BELOW 40khz, 3 = up to 100kHz For example: If you set the freq below 1KHz the "0" must be changed to "-1" The start-up wave-shape can be set here: Line 158: byte WaveShape = 0; // 0 = Sinewave, 1 = Triangle / Sawtooth, 2 = Arbitrary The amplitude cannot be changed so easily, and doing so would reduce the resolution anyway; so better to use a voltage divider as you suggested. Cheers, Bruce.

Anonymous user

4 years ago

Hi Bruce My Due (banggood clone) finally arrived and I had some trouble getting the GUI program to connect. My Due (programming port) shows as COM15 on my win10 x64 machine. The GUI program (32bit because 64bit just gives a blank window) gave me the choice of ports, but would never find the Due on any port I chose. I did manage to get it to find the Due by repeatedly pressing the reset button on the Due (at about 2Hz) and then selecting COM15 in the GUI program startup. From then on it appears to all be working. Hope this helps.

Anonymous user

2 years ago

Subsequent connections seem to work ok now without having to do the reset button dance. So that was pretty weird. Anyway I have another question... I need the arb wave and the square wave in sync, but how can I stop it doing the mirrored version of the arbitrary wave when the sync output is high? I can't just set it to 0% duty because I need a sync signal on that square wave output and setting duty to zero completely removes it.

BruceEvans

2 years ago

Hi user1605739, There is no other way to avoid the mirrored effect, but here are two possible solutions to your problem: If the frequency is not important: The arbitrary wave and the UNsynchronized square wave automatically synchronize anyway at certain precise frequencies, for example 1kHz (the start-up frequency). So just select this frequency for both waves with the arbitrary wave set to 0% duty cycle, and then the square wave can be set to a different duty cycle. Please note that when the duty cycle is set to 0% (or 100%) the square wave does NOT disappear, but the resultant 'pulse' may be as short as 48 nano seconds. (see Specifications in the help file, or above on this page.) This pulse can still be used for sync purposes provided you are able to detect such a short pulse duration. Regards, Bruce.

vk3dsb

4 years ago

Hi Bruce, This is a great project. I think I have fried DAC0 on my DUE, so I have tried changing the code as you have previously said: Find: void dac_setup() Re-comment the following lines ONLY From: // dacc_set_channel_selection(DACC, 1); // dacc_enable_channel(DACC, 1); dacc_set_channel_selection(DACC, 0); dacc_enable_channel(DACC, 0); To: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); // dacc_set_channel_selection(DACC, 0); // dacc_enable_channel(DACC, 0); This does work for high speed , but not for signals of 1KHz or less. I have tried dac_setup2() with // DACC->DACC_CHER = DACC_CHER_CH0 << 0 ; // enable chan0 DACC->DACC_CHER = DACC_CHER_CH1 << 0; // enable chan1 but this has had no effect. What am I missing? Kind regards Dave

vk3dsb

2 years ago

Thanks Bruce, much appreciated. I will have to be more carfull with the DAC outputs in future!! Kind regards Dave

BruceEvans

2 years ago

Hi Dave, Thanks for your comments. Just replace the single line: DACC->DACC_CHER = DACC_CHER_CH0 << 0 ; // enable chan0 With the 2 lines: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); This is just an alternative method. I don't know the correct syntax for the other method. I will now edit my earlier comment that you found above. Thanks for bringing this omission to my attention. Kind regards, Bruce.

BruceEvans

2 years ago

Hi Dave, You're welcome. The I/O pins are pretty fragile too. That's why I made the protection PCB. Cheers, Bruce.

Anonymous user

4 years ago

Hi Bruce. My name is William belasco and I like to learn more about your project, if I have a csv file for example, can It reproduce the eletrical signal by csv file? can you help me to understand your project? it is a great project and i like to know if is possible it works with csv file getting by a ociloscope for exemple or maybe matlab. Do you know what I mean?

BruceEvans

2 years ago

Hi William, Yes, you can use a CSV file. However, the format of the data in the CSV file is not compatible with any other program. You will need to create your own CSV file. You should create a CSV file using Excel or Notebook as explained in the help file provided, under the 'Waypoints' heading. Then rename the CSV file as an .awv file. Then use my GUI program to open the file, and then upload it to the Arduino DUE. I suggest you open one of the provided arbitrary .awv files (in the Arbitrary Waves folder) with Notebook for comparison. I hope this this helps. Regards, Bruce.

Anonymous user

4 years ago

This is a great project Bruce - and really well documented. I haven't tried it yet (waiting on Due to arrive) but I have a couple of questions.. 1. How slow do you think it would be to generate 2 different (but synchronised) arbitrary waveforms? I want to generate waveforms that emulate the cam and crank pattern of an engine. The worst case scenario would be a crank signal which is basically a sine wave for 71 periods, then one "missing" period. This would represent whats called a 72 minus 1 tooth crank trigger wheel. The cam signal would be a single sine pulse about 1 crank tooth long, then zero for the rest of the period. The cam pulse appears on every 2nd crank sequence, which could be done by concatenating 2 copies of the crank pattern for one cam pattern. Obviously these 2 waveforms need to be in sync the whole time, and able to be frequency modulated together. It would need to run at 20000rpm, so by my calculation the worst case the crank "teeth" would be at 24kHz. And the whole waveforms would repeat at a rate of 160Hz. 2. Do you think this code would work on an ESP32? It has 2 8bit DMA capable DAC outputs. (I can live with the lower resolution). The ESP32 seems to be taking over from the Due and is a bit cheaper. Cheers stuko

BruceEvans

2 years ago

Hi user1605739, Thanks for your comments. 1. Unfortunately this project can only produce one arbitrary wave at a time using only one of the DAC outputs. If it had been designed to use both outputs the resolution would have been seriously compromised. However, if it's acceptable for your cam pulse (with a single 'tooth') to be a square wave at the appropriate duty cycle you could perhaps use the synchronized square wave output for that purpose, and 'draw' the crank (arbitrary) wave to synchronize with it. The most accurate way to 'draw' the wave may be to create a CSV file using Excel or Notebook as explained in the help file provided, under the 'Waypoints' heading. Then just open the CSV file after renaming it as an .awv file. You can open one of the provided arbitrary .awv files with Notebook for comparison. Please let me know if this helps. 2. The .ino sketch has been written especially for the DUE, including some 'direct port manipulation' code that only its ARM processor can understand, in order to enhance resolution which is then maximized by also making use of the DUE's DMA ability. So it can ONLY be used with the Arduino DUE. Kind regards, Bruce.

Anonymous user

5 years ago

Hi , After I connect USB to Due .It do ask for the correct port to select as input.But after key in ,it still show " cant Arduino !"Please help.

BruceEvans

2 years ago

Hi, Sorry for the delay answering, but I only just saw your comment. If your problem is still not resolved can you please give me more details, such as which version are you using - whether it's for windows or Linux; and exactly what you typed in - it should be "a" or "b" etc. and please give me any other info you can think of. Also, have you tried it on a different computer? Without more information I have no chance of helping. Regards, Bruce.

Anonymous user

5 years ago

Hi Bruce, After many problems in regards to not recognizing my Due clone board I bought 2 genuine Due boards, uploaded the blinky sketch as per usual, still not recognizing the boards, I tried different ports, setting the port speed to 9600, adjusting the buffer speed, no difference!, I noticed when I did manage to get a connection both the rx and tx led light up, can you point me in the right direction? Kind regards

BruceEvans

2 years ago

Hi user601458150, I'm not sure I understand your problem well enough to help. Are you using Windows or Linux? If the Due boards were not recognized how did you manage to upload the blinky sketch? Did that sketch work? If it didn't upload successfully, could you try it on another PC? Did you upload my AWG sketch to the Due successfully? If so, are the waves present at the Due output pins? For my AWG program the baud rate is not 9600, but 115200 as explained in the installation section above. Did you try 115200 with Arduino's serial monitor? Or is it just my GUI (the controller program for your PC) that you cannot connect to the Due? If you can explain your problem in more detail maybe I can offer more useful advice. Regards, Bruce.

Anonymous user

5 years ago

Hi Bruce, I bought a toy scope recently as I could not find my old CRT scope any more. When I took out my analog sig gen from the basement, the RF transister on it is not working too well. That transistor was stamped in the 70's, It might be a germanium. I can't find that part number on alldatasheet any more. I have an arduino and this project turns it into a sig gen with a resistor/jumper. That would be great. Howerver when I tried to compile the ino, it hit errors. Then I realized my Mega isn't compatible with Due. Do you see anything that would stop porting your ino from Due into Mega, something like Mega is too slow or doesn't have enough DACs to do the job? Has that been ported already? +++ First 2 errors hit were about resolution. The Due ino asks for 12 bits. The Mega only supports 10. I suppose I can live with a low resolution, my new scope does not have 12 bit resolution anyway. Haven't checked the others. Some of them may be related to timer/clock settings... ++++++ Oops, there are no true analog outputs on Mega (no DACs). Hence it is impossible to port unless we add some hardware outside to do DAC or PWM to analog conversion for the Mega. Placing an order for a Due. It may be long long time before Aliexpress can ship due to cronavirus shut down. Thanks.

BruceEvans

2 years ago

As you've probably realized already, the DUE Arduino uses a completely different and faster CPU than the Mega, and the DUE also has DMA. This sketch is especially written to take advantage of all these DUE features with some code that only the ARM CPU in the DUE will recognize. The reason I did this is to increase the sample rate and hence the maximum usable analogue output frequency. So it can't possibly work with anything other than the DUE. Let me know how you get on when you receive the DUE you ordered.

Anonymous user

5 years ago

Dear Bruce Awesome project and code. I get the square wave from Pin3 but I don't get any analogue wave out of DAC0. Have you heard this problem before? Or am I doing something wrong. I tried both the GUI and serial monitor. Any advice? Thanks

BruceEvans

2 years ago

Hi Amir, No, I've never heard of it before. Maybe DAC0 is faulty. I suggest you try DAC1 instead. You can do this by changing the code as mentioned in my reply to tuandxo 4 comments above. Please let me know how you get on. Regards, Bruce.

tuandxo92

5 years ago

Hello, i have read your code, i want to know how to show signal in 2 pin DAC0 and DAC1 (the same frequency) in board DUe. Thank you so much!!!

tuandxo92

2 years ago

I just generate 2 signal sine (range: 2Hz - 20KHz) to show in oxilo, I dont need things same as: GUI, transmit data to PC... Can you help me some solutions with DUE? Thank you so much!!!

BruceEvans

2 years ago

Hi tuandxo, Sorry, if you want a different frequency from each of the DAC pins even if they are the same wave shape, much of the program (Arduino sketch) would still need to be rewritten, and the extra workload would slow it down massively again, reducing resolution. (Regardless of the GUI.) Regards, Bruce.

BruceEvans

2 years ago

Hi tuandxo, This sketch uses direct port manipulation to get the fastest performance possible from the DUE. You can't have an output from both DACs without slowing things down and spoiling performance. If you want a different wave shape from each of the pins even at the same frequency, much of the program would need to be rewritten, and the extra workload would slow it down massively. This is what you need to do to change the output from DAC0 to DAC1. But you can have only one or the other, not both. Find: void dac_setup() Re-comment the following lines ONLY From: // dacc_set_channel_selection(DACC, 1); // dacc_enable_channel(DACC, 1); dacc_set_channel_selection(DACC, 0); dacc_enable_channel(DACC, 0); To: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); // dacc_set_channel_selection(DACC, 0); // dacc_enable_channel(DACC, 0); Next find: void dac_setup2() Replace the single line: DACC->DACC_CHER = DACC_CHER_CH0 << 0 ; // enable chan0 With these 2 lines: dacc_set_channel_selection(DACC, 1); dacc_enable_channel(DACC, 1); Regards, Bruce.

Anonymous user

5 years ago

Hi Bruce, The 20Hz lower limit and 20Khz upper limit set by the GUI is very restricting for my purpose, I require an Arbitrary waveform from 1Hz to 70Khz timed to around 8Khz, is this possible by programming it directly and using the serial monitor to confirm the completion of successful code? Kind regards

BruceEvans

2 years ago

Hi, It's a pity if your Arduino is faulty. I've tried a number of cheap Chinese Arduinos and they were mostly okay, except for the port driver being different as you've already discovered. Good luck, Bruce.

BruceEvans

2 years ago

Hi, Do you mean you will use the serial monitor instead of the GUI, or do you plan to re-write some of the sketch? - Bruce.

BruceEvans

2 years ago

Hi Ian, Congrats on your success. Good luck with your project. Kind regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, Sorry for the misunderstanding, yes, I need to read more before jumping in!, however, looks like the clone Arduino Due is not functioning correctly......surprise!, connected once, then never again.....lesson learned here, I will send for a genuine one, bollocks as we say!

BruceEvans

2 years ago

Hello, I don't know what you mean by "timed to around 8KHz" and I can't understand why you get a range of only 20Hz to 20kHz. If you read the specifications in the help file (or on this webpage) you'll see that the AWG has a much wider frequency range than you need. However, the resolution will be very low at 70kHz (only 16 way-points with Exact Mode off) limited by the clock frequency of the DUE, even though it's by far the fastest Arduino available. If it had been possible to make a faster AWG with Arduino it would have been a commercial design, and not given away for free! To ensure you are using it correctly read the "Controlling Waves" section of the help file. Please give me more details of this problem if you still can't solve it. Kind Regards, Bruce. On 9/12/2019 2:18 AM, Hackster.io wrote:

BruceEvans

2 years ago

Hi, Nobody has reported this problem to me before. If you try controlling the wave frequency, period, etc. it should become clear what "Target not set" means. It means you have not set the target frequency or period, etc. You can also control these wave settings by first pressing MODE and sliding the mouse along the <<<<>>>> button that appears. (Read "Controlling Waves")

BruceEvans

2 years ago

Hi, How strange that it connects if both USB cables are connected and Upload pressed! Out of curiosity, I'd be tempted to try it on a different PC to see if it's the same. The uploaded arbitrary wave appears with a mirrored effect if not set to 0% duty-cycle. (Also mentioned in the help file. See "Drawing Waves" section.) Cheers, Bruce.

BruceEvans

2 years ago

Hi Ian, If I understand you correctly, I don't really think such a feature would be useful to many users. But actually, the frequency already sweeps in small steps (more noticeable at high frequency) determined by the DUE clock frequency; unless "Exact Mode" is on, in which case resolution suffers especially at high frequency. Regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, I will use the serial monitor instead of the GUI.

Anonymous user

2 years ago

Hi Bruce, Thank you for the explanation. I have created the waveform I require for my project very easily using your software, it helped by knowing all the parameters in advance!, my project now progress, Many thanks Ian

Anonymous user

2 years ago

Hi Bruce, I have never used a Due before, not sure what is normal, wondered if anyone else has the same problem? What is "Target not set" referring to? I need to study the "Drawing Waves" section, Cheers Ian

Anonymous user

2 years ago

Hi Bruce, So here is a thing, if I plug in both USB cables, and press the upload button, your program recognizes the Due, and connects. Also what does, "Set duty cycle to zero to avoid mirrored effect" mean?

Anonymous user

2 years ago

Hi Bruce, Thanks for that, would there be any chance of adding a Toggle feature to your GUI to allow scrolling through a frequency sweep, one frequency at a time? Cheers Ian

Anonymous user

2 years ago

Hi Bruce, I will try to create the wave forms I require using the Arduino sketch, you have included lots of useful information to enable a person to do this, Great work! Cheers

Anonymous user

5 years ago

Hi Brian, Your project is amazing, would there be any chance of modifying the code to work on something like a Teensy 3.6?, for my project I require something smaller and faster than the Arduino Due. Kind Regards

BruceEvans

2 years ago

Hi user601458150, Thanks for your kind comment. It would be great if it worked on something faster. But the .ino file was written specifically to get the most out of the DUE, and would need to be completely rewritten for anything else. Regards, Bruce.

Kelvin_Chai

5 years ago

Hi Bruce, your project is really amazing. I am looking for a solution to build an 8 channels simple function generator, I am not sure how to incorporate your idea into it. Appreciate your suggestions. Thank you very much.

BruceEvans

2 years ago

Hi Kelvin, Sorry for the delay answering, but I only just noticed your reply. I'm still not receiving comment notification emails from this site! Thanks for your kind comments. Unless you need to make your own "arbitrary" waveforms, you might be able to find something simpler or cheaper elsewhere. This project can only provide 2 channels anyway, so you'd have to buy 4 due arduinos! Regards, Bruce.

Anonymous user

5 years ago

Hi Bruce, I have downloaded the project and can only see the square signal on pin seven. Nothing on pin 3. Do you have an idea for me ? Thanks and see you

BruceEvans

2 years ago

Hi, Please see my second reply to "djadeski" above. In short, Both pins are used for the square wave output, but at different times (to make full use of the Due's specifications). One pin is disabled when the other is in use. They must be connected together as explained in the installation instructions. Regards, Bruce.

Anonymous user

6 years ago

Hello, Could you please provide links where I can download the AWV files for the waveforms? Thanks!

BruceEvans

2 years ago

Hi, The .awv files are in the "Abitrary Waves" folder which should be created when you extract the .rar file you download following the instructions on this page. Regards, Bruce.

Anonymous user

6 years ago

Fantastic project - I'm going to have to buy a Due and learn how to use Arduino just for this - so I'll tell my wife to blame YOU! I want to be able to call up a series of sine waves at half a dozen, quickly on-screen-button-selectable frequencies and set their amplitudes on-screen (by controlling the gain on an output buffer op-amp) to preset values also selectable on-screen, but with scaling constants set according to the frequency. This would result in a pretty darn good audiometer! Just letting you know and thanking yopu for your great work! If I progress far enough, I'll let you know.

BruceEvans

2 years ago

Hi chhackm, I only just noticed your reply. I don't seem to be receiving comment notification emails from this site anymore! Thanks for your "fantastic" comments, although I still refuse to accept the blame if it goes belly-up! LOL I'd love to hear how you get on with your project. You'll have to write a new GUI for the PC, I suppose. Regards, Bruce.

Anonymous user

6 years ago

Hi BruceEvans, Just wanted to let you know this seems to work perfectly for me and its a great project. Have you ever tried to trigger the output based on an input pulse? What Id ideally like to be able to do is fire off one burst of the Arbitrary waveform each time I pulse an input on the Arduino.. I looked at the code hoping it might be fairly simple, but quickly realised I'm in over my head with your code! I'm still planning to look into it but it might take more time than I was looking to spend at this stage. If I do manage it Ill drop the code chanegs in a comment in case anyone else would find it useful. Awesome code though, Thanks Again, Sam

Anonymous user

2 years ago

Hello, I am not can download

BruceEvans

2 years ago

Hi Adrian, Sorry for the delay; I only just saw your comment. To download click "Read More" above. Then on the next page click "2 releases" and then on the next page click "DueArbitraryWaveformGenerator.ino" and "DueAWGController32.rar." These instructions are also shown on each page. I hope this helps. Regards, Bruce.

BruceEvans

2 years ago

Hi Sam, Thanks for your awesome comment. Regarding you question about triggering: You may be interested to know that the AWG can already be triggered by double clicking "FREQUENCY" in the GUI, but only if the frequency is lower than 0.5 Hz . However, in order to achieve it's wide specification range, the AWG produces waves in completely different ways depending on the frequency, duty cycle and "Exact Mode" so a different way of triggering would also be needed at different frequencies etc, requiring more code than you might expect. Even worse, in order to provide "one burst" of the arbitrary wave it would, of course, be necessary to detect the end of the wave cycle, and usually arbitrary waves (in this AWG) are used at 0 % or 100% duty cycle, so if you wanted to use the pulse from the (synchronized) square wave for this purpose it would be too short for the arduino to detect using normal code in the void loop for example. Therefore, code would most likely have to be put in the DACC_handler and TCO_Handler, but these are VERY time critical and ANY extra code there would use too much time, making a lower overall resolution necessary; and thereby spoiling the specifications of the AWG. I hope this makes sense to you. If the one shot effect is not essential (or resolution unimportant) and only a narrow frequency range etc is needed the idea may be practical. If you'd like to give more details of just what you need I'll see if I can help. Regards, Bruce.

Anonymous user

7 years ago

Bruce, Congratulations by the nice project. However, I'm experiencing a problem with it, and I'd like your help. The ARDUINO DUE and the GUI connect without problem, however, just a mouse click on any component of the GUI so that the connection with the board is interrupted. To reconnect I need to close the GUI and restart the board. Any idea what might be happening? Thanks Breno

Anonymous user

2 years ago

Hi Bruce My Arduino DUE drive was the initial suspicion. But we hoped to find another solution. Really, Processing is really cool. I did not know it, but in 3 minutes I was already exporting the executable program. Excellent project. Thank you for your support. Breno

Anonymous user

2 years ago

Hi Bruce I've already tested on another PC, always using the 32-bit version of the GUI, but the problem persists. Maybe the problem is in my DUE unit, which is actually a FREADUINO DUE V1.4 from elecfreaks.com. I thought of lowering the communication rate between the card and the PC to test if this could be the problem, how can I change this parameter in the GUI? Thank you again. Breno

Anonymous user

2 years ago

Sorry Bruce. Yes, the GUI works even with a board disconnected. I can draw waveforms normally. Thank you for your attention, I will follow the procedures and post the result. Breno

Anonymous user

2 years ago

Hi Bruce In fact, lowering the COM speed did not work. And yes, I was successful using the DUE command line. If you have any idea what might be happening ... Thanks

BruceEvans

2 years ago

Hi Breno, You appear to have forgotten to answer the following question: Will the GUI operate WITHOUT the DUE connected? (just to open or draw waves, or access the help file, etc.) If the answer is no, then your suggestion and question may be irrelevant, but I'll answer it anyway: The GUI program was created using "Processing" - the program that Arduino was originally based on. So in order to change the com rate you would need to install Processing 3 on your PC so you can change the DueArbitraryWaveformGenerator.pde file (found in the source folder). If successful, you could then "export the application" to create the DueArbitraryWaveformGenerator.exe file. (as well as changing the Arduino .ino file)

BruceEvans

2 years ago

Hi Breno, I suppose I should have guessed the answer was yes. I suggest checking if you can control the DUE using Arduino's serial monitor at 115200 baud. If you can, then I would not expect the com rate to be the problem. If you can't, it would be easier to just change the rate in the .ino file at first, to see if it helps (using the monitor).

BruceEvans

2 years ago

Hi Breno, Because you have the same trouble on 2 computers, and because nobody else has reported this problem despite many downloads, and because I have run the program successfully on multiple computers with a genuine Arduino Due and have also tried a cheap Chinese Due, but have not tried it with the same Due version as yours, I think you could be right suspecting your Due. It would be good if you had another one to try, wouldn't it? If anyone else has had this problem, we would like to hear from you!! Cheers, Bruce. PS: Did you install Processing 3? It looks really similar to the Arduino GUI, doesn't it?

BruceEvans

2 years ago

Hi Breno, Thanks for your comment. Regarding your question: Will the GUI operate WITHOUT the DUE connected? (just to open or draw waves, or access the help file, etc.) - If the GUI does not operate, make sure the correct folders have been created when extracting the .rar file. Especially the data folder. Make sure the settings.awg file exists in this folder. Did you use the DueAWGController32.rar file? (The DueAWGController64.rar can cause problems.) - If the GUI does operate, this may indicate it's not connecting to the DUE correctly, despite reporting that it IS connected. In this case, the problem could be harder to find. Does everything work okay on a different computer WITH the DUE connected? Cheers, Bruce.

djadeski

7 years ago

Bruce, I am new but having a ton of fun with this stuff and have perhaps a dumb question about the output protection circuitry - I understand all the components but the last two - the 50mA items F1, F2 - they are what? thanks Dave

djadeski

2 years ago

Thanks for the quick reply Bruce, I tried it out and it all works extremely well. The java desktop interface is very cool indeed. One follow up question, I understand the analog signal coming from the DAC and the squarewave from a PWM output - but why the jumper between pins 7 & 3, when the output of the squarewave is on pin 7 - i see where you use PIO_configure to setup pin 3 but its not clear to me what is going on there? If this question is better taken to another forum let me know. Best Regards Dave

BruceEvans

2 years ago

Thanks again for your comments. Regarding your question: To maximize the square wave's specifications, allowing very short duration pulses when set to 0% or 100% duty cycle, both pin 3 & 7 are used as the same output at different times. One is disabled when the other is enabled. Using one of the microprocessor's PWM outputs (pin 7) is better when the target frequency is at least 163Hz. At lower frequencies, using one of the microprocessor's TIO timer pin outputs (pin 3) is better. (See TC1_Handler at line 1845) Pin 3 (TIOA) is always used when the square wave is synchronized with the analogue wave (See ToggleSquareWaveSync at line 1289) allowing pulse times of just nanoseconds even at the minimum frequency.

BruceEvans

2 years ago

Thanks for your comments. Regarding F1 and F2, they are fuses. They can be polyfuses which "reset" themselves. I have slightly changed the description above which should make this clearer.

Anonymous user

7 years ago

I haven't tried it out yet but it looks very impressive. Recommend a YouTube video to provide an introductory tutorial on using the application. Thanks! W

BruceEvans

2 years ago

Hi Willie, I still can't replicate the problem here, so I've added to the GUI the ability of manual COM port selection. This will be enabled if automatic connection fails. I hope this solves the problem. Please download the new version (v1.1) to try it out. And would you please let me know the result either way, thanks. Regards, Bruce.

Anonymous user

2 years ago

Hi Bruce, I tried your latest version and your GUI was able to successfully connect with the DUE. Thanks for bearing with me! Best regards, Willie

BruceEvans

2 years ago

HI Willie, Thanks for your feedback. I'll investigate it as soon as possible. I assume you mean that the Due resets even when it doesn't connect. If this is not the case please let me know. Thanks, Bruce.

BruceEvans

2 years ago

Hi Willie, Thanks for your kind comments, too. If you try it you'll find there's a very comprehensive help file, so maybe a YouTube video isn't necessary. Cheers, Bruce.

BruceEvans

2 years ago

Ahhh! so there's only one COM port recognized. I just put that message box in the code to help identify the problem if it still didn't work. It's very hard to figure out the problem without seeing it!! I've just modified the code again, so please download it again and you should see a different message box this time and be able to select COM4. Hopefully it'll connect then. Cheers, Bruce.

Anonymous user

2 years ago

Hi Bruce, Same result but now I do get an error message when it fails to connect. The error message states: "Your PC has recognized only COM4. The Arduino cannot be found there." -W

Anonymous user

2 years ago

Hi Bruce, I reviewed your help file and took a look at your code. I intend to try it. Amazon is delivering my Due on Friday. Thanks! W

Anonymous user

2 years ago

Bruce, Yes, it resets every time I start the gui. -W

Anonymous user

2 years ago

Hi Bruce, My DUE arrived yesterday and I spent a little time to make sure it was functioning and to get familiar with it before trying out your code. I initially started with your serial command interface and had no problem. Like Brian, I encountered a startup initialization problem with the GUI. It appears it is something associated with the startup timing, as I can get the GUI to hook up with the DUE after several attempts of loading the GUI while simultaneously pushing the reset button on the DUE. The GUI does reset the DUE each time I start the GUI. In full disclosure, I also changed the timeout value on line 1143 to ten seconds from one second, but I'm not sure if that is making any difference. See below: else if (InputChar == 'G' && millis() < 10000) // if connecting to GUI: Timeout value changed from 1000 - Willie Aside from the startup issue, I have been able to successfully generate several waveforms with no problems. I am running Windoz 10 with Arduino IDE 1.8.5 from the Windows Store (version 1.8.10.0). I am using the Arduino DUE programming port (COM4). Let me know if you have any questions regarding the problem I am observing. Best regards, Willie

brianrow

7 years ago

Hello, I like this application of the Due. Looks like it will make a good test instrument - very flexible. I can get it to work fine with the serial Monitor, but no joy with the PC GUI - just cannot find the Arduino. I tried both the 32bit and 64bit versions. I can see the TX LED flicker as it probes the board, but no action on the RX. I know they both works as they are active when programming. If I have Serial Monitor running, then the GUI reports serial port busy. I changed the code 'bool UsingGUI = 1;' to try force the GUI - no luck! Seems like the Due is not returning data to the GUI? Any advice? Rgds, Brian

BruceEvans

2 years ago

...... to be more precise, the Due sends a message during setup (line 196) which the GUI recognizes and then initiates connection.

brianrow

2 years ago

OK, So I found the problem, it does not like COM8. On another machine where the USB registers as COM3, it finds the Due perfectly. I'll look at the JAVA code and change it to search up to 10 just to leave some headroom. Now to hook it up to some buttons and pots to play with the other stuff.

BruceEvans

2 years ago

Hi Brian, The problem seems to be corrected now. Just download the latest version. Cheers, Bruce.

BruceEvans

2 years ago

Hi Brian, Thanks for your kind comments. Regarding your problem, this is the first time I've encountered it so could you please answer the following so I can try to figure it out? 1. Which Windows version / system are you using? 2. Which Arduino IDE version are you using to upload the sketch? 3. Does the Due reset when you start up the Windows PC GUI? Find out by using the serial monitor to change the frequency or wave-shape etc. Then close the serial monitor, and then start up the PC GUI. If the wave viewed on the oscilloscope changes back to the default 1kHz sine-wave then the Due has reset. (Note that it should reset.) 4. If you have another PC / laptop does it work okay on that? (Easy to try, as the GUI doesn't need installing.) Regards, Bruce.

BruceEvans

2 years ago

Good, the part of the code you want starts from line 202, but you'll see that the com ports are actually searched up to the number of ports available, it's not limited to any particular number. You didn't say whether the Due was resetting, I think this might be important because the Due only tries to connect during setup.