What is VGA and How to Use it With a Raspberry Pi Pico

Sdílet
Vložit
  • čas přidán 11. 07. 2022
  • VGA is de-facto PC video standard. It is an analogue video system with a heritage from the IBM PS/2. The Raspberry Pi Pico is fast enough to generate a VGA signal in real time! In this video I look at VGA, how it works, and how to build a simple DAC for generating a VGA signal using the Pico.
    RP2040 Doom: DOOM1 Demo/Gameplay on a Raspberry Pi Pico: • RP2040 Doom: DOOM1 Dem...
    Let Me Explain T-shirt: teespring.com/gary-explains-l...
    Twitter: / garyexplains
    Instagram: / garyexplains
    #garyexplains

Komentáře • 115

  • @jakemeyer8188
    @jakemeyer8188 Před rokem +29

    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!

  • @Wolfennar
    @Wolfennar Před rokem +20

    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.

  • @kortaffel
    @kortaffel Před rokem +26

    Ben Eater talked about this for hours, for anyone who wants to spend a day on this topic

    • @alatnet
      @alatnet Před rokem +3

      There's also James Sharman too. He's made a pipelined 8 bit cpu and is currently working on adding vga to his.

    • @alinaqirizvi1441
      @alinaqirizvi1441 Před rokem

      Where?

    • @Paul_Bearden
      @Paul_Bearden Před 5 měsíci

      No, you are incorrect. Although Ben Eater used the VGA standard, his janky breadboard computer used a framebuffer.

  • @w2tty
    @w2tty Před rokem +15

    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.

  • @critical_always
    @critical_always Před rokem +3

    What I find amazing is how technology that seemed way beyond my understanding eventually becomes easy and obvious when explained well.

  • @AlMartinsvidplace
    @AlMartinsvidplace Před rokem +23

    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.

    • @afreestone101
      @afreestone101 Před rokem +1

      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.

    • @dh2032
      @dh2032 Před 10 měsíci

      @@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

    • @dh2032
      @dh2032 Před 10 měsíci

      @@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

  • @samneggs1
    @samneggs1 Před rokem +4

    Great video, Gary and great topic.
    You have my vote for more obscure, esoteric things you can do with the Pico.

  • @markwarburton8563
    @markwarburton8563 Před rokem +5

    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!

  • @leskaighin8903
    @leskaighin8903 Před rokem +1

    Very interesting explanation of VGA, well worth making and watching.

  • @anurasenarathna1703
    @anurasenarathna1703 Před rokem +1

    Very good explanation on VGA signal, and creating VGA from PICO. Thank you for sharing your knowledge.

  • @markhatch1267
    @markhatch1267 Před 11 měsíci

    Ohhh! I get it now! Thank you for your excellent explanation of how a VGA signal and interface really works.

  • @anirudhkaviya9143
    @anirudhkaviya9143 Před 5 měsíci

    Very well explained sir!

  • @sinjhguddu4974
    @sinjhguddu4974 Před rokem +1

    Informative tutorial, thank you.

  • @daviddavies3637
    @daviddavies3637 Před rokem +1

    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).

  • @RonSheely
    @RonSheely Před 7 měsíci

    Thank you Gary.

  • @aleXelaMec
    @aleXelaMec Před rokem

    THIS IS JUST CRAZY SMART!!!! I DONT HAVE ANNYTHING TO SAY!!! Simple and genius!!!!

  • @jonathanstein6056
    @jonathanstein6056 Před rokem +2

    The RP2040 and its PIO are fantastic. Half-step between microcontrollers and FPGAs. Like VIDOR.

  • @VarunaSingh89
    @VarunaSingh89 Před rokem +5

    I think technically the port is called D-sub?
    Great video!

  • @fallenrepublic6342
    @fallenrepublic6342 Před rokem

    wow ....just wow....i feel like i am learning the esoterica of a secret religion....super awesome content. Thanks for sharing your knowledge...

  • @DavidAlsh
    @DavidAlsh Před rokem +4

    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!

    • @GaryExplains
      @GaryExplains  Před rokem +3

      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

    • @paulmichaelfreedman8334
      @paulmichaelfreedman8334 Před rokem

      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.

  • @sundhaug92
    @sundhaug92 Před rokem +2

    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

    • @GaryExplains
      @GaryExplains  Před rokem +2

      Yes it is wrong. Please see the other discussions about that here in this comment section.

  • @webmasterg3526
    @webmasterg3526 Před rokem

    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! 🙂

  • @captainpumpkinhead1512
    @captainpumpkinhead1512 Před rokem +1

    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!

  • @Darkk6969
    @Darkk6969 Před rokem +2

    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

  • @theosib
    @theosib Před měsícem +1

    I did this too!

  • @fluiditynz
    @fluiditynz Před rokem

    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.

  • @clearwater1231
    @clearwater1231 Před rokem +1

    Digital to audio. Bada bing bada boom

  • @theosib
    @theosib Před měsícem

    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.

  • @joegee2815
    @joegee2815 Před rokem

    If nothing else, it's great for teaching people how graphics adapters work at the most basic level.

  • @DylanMatthewTurner
    @DylanMatthewTurner Před rokem +1

    Pico DVI is also a thing (and works over HDMI)

  • @simonabunker
    @simonabunker Před rokem +1

    I guess you could write a MicroPython extension in C, but the interpreter will use up some of that precious memory!

  • @auglau1
    @auglau1 Před měsícem

    Is it possible to use 1 pin with 1 resistor pwm to replace the 5 pins with resistors

  • @helmutzollner5496
    @helmutzollner5496 Před rokem +1

    Why is the 2k resistor in the blue section in your diagram connect to ground and not to GP13?

    • @GaryExplains
      @GaryExplains  Před rokem +1

      Unfortunately there are some mistakes in the diagram. The red channel is correct.

  • @misterhat5823
    @misterhat5823 Před rokem +6

    There's errors in your diagram at 8:17. Your resistor ladders some resistors connected to ground and the GPIO is left open.

    • @GaryExplains
      @GaryExplains  Před rokem

      I think you are mistaken. Also, the diagram comes from the Raspberry Pi people, not me.

    • @misterhat5823
      @misterhat5823 Před rokem +1

      @@GaryExplains I'd have to disagree. That diagram is wrong.

    • @GaryExplains
      @GaryExplains  Před rokem

      Which resistors are connected to ground and the GPIO left open?

    • @misterhat5823
      @misterhat5823 Před rokem +3

      @@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.

    • @GaryExplains
      @GaryExplains  Před rokem +3

      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.

  • @jasontiscione1741
    @jasontiscione1741 Před rokem

    What if I need VGA input? I have a 16x16 neopixel grid here.

  • @VioletGiraffe
    @VioletGiraffe Před rokem

    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.

  • @SadiqueKhan449
    @SadiqueKhan449 Před 11 měsíci

    This will surely able to run cyberpunk 🎉🎉

  • @gregdaweson4657
    @gregdaweson4657 Před rokem

    Why can my vga make 1080p if it is so much smaller in the video?

  • @matiasvaldothebird4043
    @matiasvaldothebird4043 Před 8 měsíci

    Does anyone know what the component (47) that they placed in hsync and vsync is?

  • @geoffmorrison3648
    @geoffmorrison3648 Před rokem

    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.

  • @bertblankenstein3738
    @bertblankenstein3738 Před rokem +1

    The E12 values might be 470, 1000, 2200, 3900 and 8100. That should be closer enough.

    • @massimookissed1023
      @massimookissed1023 Před rokem

      2x 1k in parallel = 500 Ω
      1x 1k = 1k
      2x 1k in series = 2k
      1.8k + 2.2k = 4k
      3.3k + 4.7k = 8k

  • @wulfboy_95
    @wulfboy_95 Před rokem +1

    -HDMI- DVI is actually possible on the RPi Pico.

    • @wayland7150
      @wayland7150 Před rokem

      That would be a better option if possible. It actually ought to be easier as long as the Pico can keep up.

  • @taoyang9843
    @taoyang9843 Před rokem

    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.

  • @VioletGiraffe
    @VioletGiraffe Před rokem

    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.

  • @PhyChris
    @PhyChris Před měsícem

    240p possible?

  • @1MarkKeller
    @1MarkKeller Před rokem +1

    *GARY!!!*
    *Good Evening Professor!*
    *Good Evening Fellow Classmates!*
    Stay Safe Out There Everyone!

  • @openBSDguru
    @openBSDguru Před rokem +1

    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..

  • @jensschroder8214
    @jensschroder8214 Před rokem

    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.

    • @GaryExplains
      @GaryExplains  Před rokem +2

      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.

    • @TheFerdi265
      @TheFerdi265 Před rokem

      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)

  • @SpeccyMan
    @SpeccyMan Před 2 měsíci

    A gun? Try three guns - one for each of the colours red, green and blue!

  • @randysmith7094
    @randysmith7094 Před rokem

    It doesn't have enough memory for a 480p frame buffer but it can run Doom? That is extremely hard to believe.

    • @GaryExplains
      @GaryExplains  Před rokem +1

      There are other techniques besides frame buffers. The code is here try it for yourself: github.com/kilograham/rp2040-doom

    • @GaryExplains
      @GaryExplains  Před rokem +1

      Also the port runs as 320x200x60 not 480p. More details here as well: kilograham.github.io/rp2040-doom/

    • @randysmith7094
      @randysmith7094 Před rokem

      @@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.

    • @GaryExplains
      @GaryExplains  Před rokem

      That is your choice. It isn't my job to convince you.

  • @TT-it9gg
    @TT-it9gg Před rokem

    The schematic is wrong. You connect two pins to GND....

    • @GaryExplains
      @GaryExplains  Před rokem +1

      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.

  • @badco.3705
    @badco.3705 Před rokem

    Boku no pico 🤠

  • @JarppaGuru
    @JarppaGuru Před 4 měsíci

    16:06 yes yes no problem its not 16bit its 5bit haha

  • @TheGamingDinosaurRoblox
    @TheGamingDinosaurRoblox Před 11 měsíci

    of course its doom

  • @mandelbro777
    @mandelbro777 Před rokem

    > "But can it run Crysis?"

  • @tonysheerness2427
    @tonysheerness2427 Před rokem +1

    A little board consuming hours and hours of programmer's time.

  • @graealex
    @graealex Před rokem +1

    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
      @GaryExplains  Před rokem +9

      Wow. Feel better now?

    • @graealex
      @graealex Před rokem +2

      @@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.

    • @graealex
      @graealex Před rokem +1

      @@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.

    • @GaryExplains
      @GaryExplains  Před rokem +5

      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.

    • @GaryExplains
      @GaryExplains  Před rokem +5

      I have no idea who Bitluni is (a CZcamsr 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.

  • @pathfinderpolska
    @pathfinderpolska Před 7 měsíci

    Vega is shit. Iam from europe and we have rgb in composit and universal euroconnector 😊

  • @wakeupcanadians
    @wakeupcanadians Před 9 měsíci

    what good is this video with nothing to how we can do this just you thumb down

    • @GaryExplains
      @GaryExplains  Před 9 měsíci

      Eh? I don't understand. What information is missing?