{"id":40644,"date":"2014-06-14T04:31:27","date_gmt":"2014-06-14T04:31:27","guid":{"rendered":"http:\/\/rafaelfajardo.com\/portfolio\/fyprocessing-how-to-produce-640-480-color-vga\/"},"modified":"2014-06-14T04:31:27","modified_gmt":"2014-06-14T04:31:27","slug":"fyprocessing-how-to-produce-640-480-color-vga","status":"publish","type":"post","link":"https:\/\/rafaelfajardo.com\/portfolio\/fyprocessing-how-to-produce-640-480-color-vga\/","title":{"rendered":""},"content":{"rendered":"<p><a href=\"http:\/\/fyprocessing.tumblr.com\/post\/88719923784\/how-to-produce-640x480-color-vga-video-from-an-8-bit\" class=\"tumblr_blog\">fyprocessing<\/a>:<\/p>\n<blockquote>\n<p><a href=\"http:\/\/dqydj.net\/how-to-produce-640x480-vga-color-video-from-an-arduino\/\">How to Produce 640\u00d7480 Color VGA Video From an 8-Bit Arduino! &#8211; Don&rsquo;t Quit Your Day Job&hellip;<\/a><\/p>\n<p><a class=\"tumblr_blog\" href=\"http:\/\/enki2.tumblr.com\/post\/88717662999\/how-to-produce-640x480-color-vga-video-from-an-8-bit\">enki2<\/a>:<\/p>\n<blockquote>\n<blockquote class=\"link_og_blockquote\">\n<div>With a minimum of external hardware, I demonstrate how to get 640&#215;480 out of an Arduino! For the advanced reader, I present a theory of how to improve further.<\/div>\n<\/blockquote>\n<h1 class=\"entry-title\">How to Produce 640\u00d7480 Color VGA Video From an 8-Bit Arduino!<\/h1>\n<div class=\"entry-content\">\n<div><\/div>\n<p>Let me set this up for you: most 8-bit AVRs in the wild (I\u00a0<a href=\"http:\/\/arduino.cc\/en\/Main\/arduinoBoardNano\">happened to use an Arduino Nano<\/a>\u00a0for this project) are running at\u00a016\u00a0MHz.\u00a0 That\u2019s\u00a016,000,000 calculations per second\u2026 a very respectable number for most embedded applications.<\/p>\n<p>The VGA industry standard, which is pretty much the default case \u201c<a href=\"http:\/\/en.wikipedia.org\/wiki\/Video_Graphics_Array\">we-can-always-fallback-to-this<\/a>\u201d video standard\u00a0(640 pixels wide by\u00a0480 pixels tall by\u00a060 frames per second), requires pixels to be clocked out at\u00a025.175\u00a0MHz:<\/p>\n<p>25,175,000 &gt; 16,000,000.\u00a0<\/p>\n<p>And that was just\u00a0one of the barriers\u00a0to pulling off this silly project.\u00a0 And, yes,\u00a0<a href=\"http:\/\/dqydj.net\/how-to-double-clock-frequency-using-only-digital-logic\/\">with the hack I told you about last time<\/a>\u00a0(Please see my notes below), more is possible without overclocking the Arduino \u2013 roughly\u00a0800 or so pixels\u00a0wide in\u00a04 bit color should\u00a0be doable\u00a0with a\u00a016MHz part, and, probably\u00a01024 pixels in\u00a04 bit color are\u00a0in reach for\u00a020\u00a0MHz clocked parts.\u00a0 (If you\u2019re willing to drop to\u00a02 or\u00a01 bit color and\u00a0spend a ton on ICs that can handle even faster clocks, you can hit HD resolutions \u2013 but I think you\u2019ll run into financial constraints before you max out on the technical side)<\/p>\n<p>Let\u2019s begin.<\/p>\n<p>Or, if you want to skip the details:<\/p>\n<ul>\n<li>\n<h3><a href=\"http:\/\/dqydj.net\/how-to-produce-640x480-vga-color-video-from-an-arduino\/#theDemo\">Skip to the demo!<\/a><\/h3>\n<\/li>\n<li>\n<h3><a href=\"http:\/\/dqydj.net\/how-to-produce-640x480-vga-color-video-from-an-arduino\/#theSchematic\">Skip to the schematics!<\/a><\/h3>\n<\/li>\n<li>\n<h3><a href=\"http:\/\/dqydj.net\/how-to-produce-640x480-vga-color-video-from-an-arduino\/#theCode\">Bring me to the code!<\/a><\/h3>\n<\/li>\n<\/ul>\n<h2>What Was the Goal?<\/h2>\n<p>I\u2019m not sure what the current resolution record on a stock clocked Arduino is, but with tight coding you can achieve around\u00a0512 pixels wide on\u00a0a\u00a020 Mhz or\u00a0~400 pixels wide on\u00a0a\u00a016\u00a0MHz part.\u00a0 That math is simple: (20\/25.175 * 640) or (16\/25.175) * 640, if you can clock out your pixels at\u00a0one pixel per clock.<\/p>\n<p>My goal was to produce \u2018full screen\u2019 video from an Arduino using\u00a0one of the early-gen display technologies (in America \u2013 so NTSC or VGA, sorry SCART and PAL).\u00a0 Color too.<\/p>\n<p>Even though people have hacked color NTSC video out of Arduinos, they generally have only done so by changing\u00a0the clock to (usually)\u00a014.31818\u00a0MHz crystals.\u00a0 Television compatibility is great, but laziness won out and I targeted VGA and its simple, discrete outputs for red, green, and blue\u2026 and keeping my stock\u00a016\u00a0MHz clock.<\/p>\n<p>As a challenge to myself, I wanted to keep the clock under the maximum figures quoted by AVR\u00a0(20\u00a0MHz at\u00a05.5 volts).\u00a0 Overclocking is fine for the consumer on a cheap part, but it wouldn\u2019t be worth it to assume all risks in a commercial product by exceeding manufacturer specifications\u2026 if that\u2019s your final destination.<\/p>\n<p>So, my requirements were set:<\/p>\n<ul>\n<li>Full width video, (&gt;=\u00a0640 pixels wide)\u00a0from an Arduino<\/li>\n<li>Color<\/li>\n<li>Use only parts I have on hand<\/li>\n<li>No reprogrammable logic (FPGA\/CPLD\/GAL\/PAL\/PLA\/Whatever else is out there)<\/li>\n<li>\n<h3><em><span>No overclocking<\/span><\/em>!<\/h3>\n<\/li>\n<\/ul>\n<h2 id=\"theSchematic\">What Was Your Parts List?\u00a0 Can I Have a Schematic?<\/h2>\n<p>Of course!<\/p>\n<p>I did it with\u00a06 ICs, 10 resistors,\u00a0one VGA port and\u00a0a bunch of jumper wire.\u00a0 Substitutions are fine, just keep the propagation delay of the parts under\u00a032 ns so you\u00a0can latch in time (if you do my clock hack, probably\u00a0<em>20ns<\/em>\u00a0due to the weird duty cycle) or so.\u00a0 The first\u00a0four are\u00a0<a href=\"http:\/\/dqydj.net\/how-to-double-clock-frequency-using-only-digital-logic\">for the clock circuit<\/a>\u00a0I discussed last week.<\/p>\n<ul>\n<li>HD74LS04P \u2013 Not Gate.\u00a0\u00a0<em>Used as Delay<\/em><\/li>\n<li>HD74LS08P \u2013 And Gate.\u00a0\u00a0<em>XOR half<br \/><\/em><\/li>\n<li>HD74LS32P \u2013 Or Gate.\u00a0\u00a0<em>XOR other half<br \/><\/em><\/li>\n<li>SN74F10N\u00a0[\u2248 One kilogram-force, nominal weight of a 1\u00a0kg object at sea level on Earth] \u2013 Fast\u00a03 Input Nand Gates.\u00a0\u00a0<em>Clean up the ugly clock from the hacked XOR, also used as Inverter<br \/><\/em><\/li>\n<li>DM74LS244N \u2013 3 State Buffer\/Line\u00a0Driver\/Line Receiver.\u00a0\u00a0<em>Control which pixel of the\u00a0two is on the\u00a0output bus.<\/em><\/li>\n<li>SN74LS373N \u2013 8 D Type Latches.\u00a0<em>Our digital sampler\/output to resistors and sync.<\/em><\/li>\n<li>VGA Port \u2013 See\u00a0<a href=\"http:\/\/www.gammon.com.au\/forum\/?id=11608\">Nick Gammon\u2019s site<\/a>\u00a0for how to wire this.<\/li>\n<li>Resistors ~68\u00a0Ohm.\u00a0\u00a0<em>Sync signals.<\/em><\/li>\n<li>Resistors ~470\u00a0Ohm.\u00a0<em>R\/G\/B signals.<\/em><\/li>\n<\/ul>\n<h6>A Note\/Disclaimer:\u00a0 I make no warranty that this is Moderately correct, and that I even transposed it correctly from my working copy.\u00a0 I may have transposed this incorrectly,\u00a0<span>so don\u2019t even trust the picture 100%<\/span>.\u00a0 I won\u2019t be held responsible if you break any equipment using this circuit!\u00a0 Before you turn this on, check\u00a0<em>my<\/em>connections are accurate,\u00a0<em>your<\/em>\u00a0connections are correct\u00a0<em>and<\/em>\u00a0you understand what\u2019s happening.\u00a0<\/h6>\n<div class=\"wp-caption aligncenter\" id=\"attachment_7029\"><a href=\"http:\/\/dqydj.net\/wp-content\/uploads\/2014\/06\/640x480_VGA_Video_Arduino.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"Click to Zoom\" class=\"size-medium wp-image-7029\" height=\"240\" src=\"http:\/\/dqydj.net\/wp-content\/uploads\/2014\/06\/640x480_VGA_Video_Arduino-300x240.jpg\" width=\"300\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Click to Zoom<\/p>\n<\/div>\n<p>(<em>Note<\/em>: try not to use\u00a0<a href=\"http:\/\/dqydj.net\/how-to-double-clock-frequency-using-only-digital-logic\">my clock multiplier circuit<\/a>\u00a0if you build this.\u00a0 It\u2019s better to start with a\u00a032\u00a0MHz oscillator and\u00a0divide the clock by\u00a02 to drive the\u00a0Arduino than to use my hack.\u00a0 Plus, that would cut your IC count down by 2-3.)<\/p>\n<h2>How Did You Achieve 640\u00d7480?<\/h2>\n<div class=\"wp-caption alignright\" id=\"attachment_7030\"><a href=\"http:\/\/dqydj.net\/wp-content\/uploads\/2014\/06\/Breadboard-640x480-Arduino-Color-VGA.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"Click to Zoom\" class=\"wp-image-7030 size-medium\" height=\"300\" src=\"http:\/\/dqydj.net\/wp-content\/uploads\/2014\/06\/Breadboard-640x480-Arduino-Color-VGA-210x300.jpg\" width=\"210\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Click to Zoom<\/p>\n<\/div>\n<p>At this point I\u2019d like to thank\u00a0three folks in particular\u00a0for inspiring this project.\u00a0 Nick Gammon is the first \u2013 <a href=\"http:\/\/www.gammon.com.au\/forum\/?id=11608\">his VGA library<\/a>\u00a0was the start point for this successful project, and this demo\u00a0<a href=\"http:\/\/gammon.com.au\/Arduino\/TimerHelpers.zip\">requires his Timing library<\/a>.\u00a0 His timers greatly simplified the interrupt writing necessary for this project.\u00a0 His wiring diagrams and initial code-base were also invaluable to sanity checking my early prototypes.<\/p>\n<p>Second, thanks are owed to\u00a0<a href=\"http:\/\/www.henningkarlsen.com\/\">Henning Karlsen<\/a>, who had great 16\u00d716 fonts available for\u00a0easy use in Microcontroller projects.\u00a0 Please checkout his projects,\u00a0<a href=\"http:\/\/www.henningkarlsen.com\/electronics\/library.php?id=51\">especially his UTFT related projects<\/a>\u00a0where he has a ton of resources for serial displays.\u00a0 My message generator uses\u00a0one of his fonts.<\/p>\n<p>Third, to Linus Akesson (a.k.a.\u00a0<em>lft<\/em>) who\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=sNCqrylNY-0\">bitbanged vga color video out of a similar part back in 2008<\/a>.\u00a0 (<a href=\"http:\/\/www.linusakesson.net\/scene\/craft\/\">His site, here<\/a>).\u00a0 Inspirational!<\/p>\n<p>As for my project?\u00a0 At the most basic level, I treated the 8-bit microcontroller hobbyists love to love\u00a0as a\u00a04 bit microcontroller by\u00a0dividing its output into\u00a0two logical parts.\u00a0 For this demo, I had\u00a0two sets of Reds, Greens and Blues, laid out like you see on the right somewhere (the Microcontroller is an Atmel ATMega\u00a0328p on an\u00a0Arduino Nano board).<\/p>\n<blockquote>\n<p>Pin D7: Red 1<br \/>Pin D6: Green 1<br \/>Pin D5: Blue 1<br \/>Pin D4: Red 2<br \/>Pin D3: HSync<br \/>Pin D2: Green 2<br \/>Pin D1 (Tx): N\/C<br \/>Pin D0 (Rx): Blue 2<\/p>\n<\/blockquote>\n<p>\u2026 that\u2019s all Port D.<\/p>\n<p>Once I had the\u00a032\u00a0MHz clock\u00a0<a href=\"http:\/\/dqydj.net\/how-to-double-clock-frequency-using-only-digital-logic\/\">I discussed in my last post,<\/a>\u00a0the project came together quickly: the\u00a032\u00a0MHz clock goes\u00a0to the Latch Enable Pin (11) of the LS373.\u00a0 Enable gets tied to ground (always on), in effect latching to the\u00a0373 outputs to whatever\u00a0value happens to be presented every\u00a032 ns.<\/p>\n<p>The\u00a0244N\u00a0uses the\u00a0stock\u00a016\u00a0MHz clock, plus the clock\u00a0180 degrees out of\u00a0phase with itself connected to the\u00a0two enables.\u00a0 When\u00a0one clock is high, the other is low, so only\u00a0one pixel is allowed\u00a0through to the\u00a0373N\u2026 and thus presenting ~810 samples to the\u00a0monitor for every\u00a0640 pixel horizontal\u00a0(and viewable) cycle.\u00a0 Yes, that\u2019s 640+ samples, completing my goal so I can sleep well at night.<\/p>\n<h2>Could You Simplify the Circuit?<\/h2>\n<p>If you give up color fidelity\/the latch, you can use the clock and an inverted clock into the enables on the DM74LS244N \u2013 2 chips.<\/p>\n<p>As for real answers, some folks will be bothered by the mild amount of chip inflation on the board.\u00a0 Setting aside the fact that you could achieve a\u00a032MHz clock with\u00a0an external crystal, and divide it to a\u00a016MHz clock for\u00a0the Arduino (thus eliminating\u00a03 ICs)\u00a0I\u2019ve thought about it a bit, and I can\u2019t come up with a way to clock out more than\u00a0one pixel per clock\u00a0without\u00a0<em>some<\/em>\u00a0active component assistance.<\/p>\n<p>The \u201csimplest way to simplify\u201d would be to get rid of the latch and the buffer and go to a\u00a0transistor only setup.\u00a0 I tried to do this with common NPNs and PNPs \u20132222s and\u00a03904s\u00a0 and\u00a03906s &#8211;\u00a0 but they\u00a0just didn\u2019t have the switching speed necessary.\u00a0 I don\u2019t have any higher speed transistors, but I\u2019d love if someone tried to dothis with something faster.\u00a0 I\u2019m thinking:<\/p>\n<p><em>2 transistors per bus\u00a0for R\/G\/B,\u00a0one active high and\u00a0one active low, then the\u00a0470 ohm\u00a0resistors into\u00a0the VGA port.<\/em><\/p>\n<p>If you pull that off you can kill the clock circuit completely since we\u2019ll be clocking at\u00a032\u00a0MHz a second \u2013 low clock AND high clock assuming your transistors are fast enough.<\/p>\n<p>As for doing it with\u00a0all passive components?\u00a0 Perhaps by introducing some well timed delays with some fancy math and carefully selected components?\u00a0 I doubt it; my guess is you\u2019ll attenuate the signal too much for it to be useful to the monitor\/TV; I believe\u00a0<em>some<\/em>\u00a0silicon\/silicon equivalent will need to be in there.\u00a0 So, my<em>guess<\/em>\u00a0is the minimum circuit is 6-8 transistors\u00a0(PNP\/NPNs) and some resistors.<\/p>\n<p>Please someone try to prove\u00a0that wrong, though!\u00a0 It would make my year to see someone improve this design!<\/p>\n<h2>What Problems Did You\/Do You Face?<\/h2>\n<p>Simple \u2013 samples, samples everywhere.\u00a0 We\u2019re talking errors on top of errors.\u00a0 First off, you\u2019ve got the ugly clock with the fluctuating duty cycle which is a consequence\u00a0<a href=\"http:\/\/dqydj.net\/how-to-double-clock-frequency-using-only-digital-logic\/\">of the hack from last article<\/a>.\u00a0 That\u2019s not the main problem though.<\/p>\n<p>The biggest issue is the fact that we\u2019re now clocking at\u00a032\u00a0MHz into a\u00a0standard calling for\u00a025.175\u00a0MHz.\u00a0 While that wasn\u2019t a problem when folks were producing less pixels than 640 \u2013 you were guaranteed to have at least\u00a0one of your pixels\u00a0sampled \u2013 at\u00a032\u00a0MHz you actually\u00a0lose data.\u00a0 It\u2019s also far enough off that you get weird artifacts like you can see in this demo picture with my Nano displaying of\u00a0<a href=\"http:\/\/feeds.feedburner.com\/DQYDJ\">the name of an Painfully Ordinary blog you should subscribe to<\/a>\u00a0(and showing off\u00a0640 pixels per line\u00a0and its beautiful\u00a08 color palette!):<\/p>\n<p>The error is\u00a0<em>huge: 32 \/ 25.175\u00a0<\/em>=~ 27% error rate!\u00a0 It\u2019s safe to say there\u2019s an issue every 3-4 pixels: the monitor will sample while the latch is changing, or catch it during propagation delay (low to high or high to low\u00a0<em>isn\u2019t<\/em>\u00a0instantly\u00a05v or\u00a00v)\u00a0and render a color darker than we intended.\u00a0 Take note: there shouldn\u2019t be\u00a0<em>vertical lines<\/em>in the solid color horizontal bars in my video.<\/p>\n<p>The third factor is technological \u2013 the monitor samples our jittery\u00a032MHz hacked clock\u00a0at\u00a025.175\u00a0MHz to try\u00a0to get 640\u00d7480.\u00a0 The monitor itself?\u00a0 1920\u00d71080.\u00a0 For this particular monitor, that\u2019s not an issue because I can get it to display double pixels at 1280\u00d7960 and letterbox the\u00a0sides (and leave a sliver at the bottom \u2013 see the demo) of the screen.\u00a0 But still, of course, blowing up pixels means you\u2019re also zooming in on the problems we just discussed while the monitor is trying to smooth out the area between pixels.\u00a0 So, yes, errors on top of errors.<\/p>\n<h2>How Could You Improve It?<\/h2>\n<p>First, and simply, the clock.\u00a0 Most Unexceptional would be to clock the Arduino at\u00a012.5875\u00a0MHz using a\u00a0divide by 2 (use a counter) after a\u00a025.175MHz oscillator.\u00a0 Second Most Unexceptional, is to target a\u00a0<em>higher<\/em>\u00a0clock rate.\u00a0 That could be either with\u00a0<a href=\"http:\/\/wiki.osdev.org\/Video_Signals_And_Timing\">VESA \u2018non-standard standards\u2019<\/a>\u00a0or with other accepted timings (which aren\u2019t<em>quite<\/em>\u00a0640\u00d7480@60 \u2013 that\u2019s the gold standard).\u00a0 640\u00d7480@73 fps, for example, needs a\u00a031.5\u00a0MHz clock \u2013 that\u2019s only a 1.59% error.\u00a0 Quite the cleanup from 27%.\u00a0 You can also use VESA timings targeted at\u00a032\u00a0MHz \u2013 YMMV, and you\u2019ll have to read the specs on your target monitor.<\/p>\n<p>Second, a fourth bit of color for each pixel (remember, we divided our\u00a08 bit processor into\u00a02 \u2013 we\u2019re wasting a bit).\u00a0 It\u2019s a nonstandard palette, but\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/Color_Graphics_Adapter#RGBI_monitor_availability\">RGBI is doable<\/a>.\u00a0 You just need to move the\u00a0one sync pin.<\/p>\n<p>Third, external memory.\u00a0 The only practical use of the code as is?\u00a0 A digital signage display, or a silly hack for a personal web site (wait a second\u2026).\u00a0 There isn\u2019t enough on-board RAM to store discrete pixel information for 640\u00d7480, you only get\u00a0one clock per two\u00a0pixels already, and self-modifying code on a Harvard Architecture uC which can only run from flash is\u2026 not smart.<\/p>\n<h2 id=\"theCode\">How Can I Use It?<\/h2>\n<p>Sorry I buried this \u2013 I really wanted everyone to understand the\u00a0challenges first.\u00a0 Usage is simple:<\/p>\n<ol>\n<li>Burn the CKOUT fuse on your AVR microcontroller \u2013 you need to Google how to do this; I did it on a Mac by modifying \u201cboards.txt\u201d and choosing \u201cBurn Bootloader\u201d in the Arduino IDE.\u00a0 This puts the\u00a016\u00a0MHz clock on\u00a0pin D8 for the Nano.<\/li>\n<li>Next, grab\u00a0<a href=\"http:\/\/gammon.com.au\/Arduino\/TimerHelpers.zip\">Nick Gammon\u2019s Timer libraries.<\/a><\/li>\n<li>Third, download our code which runs the demo for the below video from here:<a href=\"http:\/\/dqydj.net\/wp-content\/uploads\/2014\/06\/Full640x480Video.zip\">Full640x480Video<\/a>\u00a0(zip)<\/li>\n<li>Wire up the schematic \u2013 make sure to find a way to get a doubled clock.\u00a0 We suggest a PLL or using a higher clock to begin with then dividing it for the Arduino to use.\u00a0 You can always do something like my clock doubler circuit, but please,\u00a0<em>please<\/em>\u00a0do it a better way.<\/li>\n<\/ol>\n<p><em>Want to edit the text to something meaningful to you?<\/em><\/p>\n<p><a href=\"http:\/\/dqydj.net\/scripts\/arduino\/font_generator.html\">We made a script<\/a>\u00a0to make it easy to change the message displayed.\u00a0\u00a0<a href=\"http:\/\/dqydj.net\/scripts\/arduino\/font_generator.html\">Click here to try it out<\/a> \u2013 you just need to copy\/paste the output into the fontLines16.h and fontLines16_2.h file and overwrite whatever is there to see the message transition.\u00a0 (On a side note, that\u2019s\u00a0<em>Javascript compiling C which you\u2019ll copy &amp; paste into the Arduino IDE running on Java which compiles to AVR assembler<\/em>.\u00a0 Hard to wrap my head around it!)<\/p>\n<p>Oh, of course,\u00a0you\u00a0do this at your own risk.\u00a0 I won\u2019t be held responsible for any trouble you get into trying to reproduce this project, especially with whatever expensive (or cheap) equipment you expose this too.\u00a0 This is on you; please understand what is wired to what and why; I can\u2019t guarantee my schematics are 100% accurate.\u00a0 If there is a conflict, please refer to the picture of the circuit board, if it helps (that\u00a0one works \u2013 well, at least on all the monitors in my house), but even then you should work through it on your own before trusting a random guy on the internet.<\/p>\n<p>Since you\u2019ve been waiting patiently,\u00a0<em>finally<\/em>, let\u2019s show the demo.\u00a0 We show off all\u00a08 colors \u2013 each in rows\u00a010px high,\u00a0 a \u201914 color\u2019 video rainbow made by mixing pixels, then (ugly, see: 27% timing error) some writing, then\u00a010 lines of clocking\u00a0out\u00a0<em>640 pixels\u00a0<\/em>of red\/white mixed followed by blue\/white mixed.<\/p>\n<h2 id=\"theDemo\">The Demo!<\/h2>\n<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/nmdvhgbsglQ?version=3&#038;rel=0&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span>And if video isn\u2019t your thing, you don\u2019t want to build it and you don\u2019t believe me that it is doing at least\u00a0640 pixels\u00a0(don\u2019t feel bad, my wife didn\u2019t believe me at first, either), here\u2019s a full screen capture off my SLR.<\/p>\n<p>Each band is\u00a08 colors \u2013 black, white, red, green, blue, yellow, cyan and purple.\u00a0 Remember, each pixel by definition can only hold\u00a0one color \u2013 I explicitly draw a new color in each pixel.\u00a0 So pick a color (say, red \u2013 that\u00a0one is easy to\u00a0see), count it, then\u00a0multiply by 8:<\/p>\n<div class=\"wp-caption aligncenter\" id=\"attachment_7073\"><a href=\"http:\/\/dqydj.net\/wp-content\/uploads\/2014\/06\/fullcrop.jpg\"><img loading=\"lazy\" decoding=\"async\" alt=\"Full crop of color bars from an Arduino\" class=\"size-medium wp-image-7073\" height=\"47\" src=\"http:\/\/dqydj.net\/wp-content\/uploads\/2014\/06\/fullcrop-300x47.jpg\" width=\"300\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Full crop of color bars from an Arduino (Click for full width)<\/p>\n<\/div>\n<p>If you\u00a0<em>still<\/em>\u00a0don\u2019t believe me (you must be fun at parties!),\u00a0<a href=\"http:\/\/www.atmel.com\/images\/doc0856.pdf\">pop up the AVR 8-bit instruction listing<\/a>.\u00a0 Search for the \u2018OUT\u2019 instruction.\u00a0 Note that it is a\u00a0one clock instruction\u00a0(16\u00a0MHz).\u00a0 Note that we treat\u00a0<em>each<\/em>\u00a0\u2018OUT\u2019 as\u00a02 pixels using our\u00a0external hardware\u00a0(2x16MHz\u00a0=\u00a032\u00a0MHz,\u00a0which is more\u00a0than 25.175), so if you look at the assembly generated by our code it looks like a whole bunch of this:<\/p>\n<ul>\n<li>\u00a0 \/\/ PORTD = B01010100; &lt;\u2014\u00a0010 Green on one\u00a0pixel, 110 Yellow on the\u00a0one next to it<br \/>\u00a04c2:\u00a0\u00a0 \u00a09b b9\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0out\u00a0\u00a0 \u00a00x0b, r25\u00a0\u00a0 \u00a0; 11<\/li>\n<\/ul>\n<h2>Your Turn!<\/h2>\n<p>So, now, go have fun with the code and the schematic!\u00a0 It\u2019s released with the same license as\u00a0<a href=\"http:\/\/www.gammon.com.au\/forum\/?id=11608\">Nick Gammon\u2019s VGA code<\/a>, so go out and make something more interesting than a poorly sampled digital signage display which shows a rainbow, then come back and share!<\/p>\n<\/div>\n<\/blockquote>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>fyprocessing: How to Produce 640\u00d7480 Color VGA Video From an 8-Bit Arduino! &#8211; Don&rsquo;t Quit Your Day Job&hellip; enki2: With a minimum of external hardware, I demonstrate how to get 640&#215;480 out of an Arduino! For the advanced reader, I present a theory of how to improve further. How to Produce 640\u00d7480 Color VGA Video [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[1537],"class_list":["post-40644","post","type-post","status-publish","format-standard","hentry","tag-critical-toys"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6PWot-azy","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/posts\/40644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/comments?post=40644"}],"version-history":[{"count":0,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/posts\/40644\/revisions"}],"wp:attachment":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/media?parent=40644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/categories?post=40644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/tags?post=40644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}