SHOWALL FUN PRANKS HIGH VOLTAGE LAZARUS-64 PHOTOGRAPHY SPY GADGETS VIDEO GAME
Figure 2 - Soldering the necessary signal and ground wires to the connector
Figure 2 - Soldering the necessary signal and ground wires to the connector

Once you have extracted your female VGA connector, find some solderless breadboard compatible wires and create the connections using the pin-out guide. As you can see, there are five signal wires and one ground wire. In actuality, there are five separate ground wires (pins 5, 6, 7, 8, 10), but because of the low clock rates we will be using here, they can all be joined together as a single ground wire. Multiple ground wires help reduce grounding loops in very high speed systems. There are also three analog color connections (pins 1, 2, 3) that tell the display how to mix the red, green and blue in order to create a single color pixel. The two synchronization connections (pins 13, 14) tell the display when to move the "beam" to the next line and next frame.

If you have never studied the VGA signal, then these five connections may seem incompatible with a typical microcontroller since three of them expect an analog voltage, but as will be shown soon, all you need is a few resistors and you can bit bang a very stable VGA image right from your software. I know...Why am I doing this when ICs like the Parallax Propeller can already generate VGA video? Simple. Because I like to exercise my grey matter, and it looks like magic when you pump out a VGA signal on a $2 microcontroller with only a few resistors connected! Yes, the cool factor always counts!



Figure 3 - An R2R resistor ladder will change digital signals into analog signals
Figure 3 - An R2R resistor ladder will change digital signals into analog signals

Ok, let's dig right in and convert the digital signals from the microcontroller into the analog and digital signals that the VGA monitor will expect. The good news is that both the horizontal sync and vertical sync lines are fully compatible with any 5 volt or 3.3 volt microcontroller, so they can be connected directly from your output pins to the VGA connector. The three analog color lines that generate the red, green, and blue intensities are not digital, and the monitor expects some voltage between 0 volts and .7 volts (or close) on these three lines. Because the color signals are analog, you can effectively create an infinite amount of different colors depending on how many steps you have in your analog voltages. Most modern VGA systems have 256 steps (8 bits) in each color, allowing 24 bits of color information, or 16,777,216 total colors. Because this basic system is powered by an 8 bit microcontroller, there will only be a single 8 bit port used to generate all three analog color lines, so the maximum amount of colors we can get is only 256. This is the same number of colors used by the early VGA systems, and is more than enough to show clear text, graphics, and photographic images.

Wait...three colors and 8 bits - the division does not work here! Correct. It was common to simply weigh the colors with one less bit on red or green to get a palette that would have something like eight shades of red (2 bits), four shades of green (3 bits), and eight shades of blue (3 bits). This arrangement, or "color space" is called RRGGGBBB, representing the number of bits in each color position. I spent a lot of time messing around with various eight color spaces, and did not like any of the unbalanced arrangements as it made images look strange, and made it difficult to convert graphics from a program like Photoshop. I found a way to make each color have 2 bits (four shades), but then have a global 2 bits of intensity that could work on the 6 bits of color. In other words...four levels of 64 colors to make a nice even 256 color palette.

As shown in the image, each color has two resistors feeding it, creating a simple 2 bit digital to analog converter (DAC) that gives four levels of that color. Since each color has its own 2 bit DAC, there are a total of 64 possible colors (6 bits). The last two bits are connected to three more 2 bit DACS, which then feed the three colors, giving another 2 bits of intensity to each color. So now every group of 64 colors has its own four levels of intensity, giving a colors space of RRGGBBII. The diodes are necessary so that the individual 2 bit DACs do not feed back into each other, as this would mix the colors in an odd way. This simple RRGGBBII DAC is very easy to calculate in software, and makes conversion from Photoshop to data statements very easy to do in a simple language like Visual Basic.

Back Home Last Next
You are Viewing... Page 2 of 16
Lucid Science Electronics from the Fringe AtomicZombie Hack-a-day SparkFun