I genuinely love the time we live in. All this with a few dollars in hardware, an infinite resource of info readily available, and even the ability to design and get your own custom circuit boards made for the price of a Starbucks coffee and sent directly to your door in a matter of days. Our only constraint is a choice of ignorance. Love it!
Gotta admit, never would've thought that a microcontroller like the pico could be powerful enough to play a game, render it, and drive an output image. Absolutely mind blown.
Great explanation of VGA for the pico. Some of you may find the PicoMiteVGA implementation interesting....basic on a pico with vga support...and the graphics commands needed. I have not messed with the VGA version yet but the regular PicoMite seems to work well. The fellow who did the MaxiMite boards brought Basic over to the pico. So now we can have an 80's micro in the form of a pico microcontroller board.
I second this recommendation, having built up a Picomite myself on some Veroboard. While the hard coded graphics demos referenced in this video look very impressive, the Picomite is a nice little project which turns your Pico into a fully self-contained computer running BASIC (just add a PS2 keyboard and VGA monitor). That may not sound too impressive but if you're familiar with the Maximite and other MMBASIC running platforms, you know that BASIC running on this modern hardware is a fast if not faster, than machine code running on 1980's hardware. Lots of fun to play with.
@@afreestone101 BASIC in the was not fastest, but it was never slow, there was a lot a bad programming, even being manly used as stepping stone to something, else, with the excuse , X programming language does not have command X, so we wont discuses that here? more on basic is slow, professionals use x, y, z, but not, basic even if was not the fastest, that down compiler used, and hardware it was run on, 4 or 8mhz cpu's and memory 32k or 64k, it computer 510k or more you where in mainframe business stuff, now a days there some discreet logic on the motherboard somewhere that's using many time that
@@afreestone101 BASIC in the was not fastest, but it was never slow, there was a lot a bad programming, even being manly used as stepping stone to something, else, with the excuse , X programming language does not have command X, so we wont discuses that here? more on basic is slow, professionals use x, y, z, but not, basic even if was not the fastest, that down compiler used, and hardware it was run on, 4 or 8mhz cpu's and memory 32k or 64k, it computer 510k or more you where in mainframe business stuff, now a days there some discreet logic on the motherboard somewhere that's using many time that
Thanks Gary for the explanation of how the VGA can be produced. The video you shared was truly mindblowing. I've seen microcontrollers used to play snake or other simple games, but it is truly mindblowing that a microcontroller can emulate a PC to play a (relatively) sophisticated 3D graphics game. Wow!
8:23 I think the diagram is wrong, it connects the 2k ohm resistor for blue to ground instead of GP13 (17), and the 1K ohm resistor for GREEN to GND. I believe this was caused by just copying the connection-pattern from RED and not checking the ground-pins
Great explanatory video. Reminded me of the Atari 2600. This is similar to how the Atari 2600 has to be coded but at much lower resolution because the 6502 doesn't have enough grunt in it and each instruction takes at least two clock cycles, IIRC. But here the PIO takes up much of the grunt work that has to be done in software on the 2600. There is no buffer of any kind on that thing and because virtually all its time is taken up drawing the screen, most of the extra code has to be performed in the VBLANK area (what you call the Front Porch at the top of the screen).
@@GaryExplains On the green channel: GP8 is left open and the 1K is tied to ground. On the blue channel: GP13 is left open and the 2K is tied to ground. The red channel appears to be correct. Please check what you are posting instead of being defensive with critiques.
First, my apologies, you are correct. I didn't spot those mistakes. As I said the diagram is from the official Raspberry Pi github repo. It appears that a bug report was raised in Nov 2021 about this github.com/raspberrypi/pico-playground/issues/20 but it has yet to be fixed. Can I just say that if you had just led with that info, this thread would have gone much better.
There is a thing called the GPIO Expander that works with the Pi Zero. I haven't tried it, but here is the link: magpi.raspberrypi.com/articles/pi-zero-gpio-expander
Dude the Pi Pico IS a usb driven GPIO board, in a sense.. You can use thonny and micropython for example to edit the program ON the pico so all you have to do is hit F5 and the code runs. If it's about memory and speed, I concede of course.
I did something similar. I have an array of six resistors for four outputs, so I get 16 fixed colors, and the memory is organized as flat 4 bits per pixel. It didn't occur to me to run length encode the pixel data. I've been thinking about using an external RAM as a palette, but I can't find one fast enough in a through hole package.
Imagine going back in the 1980s with Pico running Pac-Man and show the designers with their multi PCB boards down to the size of a cigarette lighter. lol
Very good Gary but the PicoMiteVGA is a more complete implementation and already avaialble. Uses the 2nd ARM CPU and one of the PIOs to generate VGA without impacting the very fast MMBasic running on the other CPU. High level graphic commands and sprites, file system via both SD card and onboard Flash. Some very clever people have developed the 'Mite' over the past 12 years or so (previously on the PIC32) and it's really impressive. They are busy working on a Picomite-based (6-8 channel) Logic Analyser at the moment - it uses PIO DMA transfers (controlled by MMB) to achieve the speed. Just built a PicomiteVGA 'home computer' for my Grandson's birthday - software a free download, hardware just a Pico and a few components. Very inexpensive and much easier to do for us programming Dummies! 🙂
It's interesting if you look at the Espressif ESP32 variants how many of them have co-processors that aren't well known. For example ESP32-S3 has two LX7 ARM main processors and two ULP coprocessors, one based on RISC-V instruction set architecture (ULP-RISC-V) and the other on finite state machine (ULP-FSM). The clock of the coprocessors is the internal fast RC oscillator. C3 and C2 look to be missing out on these. While the coprocessor speeds appear at first glance to be very constrained by the RTC clock speed, don't forget that the ESP32 units contain DMA. While a micro like the C3 needs highly structured multitasking to run real time tasks in addition to something like VGA (And doesn't have that many pins anyway), most of the other ESP32 variants do have the capacity. Many of the pheripherals support DMA which substantially offloads urgent tasks when used. If the ULP can be switched to run at a higher clock speed, there's a lot more can be done with many of the Espressif chips. And they have built in Wireless. That's the main thing putting me off doing much with the RP2040 dev boards. On the flip side of that, I developed a PCB years ago using an OSD chip. Around the time I started populating the board, I found the OSD chip was going obsolete, so it's great to see projects like the VGA hat and the HDMI hat for the RP2040. I would think that typical sorts of tasks the ULP would be well suited for would be things like remote control IR code bit banging, reading and writing other custom bit banged protocols. Not sure how much connectivity the low power RISC-v sub core has on the S3 to the main pheripherals? Of course there's also the possibility that the processors are not fully available, for example they may get priority tasks from the 2.4G subsystem, I don't know if that stuff is in embedded code or if it's implemented in an FPGA realised as a subset ASIC block on chip.
A simple doubling of resistor value between bit positions does not give a linear output. Consider the 500 and 1000 values. If only the GPIO with the 500 resistor is high the voltage across the 75 ohm in the display is proportional to 75/(500+75) = 0.1304 When only the 1000 ohm one is energised the voltage across the 75 is proportional to 75(1000+75) = 0.0.0698. Clearly the first of those is less than twice the second. For the 8K resistor it is 75(8000+75) = 0.009288. The ratio between the outputs from the 500 and 8000 is only 14.043 instead of the ideal 16.
Is the same doable with ESP32? It's similar in performance and RAM (more RAM, I think - 320K), but I don't know if it has hardware DMA which seems crucial.
My 386DX-40 PC with 4 MB of RAM cannot really run DOOM - it's too slow (no FPU). And the Pico with 320K can? The CPU is faster for sure, but what about RAM? DOOM requires 4MB at the minimum.
I think the Pico will be 70% busy and full with VGA. You have to program really fast and efficiently to squeeze everything in there. Therefore everything in C++ and not in python. Each higher Lib will again need space and CPU time. The 8 bit computers of the 80's had their own IC that took care of the video and not the CPU.
Yes that might all be true but the Pico is a dual core processor so there is another whole core sitting there doing nothing. Also, it is powerful enough to play Doom, do that kind of proves what it is capable of doing.
If you code efficiently you can definitely get a lot out of it. If you do it right you can even get VGA output plus a basic animated effect in less than 1.5 kilobytes (for the whole .bin file; 3KB for the .uf2, always twice the size)
@@GaryExplains This guy seems to be the only one with videos of this Pico Doom. Honestly looks pretty sus' to me. I'm simply not going to believe this until I see some independent setup videos.
Yes, that is a mistake. The diagram is from the official Raspberry Pi github repo. It appears that a bug report was raised in Nov 2021 about this github.com/raspberrypi/pico-playground/issues/20 but it has yet to be fixed.
would be cool if someone could come up with some sort graphics card based on the pico with an ttl interface so that ppl could use it on their homebrew computers. maybe even sprites might be possible.. just dreaming..
Yes, lets not use an SoC with a built-in framebuffer and digital video interface, and instead produce a 5-bit-per-channel analog legacy format for which display devices get increasingly rare by the day by bitbanging and having CPU utilization close to 100% all the time. Also, the severe shortages of all Raspberry Pi products means that you probably should avoid them altogether, at least if you have the option.
@@GaryExplains Kind of. Anyway, there is so much interesting stuff to do - and we're here doing bad VGA on underpowered micros... Show some real-time HDMI pass-through video processing on an FPGA board, that'd be interesting.
@@GaryExplains I also have the feeling that since Bitluni did not only VGA but also Composite video on an ESP32, the topic is about as explored as it can be.
Hmmmm, I guess that depends on what you find interesting, personally I found this very interesting but I wouldn't find real-time HDMI pass-through video processing on an FPGA board interesting at all. Each to his own. The title is clear, as is the description, if the subject doesn't interest you then just move along. No need to rant about why you don't like it. Wastes my time and yours.
I have no idea who Bitluni is (a TH-camr I guess), and I don't make my videos based on what other people are making. I make what I find interesting. If you find it interesting as well, great. If not, then no problem.
I genuinely love the time we live in. All this with a few dollars in hardware, an infinite resource of info readily available, and even the ability to design and get your own custom circuit boards made for the price of a Starbucks coffee and sent directly to your door in a matter of days. Our only constraint is a choice of ignorance. Love it!
Gotta admit, never would've thought that a microcontroller like the pico could be powerful enough to play a game, render it, and drive an output image. Absolutely mind blown.
This is the first decent explanation of VGA I have seen. Thank you. Yes, I would be interested in SD card and audio as well.
Awesome, thank you!
Great explanation of VGA for the pico. Some of you may find the PicoMiteVGA implementation interesting....basic on a pico with vga support...and the graphics commands needed. I have not messed with the VGA version yet but the regular PicoMite seems to work well. The fellow who did the MaxiMite boards brought Basic over to the pico. So now we can have an 80's micro in the form of a pico microcontroller board.
I second this recommendation, having built up a Picomite myself on some Veroboard. While the hard coded graphics demos referenced in this video look very impressive, the Picomite is a nice little project which turns your Pico into a fully self-contained computer running BASIC (just add a PS2 keyboard and VGA monitor). That may not sound too impressive but if you're familiar with the Maximite and other MMBASIC running platforms, you know that BASIC running on this modern hardware is a fast if not faster, than machine code running on 1980's hardware. Lots of fun to play with.
@@afreestone101 BASIC in the was not fastest, but it was never slow, there was a lot a bad programming, even being manly used as stepping stone to something, else, with the excuse , X programming language does not have command X, so we wont discuses that here? more on basic is slow, professionals use x, y, z, but not, basic even if was not the fastest, that down compiler used, and hardware it was run on, 4 or 8mhz cpu's and memory 32k or 64k, it computer 510k or more you where in mainframe business stuff, now a days there some discreet logic on the motherboard somewhere that's using many time that
@@afreestone101 BASIC in the was not fastest, but it was never slow, there was a lot a bad programming, even being manly used as stepping stone to something, else, with the excuse , X programming language does not have command X, so we wont discuses that here? more on basic is slow, professionals use x, y, z, but not, basic even if was not the fastest, that down compiler used, and hardware it was run on, 4 or 8mhz cpu's and memory 32k or 64k, it computer 510k or more you where in mainframe business stuff, now a days there some discreet logic on the motherboard somewhere that's using many time that
Ben Eater talked about this for hours, for anyone who wants to spend a day on this topic
There's also James Sharman too. He's made a pipelined 8 bit cpu and is currently working on adding vga to his.
Where?
No, you are incorrect. Although Ben Eater used the VGA standard, his janky breadboard computer used a framebuffer.
What I find amazing is how technology that seemed way beyond my understanding eventually becomes easy and obvious when explained well.
Thanks Gary for the explanation of how the VGA can be produced. The video you shared was truly mindblowing. I've seen microcontrollers used to play snake or other simple games, but it is truly mindblowing that a microcontroller can emulate a PC to play a (relatively) sophisticated 3D graphics game. Wow!
Great video, Gary and great topic.
You have my vote for more obscure, esoteric things you can do with the Pico.
8:23 I think the diagram is wrong, it connects the 2k ohm resistor for blue to ground instead of GP13 (17), and the 1K ohm resistor for GREEN to GND. I believe this was caused by just copying the connection-pattern from RED and not checking the ground-pins
Yes it is wrong. Please see the other discussions about that here in this comment section.
Great explanatory video. Reminded me of the Atari 2600. This is similar to how the Atari 2600 has to be coded but at much lower resolution because the 6502 doesn't have enough grunt in it and each instruction takes at least two clock cycles, IIRC. But here the PIO takes up much of the grunt work that has to be done in software on the 2600. There is no buffer of any kind on that thing and because virtually all its time is taken up drawing the screen, most of the extra code has to be performed in the VBLANK area (what you call the Front Porch at the top of the screen).
Very interesting explanation of VGA, well worth making and watching.
Very good explanation on VGA signal, and creating VGA from PICO. Thank you for sharing your knowledge.
Glad it was helpful!
The RP2040 and its PIO are fantastic. Half-step between microcontrollers and FPGAs. Like VIDOR.
Ohhh! I get it now! Thank you for your excellent explanation of how a VGA signal and interface really works.
There's errors in your diagram at 8:17. Your resistor ladders some resistors connected to ground and the GPIO is left open.
I think you are mistaken. Also, the diagram comes from the Raspberry Pi people, not me.
@@GaryExplains I'd have to disagree. That diagram is wrong.
Which resistors are connected to ground and the GPIO left open?
@@GaryExplains On the green channel: GP8 is left open and the 1K is tied to ground. On the blue channel: GP13 is left open and the 2K is tied to ground. The red channel appears to be correct.
Please check what you are posting instead of being defensive with critiques.
First, my apologies, you are correct. I didn't spot those mistakes. As I said the diagram is from the official Raspberry Pi github repo. It appears that a bug report was raised in Nov 2021 about this github.com/raspberrypi/pico-playground/issues/20 but it has yet to be fixed. Can I just say that if you had just led with that info, this thread would have gone much better.
I think technically the port is called D-sub?
Great video!
It is indeed
Yup, commonly called db19, though it’s really de19. Ah, the old days.
Love this series on embedded programming. Would love a USB driven GPIO board I can plug directly into my PC and not need a Pi or Arduino!
There is a thing called the GPIO Expander that works with the Pi Zero. I haven't tried it, but here is the link: magpi.raspberrypi.com/articles/pi-zero-gpio-expander
Dude the Pi Pico IS a usb driven GPIO board, in a sense.. You can use thonny and micropython for example to edit the program ON the pico so all you have to do is hit F5 and the code runs. If it's about memory and speed, I concede of course.
Pico DVI is also a thing (and works over HDMI)
I did something similar. I have an array of six resistors for four outputs, so I get 16 fixed colors, and the memory is organized as flat 4 bits per pixel. It didn't occur to me to run length encode the pixel data. I've been thinking about using an external RAM as a palette, but I can't find one fast enough in a through hole package.
wow ....just wow....i feel like i am learning the esoterica of a secret religion....super awesome content. Thanks for sharing your knowledge...
Why is the 2k resistor in the blue section in your diagram connect to ground and not to GP13?
Unfortunately there are some mistakes in the diagram. The red channel is correct.
Imagine going back in the 1980s with Pico running Pac-Man and show the designers with their multi PCB boards down to the size of a cigarette lighter. lol
Wouldn't it be possible to use some analog pins for the color to save some pins?
Very good Gary but the PicoMiteVGA is a more complete implementation and already avaialble. Uses the 2nd ARM CPU and one of the PIOs to generate VGA without impacting the very fast MMBasic running on the other CPU. High level graphic commands and sprites, file system via both SD card and onboard Flash. Some very clever people have developed the 'Mite' over the past 12 years or so (previously on the PIC32) and it's really impressive. They are busy working on a Picomite-based (6-8 channel) Logic Analyser at the moment - it uses PIO DMA transfers (controlled by MMB) to achieve the speed. Just built a PicomiteVGA 'home computer' for my Grandson's birthday - software a free download, hardware just a Pico and a few components. Very inexpensive and much easier to do for us programming Dummies! 🙂
I kind of want to build a custom RP2040 dongle that just plugs into USB and VGA to output something like this. That's be so cool!
THIS IS JUST CRAZY SMART!!!! I DONT HAVE ANNYTHING TO SAY!!! Simple and genius!!!!
Informative tutorial, thank you.
Glad it was helpful!
Is it possible to use 1 pin with 1 resistor pwm to replace the 5 pins with resistors
It's interesting if you look at the Espressif ESP32 variants how many of them have co-processors that aren't well known. For example ESP32-S3 has two LX7 ARM main processors and two ULP coprocessors, one based on RISC-V instruction set architecture (ULP-RISC-V) and the other on finite state machine (ULP-FSM). The clock of the coprocessors is the internal fast RC oscillator. C3 and C2 look to be missing out on these. While the coprocessor speeds appear at first glance to be very constrained by the RTC clock speed, don't forget that the ESP32 units contain DMA. While a micro like the C3 needs highly structured multitasking to run real time tasks in addition to something like VGA (And doesn't have that many pins anyway), most of the other ESP32 variants do have the capacity. Many of the pheripherals support DMA which substantially offloads urgent tasks when used. If the ULP can be switched to run at a higher clock speed, there's a lot more can be done with many of the Espressif chips. And they have built in Wireless. That's the main thing putting me off doing much with the RP2040 dev boards. On the flip side of that, I developed a PCB years ago using an OSD chip. Around the time I started populating the board, I found the OSD chip was going obsolete, so it's great to see projects like the VGA hat and the HDMI hat for the RP2040. I would think that typical sorts of tasks the ULP would be well suited for would be things like remote control IR code bit banging, reading and writing other custom bit banged protocols. Not sure how much connectivity the low power RISC-v sub core has on the S3 to the main pheripherals? Of course there's also the possibility that the processors are not fully available, for example they may get priority tasks from the 2.4G subsystem, I don't know if that stuff is in embedded code or if it's implemented in an FPGA realised as a subset ASIC block on chip.
Very well explained sir!
Glad you liked it
If nothing else, it's great for teaching people how graphics adapters work at the most basic level.
Digital to audio. Bada bing bada boom
A simple doubling of resistor value between bit positions does not give a linear output. Consider the 500 and 1000 values. If only the GPIO with the 500 resistor is high the voltage across the 75 ohm in the display is proportional to 75/(500+75) = 0.1304 When only the 1000 ohm one is energised the voltage across the 75 is proportional to 75(1000+75) = 0.0.0698. Clearly the first of those is less than twice the second. For the 8K resistor it is 75(8000+75) = 0.009288. The ratio between the outputs from the 500 and 8000 is only 14.043 instead of the ideal 16.
What if I need VGA input? I have a 16x16 neopixel grid here.
I guess you could write a MicroPython extension in C, but the interpreter will use up some of that precious memory!
The E12 values might be 470, 1000, 2200, 3900 and 8100. That should be closer enough.
2x 1k in parallel = 500 Ω
1x 1k = 1k
2x 1k in series = 2k
1.8k + 2.2k = 4k
3.3k + 4.7k = 8k
Why can my vga make 1080p if it is so much smaller in the video?
Does anyone know what the component (47) that they placed in hsync and vsync is?
47ohms?
Thank you Gary.
-HDMI- DVI is actually possible on the RPi Pico.
That would be a better option if possible. It actually ought to be easier as long as the Pico can keep up.
Is the same doable with ESP32? It's similar in performance and RAM (more RAM, I think - 320K), but I don't know if it has hardware DMA which seems crucial.
Yes
240p possible?
This will surely able to run cyberpunk 🎉🎉
My 386DX-40 PC with 4 MB of RAM cannot really run DOOM - it's too slow (no FPU). And the Pico with 320K can? The CPU is faster for sure, but what about RAM? DOOM requires 4MB at the minimum.
I did this too!
I think the Pico will be 70% busy and full with VGA. You have to program really fast and efficiently to squeeze everything in there. Therefore everything in C++ and not in python.
Each higher Lib will again need space and CPU time.
The 8 bit computers of the 80's had their own IC that took care of the video and not the CPU.
Yes that might all be true but the Pico is a dual core processor so there is another whole core sitting there doing nothing. Also, it is powerful enough to play Doom, do that kind of proves what it is capable of doing.
If you code efficiently you can definitely get a lot out of it. If you do it right you can even get VGA output plus a basic animated effect in less than 1.5 kilobytes (for the whole .bin file; 3KB for the .uf2, always twice the size)
I just sold my 10 years old AOC monitor(1920x1080) for ¥90($13), last week. 😭. How I wish that I had seen this video earlier.
But does it play DOOM?
It doesn't have enough memory for a 480p frame buffer but it can run Doom? That is extremely hard to believe.
There are other techniques besides frame buffers. The code is here try it for yourself: github.com/kilograham/rp2040-doom
Also the port runs as 320x200x60 not 480p. More details here as well: kilograham.github.io/rp2040-doom/
@@GaryExplains This guy seems to be the only one with videos of this Pico Doom. Honestly looks pretty sus' to me. I'm simply not going to believe this until I see some independent setup videos.
That is your choice. It isn't my job to convince you.
The schematic is wrong. You connect two pins to GND....
Yes, that is a mistake. The diagram is from the official Raspberry Pi github repo. It appears that a bug report was raised in Nov 2021 about this github.com/raspberrypi/pico-playground/issues/20 but it has yet to be fixed.
would be cool if someone could come up with some sort graphics card based on the pico with an ttl interface so that ppl could use it on their homebrew computers. maybe even sprites might be possible.. just dreaming..
*GARY!!!*
*Good Evening Professor!*
*Good Evening Fellow Classmates!*
Stay Safe Out There Everyone!
MARK ‼️‼️
A gun? Try three guns - one for each of the colours red, green and blue!
Boku no pico 🤠
> "But can it run Crysis?"
Crysis no... Doom yes!
16:06 yes yes no problem its not 16bit its 5bit haha
of course its doom
A little board consuming hours and hours of programmer's time.
😂
Vega is shit. Iam from europe and we have rgb in composit and universal euroconnector 😊
Yes, lets not use an SoC with a built-in framebuffer and digital video interface, and instead produce a 5-bit-per-channel analog legacy format for which display devices get increasingly rare by the day by bitbanging and having CPU utilization close to 100% all the time. Also, the severe shortages of all Raspberry Pi products means that you probably should avoid them altogether, at least if you have the option.
Wow. Feel better now?
@@GaryExplains Kind of. Anyway, there is so much interesting stuff to do - and we're here doing bad VGA on underpowered micros...
Show some real-time HDMI pass-through video processing on an FPGA board, that'd be interesting.
@@GaryExplains I also have the feeling that since Bitluni did not only VGA but also Composite video on an ESP32, the topic is about as explored as it can be.
Hmmmm, I guess that depends on what you find interesting, personally I found this very interesting but I wouldn't find real-time HDMI pass-through video processing on an FPGA board interesting at all. Each to his own. The title is clear, as is the description, if the subject doesn't interest you then just move along. No need to rant about why you don't like it. Wastes my time and yours.
I have no idea who Bitluni is (a TH-camr I guess), and I don't make my videos based on what other people are making. I make what I find interesting. If you find it interesting as well, great. If not, then no problem.
what good is this video with nothing to how we can do this just you thumb down
Eh? I don't understand. What information is missing?