It is impressive how diverse the community is, i was just laying around in TH-cam and your video popped out. It is interesting that I just recently had this project in mind and starting to build up my own PCB design for a waveform generator by using rp2040, MDACs and High speed amplifiers, this video is super helpful due to the theory and the awesome explanation of the different peripheral functionality integrated with PIO. Definitively subscribed.
Thank you very much. I’m working toward a high speed version; but progress has been slowed because of my cataract surgery and all the other things going on because of summer. Maybe in a few months. Thanks for watching!
You're welcome. Thanks for the input. I'll see if I can put together something that will be useful. It all depends on getting high speed amplification (+25mHz). That will take a little bit of research. Until recently, I've been a low speed digital/audio guy, the world of high speed analog (i.e. radio) is new to me too.
Such a good and well documented work! Even for a microcontroller & c beginner its understandable (of course with pausing, repeating and looking into the repo). Thank you for making it public, sir!
@@LifewithDavid1 I did web development for over 10y now. And I was a bit scared of C/C++. Now I am writing pure C with the power of this little beast :D Keep doing, I bet it helps a lot of other people as well 👍
You are awesome! Thank you. Breaking down the informations to the minimum needed to understand the basics is above reach of other TH-cam Videos. This reminds me of the 80/90s computer area and the sharing of informations that time. Thanks!!!
Ideas for you David: 1). Do the reverse, input waveforms, then display them via your method, basis of an oscilloscope. 2) Modulate the waveform with a baseband signal for an AM transmitter. Probably reaching the limits of what the Pico could do unassisted, but I'm blown away by the capability of DMA/PIO.
HI David. Thanks again for a wonderful video! The Pico project I'm sorta looking at is to make a simple software-defined radio out of an Si5351A board and a Pico. I'm thinking of using the Si5351A to generate generate quadrature LO signals and a couple of SA612 mixers to give me I & Q signals. I want to read I & Q into A/D converters on the Pico using DMA. I'm intrigued with the potential to make a very cheap SDR receiver that's somewhat out of the normal. In particular, I'm fascinated with having the crunching power of two cores that don't have to work significantly on data grabbing. And doing it in Micropython :-) although I can do it in C if necessary.
That's a neat project. MicroPython is not quite as capable as C when it comes to PIO interrupts or DMA. I had to go to C for my video and AWG projects because of that. Good luck and keep us informed of your progress!
Fantastic project and the whole series you're making David! Helped me a lot. Until now all my projects were C++ based (Arduino, Teensy, ESP etc.). I picked the Pico for its rapid and easy prototyping with Python, which I was looking to finally get started with. Having to go through C++ chain and the separate io file and steps to achieve the coolness of PIO is a little off-putting. Definitely not "prototyping-friendly". I wish there was Python path for the same. While I'm fine with C++, for now I'll need to focus on the basics and mastering the Python. Nonetheless, I'll be coming back and keep my eye on your fantastic work. There are two important factors I really like about your videos. One, is going through the code and explaining what particular statements are responsible for. And the second is explaining the background of the topic, which like in this episode, not everyone might know what is and how an arbitrary generator works.
Thank you for the kind comments. I like making videos, and my tendency to "over-explain" (my kids' term) helps with the background. As you may know, many of my early PIO videos used MicroPython. There is a lot you can do with MicroPython; although some things might be a little clunky. Thanks for watching!
Thanks for nice and unparalleled coverage of rp2040 pio. Would appreciate if you could consider SPWM waveform generation using pio in some of your next episode. Thanks for your efforts and excellent coverage. PIO peripheral is already available on many other brand mcu but such a beautiful coverage on pio is unique on TH-cam. Thanks.
Thanks for the suggestion. I plan to follow up my Arbitrary Waveform video with one with a higher frequency op amp with a slightly better user interface. This sounds like it would be well suited for SPWM.
Super interesting video David. It would be great to know how far you can push this up. BTW, I read it is possible to overclock the 2040 up to 300Mhz without issues. Thanks for sharing, I am learning how to do PIO programming.
Thanks. I've got the high speed op amps but I haven't put it together yet. Right now I'm thinking a pseudo sine wave of about 15 MHz ( 8 samples per wave cycle)
Thanks for watching! No, I haven't looked at hardware interpolation. I'm not sure what I could do to demonstrate it on a Pico. If you have any ideas; let me know!
@@LifewithDavid1 I haven't seen examples yet but the datasheet says it can be used for audio dithering and textures. I do like the idea that it can do simple repetitive operations like right shift, masking and saving processor cycles.
That's a really ambitious project! I'm not sure the Pico could handle that much data. It only has 256K of memory, which would only be enough for a few milliseconds of a signal at 20Msps. And that doesn't include any space for the program. The Pico does have a built in ADC which can (I think) sample one pin at 500Ksps. That might be a good place to start. Thanks for watching!
That's a great idea. I didn't know about the BUF634, which looks like it would be easy to implement. However, I already bought some LM6171's and LM7171's to improve the frequency response; which I hope to do soon. Follow the link in the description for the code. Thanks for watching!
HDMI is just too fast for the Pico. Even the slowest HDMI (cat 1) operates at 75 MHz. The Pico operates at 125 MHz, which only allows 2 clock cycles to process each chunk of HDMI data. This is just not fast enough. Sorry.
I'm always impressed with how much can be done with the PIO blocks! Do you know if the block exists in other Pi devices, like the Pi Zero (BCM2835)? For example, there's a Pi project using a GPIO to implement an RF transmitter! Another great Pico PIO example is the can2040, which achieves full 2.0b Can Bus Specs using only one of the PIO hardware blocks! BTW, I've been thinking of implementing the PIO functionality inside an FPGA/CPLD.. any suggestions?
I don't believe any other RasPi device has PIO. They do have specialized I/O for handling several different standardized protocols. I'm not sure, but the higher clock speeds for the Pi 2, 3, 4, and 0 should allow them to do bit banging and give the illusion that they have PIO. Looking at the history of the Pico, it was first implemented on FPGAs during development. I've not worked with FPGAs (I'm too cheap and the Pico gets me the FPGA functionality I want at a VERY reasonable price) but I don't see why you couldn't make it happen. Good luck!
Because of my electronics noobitude, I wouldn‘t have thought of using the op-amp, believing that the output of the DAC by itself would be enough. What is the output range of the DAC when it‘s powered by VUSB? How is it improved by the op-amp?
Oh sorry, the inputs to the DAC are GPIOs, so they‘re high or low in the 3.3v range. It‘s the op-amp that‘s powered by VUSB. #noob So is the op-amp used in order to get output in the 5v range? If so, then you could do without the op-amp if you‘re okay with DAC output in the 3.3v range? #noob #questions
These are all good and important questions. If you go slow enough, and the downstream circuitry doesn't draw any load, then you can get by with no op-amp. However, to get any speed, or to provide any current, you need an amplifier to keep the current draw and capacitance on the resistor network as low as possible. This will also maintain the accuracy of the DAC because a higher downstream current draw on the resistor network will load the most significant bit (MSB) GPIO more than the LSB. This will cause a little voltage sag on the MSB GPIO, causing non-linearity. Because the op-amp is set up for unity gain, the output will be 0 to 3.3 volts (same as the input). Note that while the LM358 is capable of single supply operation, there will still be some non-linearity near 0 volts. If you were to set up the op-amp as an inverting amplifier with a split power supply, you could make an output that would be useful for all types of downstream circuits. Op-amps are awesome little devices, and there is a ton of information on how to use them "hidden" in their datasheets. Look through one, don't be discouraged if you don't understand all of it at first. The idea is to just familiarize you with where and what kind of information you can find. Good luck and have fun!
@@LifewithDavid1 thanks! My mental model of an op-amp was that it‘s just for amplification, but obviously there‘s a lot more to it than that. I might have some LM358s in the “box of stuff to try out someday”, looks like it‘s time to do just that.
@@slimhazard I definitely encourage you to do! For very long time op-amps were a mystery to me. Especially, when very early in my electronic journey I saw an analogue computer full of them. They can do all sorts of mathematical operations! I was thinking "how on earth?". Lately I finally got to use them and even do some designs. So awesome and relatively easy to work with. Just like Lego bricks.
David, now that you are close to mastering the PIO on Pico, why not try your hand at the FlexIO on the Teensy 4 or 4.1? Nobody else has tackled this, so you’d probably attract a ton of new subscribers from the Teensy community.
Thanks for the suggestion! As I learn more about the RP2040, I realize how much more there is to learn. I've not worked on the Teensy before; so I scanned the web for info. Version 4.1 looks like a very powerful controller. I'll look into it more; but I'm afraid it could be quite some time before I can put out content that would be worth people's time to watch.
@@LifewithDavid1 You bet! Your PIO series is really a general master class on hardware concepts in modern systems - and in programming them. Way beyond merely the Pico. As for the Teensy, you're right. It's the most powerful microcontroller out there. And FlexIO is its PIO. Keep up the great work! PS I too work with 65xx ICs, so I really appreciate what you're doing.
thank you, this is exactly the information i was looking for! now i know what i wanna do is feasable! but please stop with the music fading in and out for like a second between lines, it's super irritating.
Pi is 3.1415926535 from memory, you have 3.1428592654. Is there a reason that I missed? So I tried the difference between 39Hz and what the pico gives from the clocks and got 3.1466272572013. I'll puzzle it out in the end before I call typo :).
Go ahead and call typo. I remember that Pi is 3.14159. This came from a little chunk of code I got from another program. In fact I was going to change it; but it slipped my mind. Good catch! The difference in Pi will lead to a mis-shapened curve but not a difference in frequency. However a better value of pi will lead to a better curve. In reality; it probably doesn't make any difference at all since the resolution is only 1 in 256.
@@LifewithDavid1 Given most uses of PI end up being multiplied by 2, there is merit in using Tau(2xPI) instead of PI. Looking at the code: awg_buff[i] = 128+(sin((factor)*2*PI)*127); //Loads the AWG Buffer table with values of the wave Though maybe the compiler is clever enough to optimise that out, though might need bracing the (2*PI) to nudge that, safer with Tau as any literal when the first thing you do is multiply it by two always bemused me.
This channel is really "out-of-the-ordinary", thank you for sharing all these with the world!
Glad you enjoy it! Thanks for watching!
It is impressive how diverse the community is, i was just laying around in TH-cam and your video popped out. It is interesting that I just recently had this project in mind and starting to build up my own PCB design for a waveform generator by using rp2040, MDACs and High speed amplifiers, this video is super helpful due to the theory and the awesome explanation of the different peripheral functionality integrated with PIO. Definitively subscribed.
Thank you very much. I’m working toward a high speed version; but progress has been slowed because of my cataract surgery and all the other things going on because of summer. Maybe in a few months. Thanks for watching!
Thank you for showing this project I would be interested in seeing an improved version. It's great seeing how all the pieces come together.
You're welcome. Thanks for the input. I'll see if I can put together something that will be useful. It all depends on getting high speed amplification (+25mHz). That will take a little bit of research. Until recently, I've been a low speed digital/audio guy, the world of high speed analog (i.e. radio) is new to me too.
Such a good and well documented work! Even for a microcontroller & c beginner its understandable (of course with pausing, repeating and looking into the repo). Thank you for making it public, sir!
Glad you enjoyed it! Thanks for watching!
@@LifewithDavid1 I did web development for over 10y now. And I was a bit scared of C/C++. Now I am writing pure C with the power of this little beast :D
Keep doing, I bet it helps a lot of other people as well 👍
You are awesome! Thank you. Breaking down the informations to the minimum needed to understand the basics is above reach of other TH-cam Videos. This reminds me of the 80/90s computer area and the sharing of informations that time. Thanks!!!
Glad it was helpful! As you may have guessed; I loved the homebrew computer community support during the 70's and 80's.
Ideas for you David:
1). Do the reverse, input waveforms, then display them via your method, basis of an oscilloscope.
2) Modulate the waveform with a baseband signal for an AM transmitter.
Probably reaching the limits of what the Pico could do unassisted, but I'm blown away by the capability of DMA/PIO.
Those are great ideas. I'm working on a higher frequency AWG now. Thanks for watching!
Great video. A video using the PIO with Sigma Delta, and a simple RC filter to play an audio file would be pretty interesting.
That would be interesting. I'll have to add that to my list of potential video ideas. Thanks!
I was thinking about a small MIDI synthesizer project, so this would definitely interest me!
@@richardmarsden6541 Wow, that would be really cool!
Thank you. I really liked the video, because the way I treat the subject was very clear and novel for me.
Glad you enjoyed it! Thanks for watching!
HI David. Thanks again for a wonderful video! The Pico project I'm sorta looking at is to make a simple software-defined radio out of an Si5351A board and a Pico. I'm thinking of using the Si5351A to generate generate quadrature LO signals and a couple of SA612 mixers to give me I & Q signals. I want to read I & Q into A/D converters on the Pico using DMA.
I'm intrigued with the potential to make a very cheap SDR receiver that's somewhat out of the normal. In particular, I'm fascinated with having the crunching power of two cores that don't have to work significantly on data grabbing. And doing it in Micropython :-) although I can do it in C if necessary.
That's a neat project. MicroPython is not quite as capable as C when it comes to PIO interrupts or DMA. I had to go to C for my video and AWG projects because of that. Good luck and keep us informed of your progress!
Why did you define Pi as 3.142859264 instead of 3.141592653?
That's an "aw s#!+" I borrowed some code from another Raspberry Pi program and it had Pi defined improperly. My bad!
Hello, your video series is fascinating.
Glad you think so!
Cool, thanks for this video.
No problem! Thanks for watching!
Fantastic project and the whole series you're making David! Helped me a lot. Until now all my projects were C++ based (Arduino, Teensy, ESP etc.). I picked the Pico for its rapid and easy prototyping with Python, which I was looking to finally get started with. Having to go through C++ chain and the separate io file and steps to achieve the coolness of PIO is a little off-putting. Definitely not "prototyping-friendly". I wish there was Python path for the same. While I'm fine with C++, for now I'll need to focus on the basics and mastering the Python.
Nonetheless, I'll be coming back and keep my eye on your fantastic work.
There are two important factors I really like about your videos. One, is going through the code and explaining what particular statements are responsible for. And the second is explaining the background of the topic, which like in this episode, not everyone might know what is and how an arbitrary generator works.
Thank you for the kind comments. I like making videos, and my tendency to "over-explain" (my kids' term) helps with the background.
As you may know, many of my early PIO videos used MicroPython. There is a lot you can do with MicroPython; although some things might be a little clunky. Thanks for watching!
Great tutorial, and, I have to admit, I would love to see how you would improve the signal generator. 👍
Thank you! I'm going to take a look into it. It all depends on amplifier frequency response.
Thanks for nice and unparalleled coverage of rp2040 pio. Would appreciate if you could consider SPWM waveform generation using pio in some of your next episode.
Thanks for your efforts and excellent coverage.
PIO peripheral is already available on many other brand mcu but such a beautiful coverage on pio is unique on TH-cam.
Thanks.
Thanks for the suggestion. I plan to follow up my Arbitrary Waveform video with one with a higher frequency op amp with a slightly better user interface. This sounds like it would be well suited for SPWM.
Super interesting video David. It would be great to know how far you can push this up. BTW, I read it is possible to overclock the 2040 up to 300Mhz without issues. Thanks for sharing, I am learning how to do PIO programming.
Thanks. I've got the high speed op amps but I haven't put it together yet. Right now I'm thinking a pseudo sine wave of about 15 MHz ( 8 samples per wave cycle)
Nice tutorial!
Glad you think so! Thanks for watching!
Thank you for continuing the exploration of the capabilities of the Raspberry Pico. Have you covered hardware interpolators for the raspberry pico?
Thanks for watching! No, I haven't looked at hardware interpolation. I'm not sure what I could do to demonstrate it on a Pico. If you have any ideas; let me know!
@@LifewithDavid1 I haven't seen examples yet but the datasheet says it can be used for audio dithering and textures. I do like the idea that it can do simple repetitive operations like right shift, masking and saving processor cycles.
Sir, Can you make a video to interface ADC08100 to pio of raspberry pi pico and display the analog waveform on a pc ?
That's a really ambitious project! I'm not sure the Pico could handle that much data. It only has 256K of memory, which would only be enough for a few milliseconds of a signal at 20Msps. And that doesn't include any space for the program. The Pico does have a built in ADC which can (I think) sample one pin at 500Ksps. That might be a good place to start. Thanks for watching!
Fantastic project. Thank you. May I suggest you use something like a BUF634 as an output buffer-amp.. And, would you make the code available?
That's a great idea. I didn't know about the BUF634, which looks like it would be easy to implement. However, I already bought some LM6171's and LM7171's to improve the frequency response; which I hope to do soon. Follow the link in the description for the code. Thanks for watching!
is it possible to read single colors from a hdmi signal with pico?
HDMI is just too fast for the Pico. Even the slowest HDMI (cat 1) operates at 75 MHz. The Pico operates at 125 MHz, which only allows 2 clock cycles to process each chunk of HDMI data. This is just not fast enough. Sorry.
I'm always impressed with how much can be done with the PIO blocks!
Do you know if the block exists in other Pi devices, like the Pi Zero (BCM2835)? For example, there's a Pi project using a GPIO to implement an RF transmitter!
Another great Pico PIO example is the can2040, which achieves full 2.0b Can Bus Specs using only one of the PIO hardware blocks!
BTW, I've been thinking of implementing the PIO functionality inside an FPGA/CPLD.. any suggestions?
I don't believe any other RasPi device has PIO. They do have specialized I/O for handling several different standardized protocols. I'm not sure, but the higher clock speeds for the Pi 2, 3, 4, and 0 should allow them to do bit banging and give the illusion that they have PIO.
Looking at the history of the Pico, it was first implemented on FPGAs during development. I've not worked with FPGAs (I'm too cheap and the Pico gets me the FPGA functionality I want at a VERY reasonable price) but I don't see why you couldn't make it happen. Good luck!
Thank you for this very good demo.
Do you think the pico can give output frequencies up to 10 Mhz, or we will need stronger hrdware?
Thank for inspiring this video! I think I could get 10 MHz; but I need a high speed amplifier. I'll be investigating that in the future.
Because of my electronics noobitude, I wouldn‘t have thought of using the op-amp, believing that the output of the DAC by itself would be enough. What is the output range of the DAC when it‘s powered by VUSB? How is it improved by the op-amp?
Oh sorry, the inputs to the DAC are GPIOs, so they‘re high or low in the 3.3v range. It‘s the op-amp that‘s powered by VUSB. #noob
So is the op-amp used in order to get output in the 5v range? If so, then you could do without the op-amp if you‘re okay with DAC output in the 3.3v range? #noob #questions
These are all good and important questions. If you go slow enough, and the downstream circuitry doesn't draw any load, then you can get by with no op-amp. However, to get any speed, or to provide any current, you need an amplifier to keep the current draw and capacitance on the resistor network as low as possible. This will also maintain the accuracy of the DAC because a higher downstream current draw on the resistor network will load the most significant bit (MSB) GPIO more than the LSB. This will cause a little voltage sag on the MSB GPIO, causing non-linearity.
Because the op-amp is set up for unity gain, the output will be 0 to 3.3 volts (same as the input). Note that while the LM358 is capable of single supply operation, there will still be some non-linearity near 0 volts.
If you were to set up the op-amp as an inverting amplifier with a split power supply, you could make an output that would be useful for all types of downstream circuits. Op-amps are awesome little devices, and there is a ton of information on how to use them "hidden" in their datasheets. Look through one, don't be discouraged if you don't understand all of it at first. The idea is to just familiarize you with where and what kind of information you can find. Good luck and have fun!
@@LifewithDavid1 thanks! My mental model of an op-amp was that it‘s just for amplification, but obviously there‘s a lot more to it than that. I might have some LM358s in the “box of stuff to try out someday”, looks like it‘s time to do just that.
@@slimhazard I definitely encourage you to do! For very long time op-amps were a mystery to me. Especially, when very early in my electronic journey I saw an analogue computer full of them. They can do all sorts of mathematical operations! I was thinking "how on earth?". Lately I finally got to use them and even do some designs. So awesome and relatively easy to work with. Just like Lego bricks.
David, now that you are close to mastering the PIO on Pico, why not try your hand at the FlexIO on the Teensy 4 or 4.1? Nobody else has tackled this, so you’d probably attract a ton of new subscribers from the Teensy community.
Thanks for the suggestion! As I learn more about the RP2040, I realize how much more there is to learn. I've not worked on the Teensy before; so I scanned the web for info. Version 4.1 looks like a very powerful controller. I'll look into it more; but I'm afraid it could be quite some time before I can put out content that would be worth people's time to watch.
@@LifewithDavid1 You bet! Your PIO series is really a general master class on hardware concepts in modern systems - and in programming them. Way beyond merely the Pico. As for the Teensy, you're right. It's the most powerful microcontroller out there. And FlexIO is its PIO.
Keep up the great work!
PS I too work with 65xx ICs, so I really appreciate what you're doing.
@@jonathanstein6056 Thank you. I appreciate your kind words.
thank you, this is exactly the information i was looking for! now i know what i wanna do is feasable! but please stop with the music fading in and out for like a second between lines, it's super irritating.
Glad it was helpful. Sorry the music was irritating; I'm not using the music as much. However, I still don't like dead air. Thanks for watching!
sir , for video you are using same shirt for last 3 years ?
You're right. That's my video making shirt! By always using the same shirt, I can maintain continuity if I have to re-record an opening or closing.
You want to watch the TH-cam legend that is 'Colin Furze' ... I think he's had the same shirt since leaving school! 🤣 P.S. Great video's David 😎
@@simonbaxter8001 Thank you. It does get washed; so everything smells nice and fresh! LOL
Wow, 100kHz just from the basic setup.
The RP2040 is really neat. As you may have seen from my later videos; I got much faster. Thanks for watching!
Pi is 3.1415926535 from memory, you have 3.1428592654. Is there a reason that I missed? So I tried the difference between 39Hz and what the pico gives from the clocks and got 3.1466272572013.
I'll puzzle it out in the end before I call typo :).
Go ahead and call typo. I remember that Pi is 3.14159. This came from a little chunk of code I got from another program. In fact I was going to change it; but it slipped my mind. Good catch!
The difference in Pi will lead to a mis-shapened curve but not a difference in frequency. However a better value of pi will lead to a better curve. In reality; it probably doesn't make any difference at all since the resolution is only 1 in 256.
@@LifewithDavid1 Given most uses of PI end up being multiplied by 2, there is merit in using Tau(2xPI) instead of PI.
Looking at the code: awg_buff[i] = 128+(sin((factor)*2*PI)*127); //Loads the AWG Buffer table with values of the wave
Though maybe the compiler is clever enough to optimise that out, though might need bracing the (2*PI) to nudge that, safer with Tau as any literal when the first thing you do is multiply it by two always bemused me.