Raspberry Pi Pico PIO - Ep. 6 - VGA Video and C/C++

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome to life with david i'm david and today i'm continuing my research into the programmable input output features of the rp2040 last time we explored the many ways the pio jump instruction could be used at the conclusion of that video i said i wanted to try to generate video signals well as i got into the weeds i realized that micro python with pio support wasn't going to cut it however using the c c plus software development kit greatly increases the capabilities of the pico in general and the pio in particular so why don't you join me as we try to output some video from the raspberry pi pico in my previous videos about the rp2040 programmable input output i use micropython for both the main and the pio programming micro python is great for learning the pico but because it's an interpreter it's too slow to do any really high speed signal processing even though i know that the c c plus plus sdk results in much quicker and more powerful routines i've been avoiding it because really i don't know see that well but in order to move forward i figure i've got to bite the bullet so i'm taking the first step which is to load and compile some c video display programs that were developed by raspberry pi to showcase the capabilities of the pico i reference for raspberry pi's hardware design with rp 2040 to build the pico to video graphics array display circuitry also known as vga vga was one of the first higher quality analog computer graphics displays although there are now a wide variety of screen resolutions it debuted in 1987 at a resolution of 640 by 480 pixels when vga was developed computer monitors were not that much removed from the analog television sets of the day in these monitors an electron beam scans the face of the picture tube and generates a color dot made up of red green and blue phosphors as simulated here the entire screen is scanned vertically 60 times per second each scan line is generated by moving the dot horizontally at about 31 500 times a second the pixels are output at a rate of about 25 megahertz [Music] with this circuit we're outputting five bits of red five bits of green and five bits of blue on the pico gpio pins these signals are summed using a resistor-based digital-to-analog converter circuit for a total of 225 colors two additional signals are generated by the pico for the horizontal and vertical sync pulses the resistors in the dac are specified as 500 1000 2000 4000 and 8000 ohms i had exact values for the three most significant bits and was closed for the two least significant bits it's not a big deal it only affects the color balance a little [Music] i used a vga gender changer to make it easy to connect the breadboard to the vga cable i connected the summed red green and blue signals and added a ground to the cable i also connected the horizontal and vertical sync signals from the gpio pins through 47 ohm resistors then i connected the cable to an old lcd vga monitor i had that takes care of the hardware side time for the software to prepare to compile the c code i had to install several applications on my windows-based pc i referred to raspberry pi's getting started with raspberry pi pico in chapter 9 it describes the software packages you need to install even though it's very thorough i still experienced a couple gotchas first the current version of cmake which is 3.21.2 at the time of this video wouldn't finish properly on my machine after a little digging i found that version 3.19.8 did run properly the second gotcha when building your programs from the developer command prompt window every time you set an environment variable you need to close the current window and open a new one to make the change stick i mean every time the guide says it in bold print and i did it the first time but the second time i wasted a lot of time chasing an environment not found air i downloaded the pico extras and pico playground folders from the raspberry pi github account i'll put links in the description of this video i extracted them into folders named pico extras and pico playground [Music] start the video developer command prompt window navigate to the folder where the pico sdk and pico extra folders are located and add them to the environment [Music] [Music] then close the developer command prompt window and open up another one navigate into the pico playground folder and create a build directory using makeder navigate into the build directory and run cmake using the following command after a few seconds the program should complete then run nmake using this command if all goes well the programs in the pico playground folder should begin compiling including the scan video folders i'll jump forward about 7 minutes to the end of the compiling process the uf2 files to download into the pico should be inside their respective folders in the build directory plug a usb cable from your computer into the pico while holding the boot button the pico will appear as a separate device [Music] then drag the uf2 file from the appropriate folder into the pico after downloading the file the pico will reboot and run the program [Music] here are several of the video demonstrations first is the most basic called scan video minimal followed by the test pattern [Music] here's a demonstration of how the pico can display text [Music] next is demo one which shows the raspberry pi logo moving around the screen this is followed by a sprite demo showing multiple sprites moving independently [Music] next the direct memory access of the pico is demonstrated by the h scroll dma tiles and mario tiles programs in the first one horizontal motion is demonstrated mario tiles demonstrates motion in several axises and zooming too the final demo is mandelbrot here both cores of the rp2040 are used to calculate the mandelbrot graphic even though the rp2040 doesn't have a floating point arithmetic unit it still does pretty well here it is in normal speed this is what it looks like if we speed it up by 300 times [Music] how does it work well i'm still trying to wrap my head around it some really smart people at raspberry pi programmed their butts off and made every little bit of code count the scad and video routines provided by raspberry pi rely on the rp2040 generating the graphic data for each horizontal line each and every time the line is drawn roughly 31 500 times per second there are scan line buffers but in most cases there are no frame buffers primarily because there isn't much memory on board the rp2040 however i believe the mandelbrot demo does use a frame buffer to support dual core operation [Music] the timing and video output are provided by the pio pio using c c plus is much more powerful than using micro python the sdk allows you to stack many smaller pio programs into the 32 word pio program memory and each state machine can run its own little program independently from any other state machine with public entry points i only understand about five percent of how the video programs interact with the scan video c program the scan video pio program and the timing pio program there are a number of features in the rp2040 that are new to me including the c c plus plus sdk and how to program the pio with it dual core operations direct memory access and interrupts i remember feeling like this back in college when i got in over my head trying to debug ibm 370 jcl while trying to get my complex fortran program to run i guess i was a glutton for punishment back then too thanks for joining me today we reviewed how vga video works and i built a circuit to display vgo video from the raspberry pi pico i dipped my toe into compiling c c plus programs and demonstrated several raspberry pi pico video programs however it was all cookbook stuff i have a lot of learning to do before i can write my own rp2040 video routines but that's part of the fun i hope you join me on my journey to unlock more of the secrets of the raspberry pi pico if you like this video or you think someone else might please give it a thumbs up if not give it a thumbs down the more likes this video has the more youtube will recommend it to others also please leave a comment or suggestion for things to do i hope to do more of these videos so please subscribe and click on the bell for notifications of new videos let's get together next time for another day in life with david see you soon [Music] [Music] [Music] [Music] you
Info
Channel: Life with David
Views: 1,715
Rating: undefined out of 5
Keywords: RP2040, Pico VGA, C/C++
Id: mrThmFlgV_s
Channel Id: undefined
Length: 12min 28sec (748 seconds)
Published: Thu Sep 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.