Raspberry Pi Pico VGA video output using only resistors

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to show you how to generate a vga signal from a raspberry pi pico here's a picture of my raspberry pi pico comes in a little tray like this uh and you i bought mine from biopi.ca in canada so they're five dollars twenty five cents canadian which is four dollars u.s so just a quick comparison of the raspberry pi pico and an arduino um so uh the cool thing about the raspberry pi is the clock speed of the dual core cpu the arm cortex m0 it's 133 megahertz whereas the single core arduino most arduinos are only 16 megahertz flash memory and ram are also much higher the thing that's cool about the 133 megahertz is it actually allows you to generate a vga signal now the reason for that is there's something called a vga pixel clock which is the clock speed that you need to generate a single pixel at a particular display size so even at a small vga display 640 by 480 you need a 25 megahertz clock so the pico can do it but the arduino really can't so let's go through the setup process i'm going to set this up on my macbook there's a document that you can download from the raspberrypi.org website which takes you through setting it up on setting up the compiler on different operating systems so essentially what you need to do on a mac is install homebrew i already had homebrew installed so i had to update homebrew and then install something called cmake now cmake essentially generates make files from configurations then you need to install the arm gcc compiler so the instructions are all there in the document doesn't take very long next install visual studio code and configure the cmake tools inside once you've done that you're basically ready to get the raspberry pi pico examples and start to build them so here i'll show you how to build and load one of the simple projects it's the blink uh example project um so i'm just gonna quickly change the project so i'm gonna change the the the speed that the um led blinks at uh so it's gonna blink at a second kind of interval and i quite like to compile things on the command line so inside the pico examples folder there's a build blink subfolder which is where the builds are run make and it will build a fresh copy of that blink example and what it does is it generates a uf2 file and it's called blink.uf2 now um to load uh this kind of compiled executable onto our pico what we need to do is plug in the pico while pressing that boot button and what this does is uh it essentially mounts a drive not only if you saw that but on my mac there are new a new usb drive has appeared has appeared rpi rp2 and what you need to do is drag and drop the cf2 file that blink.cf2 onto that drive the moment you've done that the raspberry pi people will disconnect from your computer it'll disappear and it'll start running your projects you'll see there that blink project has actually started running and there the leds blinking at that one second interval so now that we've loaded in our first project into the pico we're ready to start to build the vga signal generator to start this off let's just draw a quick circuit diagram so this is the circuit for one set of gpios to generate one part of the color for vga and obviously you have this for red green and blue right so this circuit repeats for each of those and it's basically a five bit digital to analog converter the problem that i have with this is these resistor values um like 1k and 2k are pretty common but 4.02 and 8.06 and 499 ohms i don't i have a big uh 10 fill filled with resistors and i've got nothing close to 4.99 4.0 or 8.0 so what i need to do is figure out how to make a 499 ohm resistor what i have is a 470 ohm resistor and a 33 ohm resistor and um these are all um see they're blue which means that they're one percent um so what you can do is just put these in series so the idea is just wrap their legs together uh on one end and then you use these pens just become the resistor itself let me wrap these a bit better and then what i can do is i can i can measure what the resistance is of this so in theory this should be 503 ohms [Music] there we go so 501 so that's very close to the 400 it's within one percent so that's pretty good so i'm going to make up um three of these um one for red one for green one for blue i have nothing close to the eight either this is the closest that i have to an eight ohm resistor which is what 8.1 and what i discovered is if i take these so 8.1 is probably close enough it's the it's the least significant part the least significant bit um so um it's not going to make uh as much a difference as something like this 5 ohm 500 ohm being being off what i discovered though is if i uh take these eight point ones and i put them in parallel um i should get a four point four point zero five so this gets me a four point zero seven which i think is close enough that's you know close to it's within one percent of of what that rating is so that's a four and then i actually have 1k and 2k so this means i've got all the resistors uh to make um to make this dac so i've sped up this part of the video um here i'm building uh the resistor ladders uh or the dax for the rgb uh parts of the signal this goes pretty quickly now a note on the pin outs for the vga connector itself uh so this is the the pin outs for the female part of a vga cable one of the things i did was i bought some gender changers so that i can put this on the end of a vga cable and then i can put connector wires into the connector itself and this just allows me to very easily connect that up to a breadboard circuit notice also i'm putting in the hsync and vsync lines here and the ground a quick note on the h-sync and v-sync there are two 47-ohm resistors here they don't have to be that accurate but you'll see they're on the board there so just a quick note on where to find more information about the circuit diagram for the vga output so the circuit that i'm implementing on the breadboard here is borrowed from this document that i found on the raspberry pi website which is a hardware design guide for the 2040 rp2040 which is essentially the pico if you get this document there's also a full uh schematic at the end so this is the the picot itself um and you can see the pin outs for red green and blue notice the order of these is slightly odd so the order of the red is different from the green and the blue on the pin outs and there's gaps and grounds in between so they're not just all adjacent pins and the other thing that you can get from this document is the actual dac vga dac for red green blue as well i've omitted these switches these input switches but you can also see the vga connector pin out there okay now we're ready to program that circuit um so what we're going to do is we need some libraries from the raspberry pi github repository um so if you go to github.com forward slash raspberry pi um scroll down scroll down and look at some of the individual refills you see the pico examples and pico sdk uh you should already have those installed but keep scrolling and you'll find something called pico extras and pico playground so if we look into pico extras this actually contains a library which is called pico scan video and this is a vga implementation that we can use and in pico playground you'll see scan video there's a folder there and then it contains a set of demos that we can load into our raspberry pi pico and see what they do so sync those uh repos down and you should be good to go okay so once you've compiled those video examples we're going to start with the mandelbrot example you need to load it into the pico and uh it'll um it'll activate the display um so here you can see the mantle brought example that's running it's running at normal speed so this requires quite a lot of floating point mathematics so it's a little bit slow on the pico because it doesn't have a floating point unit um but it can still do it in with integer emulation so here's the same video kind of sped up 100 times so you can see the mandelbrot set um forming and you know the colors you know i think there's only 16 colors in this particular demo uh but you can see it's working uh really well so let's take a look at some of the other demos so this is a sprite demo just kind of floating heads um i think there might be a problem with my dac because some of the colors aren't quite right there um a text mode version so you can put text on the screen this is quite a nice floating raspberry pi um icon um and again this is uh this is a horizontal scrolling there's something called the mario scrolling demo as well which is very much like this so anyway i hope uh you like watching this video i really enjoyed making it if you like this kind of content please hit the like button and subscribe and i'll see you in the next video
Info
Channel: Robin Grosset
Views: 80,951
Rating: undefined out of 5
Keywords: raspberry pi pico, VGA, video
Id: RmPWcsvGSyk
Channel Id: undefined
Length: 11min 10sec (670 seconds)
Published: Sat Feb 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.