Arduino and AD9833 Signal Generator Part 2
5 boards for $5 https://www.pcbway.com/
In this video we upgrade the basic signal generator with an OLED display showing frequency and the waveform type. Next we will migrate it to a PCB, and you can have a signal generator that can output up to 12.5MHz for less than $20.
My code: https://pastebin.com/0FXxuM8s
CyberCityCircuits: https://shop.cybercitycircuits.com/ – Electronic kits, subscription boxes, tools and components.
My Amazon link: Anything you buy through this link helps support the channel, it doesn’t cost you extra, and I make a few%. https://amzn.to/3706t6c
Yes!! I now have merch: https://teespring.com/stores/learnelectronics-store?page=1 Electronics themed T-ShirtsIf you are shopping for electronic components, test gear or consumables please consider visiting my Amazon shop @ https://www.amazon.com/shop/learnelectronics
Please check out www.patreon.com/learnelectronics and pledge a dollar if you can. It will go a long way to keeping the channel alive. It costs a bit of money to buy all the items and produce these videos. You help is appreciated.
———————————————————————————————————————
Or….if you’d like to send a one-time donation you can use this link: paypal.me/learnelectronics
———————————————————————————————————————-
Here is all the gear I currently use:
Oscilloscope 1: Rigol 1054Z https://amzn.to/2PRybtN
Oscilloscope 2: Siglent SDS1202X-E https://amzn.to/31Kk1yH
Power Supply 1: TekPower TP3005N https://amzn.to/2TeQnxI
Power Supply 2: RUIDENG DP50V5A https://amzn.to/2sNicSe
Signal Generator: JS2800 https://ban.ggood.vip/d9vk
DMM1: Owon18B https://amzn.to/2SbIGLs
DMM2: Aneng 8008 https://amzn.to/2sNQncI
DMM3: Aneng 8009 https://amzn.to/2S5qeEp
DMM4: Uni-T UT801 https://amzn.to/2S89SuL
Soldering Station1: Zeny (Yihua)862D+ https://amzn.to/2S49z4e
Soldering Station2: KSGR T12 https://amzn.to/2Wk7Dn9
Light Meter Smart Sensor AS803 https://amzn.to/2B2gyRg
, https://i.ytimg.com/vi/qy7FKdQWVKE/hqdefault.jpg
source
thanks for the project but i have a question if i want to connect mosfet to switch load 1A at 5 MHZ is this posssible ? also which mosfet do you recommend for this circuit
Can we also control pulse width in square wave
the reason your signal generator will not count to 3 is because 0 is a number in other words 0 is 1 so start at 0 and count to 2 ..default 0 = sine
1= triangle ..2 = square ….. you could use switch case: and default Im sure google could tell you more on this because it is a C and C++ compiler
Regarding the code, you can reset the buttonPushCounter after the Switch statement instead of before it. This way you will reach 1, 2, and 3 in your Switch logic. This means you can then remove your default block in the Switch statement.
Maybe a rotary encoder with built in push button would be useful? That way you could get a stable frequency, and maybe dial in frequencies digit wise, eg. 5 push 3 push 4 push 1 push for 5341 Hz. Just a thought 🙂
Besides the topics regarding the counter and the button changing to LOW, I was wondering if the switch/case loop can be simplified by using a 2-dimensional array and just using the button counter as the index… something like:
disp_status = [ ["Sine", SINE_WAVE], ["Tri", TRIANGLE_WAVE], ["Square", SQUARE_WAVE] ];
…
display.print( disp_status [buttonPushCounter][0] );
gen.ApplySignal( disp_status [buttonPushCounter][1] );
display.display();
This should work with button status 0 to 2. And that way the code would be much more compact and probably faster…
Paul , I like this idea! Do you have any plans to add an analog output for gain and possibly things like sweep frequencies and pulse generation?
what OLEAD p/n did you use. trying to use equipment that is used in video to get familiar with it and how it functions. if the oscilascope is on your site i wii purchase it from you. Any assistance greatly appreciated. Thank you Artie
Someone may have already said this and I just missed it, but your button state will never get to 3 because it's being limited to 2 just before the switch-case section. Just change your cases to 0-2 to match.
I haven't studied the code in depth as I'm on my phone, but I have an Arduino sketch for the atmega328 where one particular "var++" REFUSED to work and it turned out to be some bug in the compiler. I changed it to "var = var+1" and it works fine Change it back and it breaks again. I use this to confuse programmers as it was a nasty bug to troubleshoot. "var++" works fine elsewhere in the same sketch.
Turn it into a bfo for an old shorwave radio that doesn't have one.
Thanks 😁
Glad you decided to continue on with the project, looking forward to anothet part TBA soon. Really enjoying the project and videos, Thanks for all the great content you continue to bring to us (been super stoked with the daily {almost seems like more Than one a day… Almost like 1video every 3/4 of a day- which is awesome} uploads of new videos). Really happy to see alternatives, especially those that are much more affordable (and not to forget, also fun bc they get made into hands-on, DIY projects), much more knowledge-inducing, and makes it all more personal as well. Nothing like being able to show it off and say, "yeah I made that…. That's cool though that you BOUGHT yours" lol. To wrap it up, huge fan of yours Paul. I Thank you again for the Soldering Iron you sent me a few months back (didn't know at the time I needed to get a power supply for it, not just USB hook up… Which was followed up then when I bought the wrong PS online too, haha.), Thanks for the easy to understand teaching you pass on, your ability to keep it down-to-earth and just like 1 regular guy speaking to another guy kind of talk; it keeps things much simpler to comprehend and to truly understand the concepts. And lastly, Thanks for the motivation to keep building the lab at home and searching out for more things to try and learn- at home, with a small budget currently, but still having the ability to make it happen. Sorry for the lengthy comment; I know a while back the comments almost stopped existing bc of a few a$$holes and the negativity they spilled here…. Thought some positive words, with some real honest thought behind it would be a nice change of pace lol. Thanks again for all of it Paul. Having found this hobby (which has become a bit more Than just a hobby by now), and your videos as well when I did, was perfect timing, with all the chaos and other nonsense I had going on at the time. For sure saved my sanity lol. Anyway, stay safe my friend. Looking forward to the next video soon. Famous last words, Peace.
Thanks Paul. Another nice one.
Looking forward to part 3. Can you share a bit of detail on the PCB design?
Hey Paul Good job! Yes a signal generator to 12.5 MHz for about $20 is fantastic…I plan on building one of these into a case – looking forward to the PCB design!
Nice, looking forward to the next part.
Thanks Paul.
Definitely a part 3. I've gotten to the point where I use the Nano more than the Uno. The display was a good addition. Have a good one, Paul.
Paul you have the button pin set as INPUT_PULLUP so your logic will be backward. A button press will send the pin low not high.
Great work.
A PCB board for part 3 might be a little primature.
Kinda like building a car. Now we got the engine, lets put it on wheels and run it. -but what about the steering and breaks?
There is a lot of fun to do on the output stage, dc-offset, output impedance, signal level.
It seems that you have a good handle on op-amps but maybe you are not up for the challenge? 😉
Have you tried anything similar with the SI 5351?
Looking forward to the finale! I think your programming is fine, as one guy told me "there's more than 1 way to skin a cat" – the important thing in the end is that YOU understand it and it's written well enough to debug or add on to in the future. Nice work!
Any practical applications or projects where DACs are used? Apart from function generators?
Why didn't you use your 'Nano Experimenters Board' for this, wasn't this the kind of thing you made it for? Anyway, your code problem seems to be with manually setting the state of the button, (line 86). There is no need to keep track of the state of the button, you just need to increment the counter when it gets pressed.
I cannot test this code but try this….DELETE THESE LINES:
69 …if (buttonState != lastButtonState) {
84 … }
86 …lastButtonState = buttonState;
(As shown in pastebin)
You should then be able to change line 87 ( ' if (buttonPushCounter > 2){ ' ) to >3.
Good luck.
Paul, I just tell folks I'm a hardware guy, (different hardware) not a programmer.
Your programming is fine. If it works is all that matters, you're not writing the next great game or operating system. 😁 This project is getting pretty interesting, are you going to make a PCB to hold the Nano and other parts? Thanks for the video!
what's the use of this signal generator ? what can be done with it in addition to a proof it can work as shown here ?
hi Thats great .Keep up the good work .best regards
(I do have some programming experience.) I wonder what's the deal with `buttonPushCounter` that you encountered.
I see it is programatically limited between 0 (inclusive) and 2 (inclusive). With the initial value of 0, the switch() would branch into the default handler "Squar", for a value of 1, into the "Sine" handler, and for the value of 2 into the "Tri" handler. Is that also what happens when you run it?
It would seem to me that everything would behave just fine when you comment out the entire branch for `case 3`?
The generator seems to produce random DC offset. Is there anything to do about it?
Nice project, I think the only thing the commercial option would have over this one is a sweep function, which you could probably build in the code, and other wave forms. However, for under $20, not bad. It looks like this only needs 5 gpio pins, you could use an attiny85 on this, assuming it’d have space for the program.
Another great job. Very interesting, simple and efficient👍
can any of this help me discover how to quell the noise in my guitar?
I mean other than my paltry playing : )
I find case a pita, if comparatives are better I think, especially for 3 states. 012
imho you set up variables for if conditionals, you should only need 1 var for case. ++ upon press.
Yes! Bring on part 3, Nano on a circuit board!
Have you ever thought about using STM or ESP. I HAVE A Small collection going and. Could always. Learn more.
Great video
Stay safe
Hi there! Can you make a video about how to display pwm of a motor ? Displayed to lcd? Thanks
Paul , I’m curios what happened to your other scopes?
Great follow up Paul!