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

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024
  • 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/...
    Twitter: / garyexplains
    Instagram: / garyexplains
    #garyexplains

Комментарии • 117

  • @jakemeyer8188
    @jakemeyer8188 2 года назад +32

    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!

  • @kortaffel
    @kortaffel 2 года назад +30

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

    • @alatnet
      @alatnet 2 года назад +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 Год назад

      Where?

    • @Paul_Bearden
      @Paul_Bearden 9 месяцев назад

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

  • @AlMartinsvidplace
    @AlMartinsvidplace 2 года назад +24

    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 2 года назад +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 Год назад

      @@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 Год назад

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

  • @Wolfennar
    @Wolfennar 2 года назад +24

    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.

  • @daviddavies3637
    @daviddavies3637 Год назад +2

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

  • @w2tty
    @w2tty 2 года назад +16

    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.

  • @markwarburton8563
    @markwarburton8563 2 года назад +6

    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!

  • @VarunaSingh89
    @VarunaSingh89 2 года назад +5

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

    • @dutchdykefinger
      @dutchdykefinger 2 года назад +1

      It is indeed

    • @SchoolforHackers
      @SchoolforHackers 2 года назад +1

      Yup, commonly called db19, though it’s really de19. Ah, the old days.

  • @jonathanstein6056
    @jonathanstein6056 2 года назад +2

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

  • @sundhaug92
    @sundhaug92 2 года назад +3

    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  2 года назад +2

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

  • @critical_always
    @critical_always Год назад +4

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

  • @webmasterg3526
    @webmasterg3526 Год назад

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

  • @Darkk6969
    @Darkk6969 2 года назад +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

  • @samneggs1
    @samneggs1 2 года назад +4

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

  • @DavidAlsh
    @DavidAlsh 2 года назад +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  2 года назад +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 Год назад

      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.

  • @captainpumpkinhead1512
    @captainpumpkinhead1512 2 года назад +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!

  • @misterhat5823
    @misterhat5823 2 года назад +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  2 года назад

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

    • @misterhat5823
      @misterhat5823 2 года назад +1

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

    • @GaryExplains
      @GaryExplains  2 года назад

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

    • @misterhat5823
      @misterhat5823 2 года назад +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  2 года назад +4

      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.

  • @DylanMatthewTurner
    @DylanMatthewTurner 2 года назад +1

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

  • @theosib
    @theosib 5 месяцев назад

    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.

  • @geoffmorrison3648
    @geoffmorrison3648 2 года назад

    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.

  • @simonabunker
    @simonabunker 2 года назад +1

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

  • @openBSDguru
    @openBSDguru 2 года назад +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..

  • @leskaighin8903
    @leskaighin8903 Год назад +1

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

  • @theosib
    @theosib 5 месяцев назад +1

    I did this too!

  • @steve_1507
    @steve_1507 Месяц назад

    Wouldn't it be possible to use some analog pins for the color to save some pins?

  • @pathfinderpolska
    @pathfinderpolska 11 месяцев назад

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

  • @helmutzollner5496
    @helmutzollner5496 2 года назад +1

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

    • @GaryExplains
      @GaryExplains  2 года назад +1

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

  • @tonysheerness2427
    @tonysheerness2427 2 года назад +1

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

  • @JarppaGuru
    @JarppaGuru 7 месяцев назад

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

  • @anurasenarathna1703
    @anurasenarathna1703 2 года назад +1

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

  • @bertblankenstein3738
    @bertblankenstein3738 2 года назад +1

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

    • @massimookissed1023
      @massimookissed1023 Год назад

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

  • @clearwater1231
    @clearwater1231 2 года назад +1

    Digital to audio. Bada bing bada boom

  • @SpeccyMan
    @SpeccyMan 6 месяцев назад

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

  • @auglau1
    @auglau1 5 месяцев назад

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

  • @taoyang9843
    @taoyang9843 Год назад

    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.

  • @fallenrepublic6342
    @fallenrepublic6342 Год назад

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

  • @Alice8000
    @Alice8000 Месяц назад

    But does it play DOOM?

  • @SadiqueKhan449
    @SadiqueKhan449 Год назад

    This will surely able to run cyberpunk 🎉🎉

  • @fluiditynz
    @fluiditynz Год назад

    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.

  • @aleXelaMec
    @aleXelaMec 2 года назад

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

  • @wulfboy_95
    @wulfboy_95 2 года назад +1

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

    • @wayland7150
      @wayland7150 Год назад

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

  • @markhatch1267
    @markhatch1267 Год назад

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

  • @sinjhguddu4974
    @sinjhguddu4974 2 года назад +1

    Informative tutorial, thank you.

  • @PhyChris
    @PhyChris 5 месяцев назад

    240p possible?

  • @TheGamingDinosaurRoblox
    @TheGamingDinosaurRoblox Год назад

    of course its doom

  • @jasontiscione1741
    @jasontiscione1741 2 года назад

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

  • @gregdaweson4657
    @gregdaweson4657 2 года назад

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

  • @VioletGiraffe
    @VioletGiraffe 2 года назад

    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.

  • @joegee2815
    @joegee2815 2 года назад

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

  • @badco.3705
    @badco.3705 Год назад

    Boku no pico 🤠

  • @VioletGiraffe
    @VioletGiraffe 2 года назад

    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.

  • @matiasvaldothebird4043
    @matiasvaldothebird4043 Год назад

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

  • @jensschroder8214
    @jensschroder8214 2 года назад

    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  2 года назад +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 2 года назад

      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)

  • @TT-it9gg
    @TT-it9gg 2 года назад

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

    • @GaryExplains
      @GaryExplains  2 года назад +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.

  • @RonSheely
    @RonSheely 11 месяцев назад

    Thank you Gary.

  • @randysmith7094
    @randysmith7094 2 года назад

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

    • @GaryExplains
      @GaryExplains  2 года назад +1

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

    • @GaryExplains
      @GaryExplains  2 года назад +1

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

    • @randysmith7094
      @randysmith7094 2 года назад

      @@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  2 года назад

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

  • @anirudhkaviya9143
    @anirudhkaviya9143 9 месяцев назад

    Very well explained sir!

  • @mandelbro777
    @mandelbro777 2 года назад

    > "But can it run Crysis?"

  • @1MarkKeller
    @1MarkKeller 2 года назад +1

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

  • @graealex
    @graealex 2 года назад +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  2 года назад +9

      Wow. Feel better now?

    • @graealex
      @graealex 2 года назад +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 2 года назад +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  2 года назад +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  2 года назад +5

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

  • @wakeupcanadians
    @wakeupcanadians Год назад

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

    • @GaryExplains
      @GaryExplains  Год назад

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