VGA Connector Pin Information: The pinout for a standard 15-pin VGA-out connector is as follows: Video card side (female socket): /----------------------------------------------\ \ 5 4 3 2 1 / \ / \ 10 9 8 7 6 / \ / \ 15 14 13 12 11 / \------------------------------------/ Monitor side (male plug): /----------------------------------------------\ \ 1 2 3 4 5 / \ / \ 6 7 8 9 10 / \ / \ 11 12 13 14 15 / \------------------------------------/ 1: Red Video (To monitor from video card) 2: Green Video (To monitor from video card) 3: Blue Video (To monitor from video card) 4: Monitor ID 2 (To video card from monitor) 5: TTL Ground (Monitor self-test, used for testing purposes only) 6: Red Analog Ground 7: Green Analog Ground 8: Blue Analog Ground 9: Key (Plugged hole, not used for electronic signals) 10: Sync Ground (For both sync pins) 11: Monitor ID 0 (To video card from monitor) 12: Monitor ID 1 (To video card from monitor) 13: Horizontal Sync (To monitor from video card) 14: Vertical Sync (To monitor from video card) 15: Monitor ID 3 (To video card from monitor) The most important pins on a monitor's connector are the synchronization, or sync pins. There are three: Horizontal, vertical, and ground. The sending of a horizontal sync pulse indicates the end of a horizontal line, and the sending of a vertical sync pulse indicates the end of a vertical screen frame. Each pulse on the horizontal pin creates one scanline across the screen. The vertical pin pulses only when a whole screenful has been drawn; a pulse from the vertical pin makes the monitor return to the upper-left corner of the screen and begin drawing the next frame. The horizontal sync pin pulses several thousand times per second, while the vertical sync pin usually pulses less than 100 times per second (depending on the monitor's vertical refresh rate). For example, on a monitor operating at 640 x 480 resolution with a 70 Hz refresh rate, the horizontal sync pin would be pulsing approximately 33,600 times per second, or 33.6 KHz (480 scanlines, 70 times per second), while the vertical sync pin would be pulsing, of course, 70 times per second. In order for any properly-aligned image to be displayed on a VGA monitor, the monitor must be connected on both pin 13 (horizontal sync or HSYNC) and pin 10 (sync ground). A proper horizontal sync signal is needed to align the image on the screen; without horizontal sync, the image will twist and deform and probably be unrecognizable. If pins 10 and 13 are connected but pin 14 (vertical sync or VSYNC) is not connected, the monitor can still display an image, but the image will scroll vertically at a rapid speed; the image will probably be recognizable and perhaps even usable, but certainly not stable. If all three of these sync pins are connected, then the image will be steady and displayed in the proper place on the screen. Note, however, that in order to be compliant with the VESA DPMS (Display Power Management Signalling) standard, a monitor must go into power-save mode when either the horizontal sync or vertical sync signal is not present. Most monitors today conform to VESA DMPS; older monitors which do not may still be able to display something even without these sync signals, but nearly every monitor manufactured after 1995 will turn itself off if either of the sync signals is absent, so you'll need an uncommonly old monitor if you want to experiment with what images look like in the absence of sync signals. On monitors which automatically go into power-saving mode when they receive no signal, connecting pins 13, 14, and 10 should be all that's needed to bring the monitor out of power-saving mode. Modern VGA monitors are "multisync" monitors, which means they can operate at more than one frequency. This is possible because they use two separate sync inputs, one for horizontal sync, one for vertical sync. Fixed-frequency monitors, as the name suggests, can run at only one refresh rate. They usually use "composite sync", a system in which only one sync pin exists. Since the number of horizontal lines needed to make a whole screen is always fixed, there is no need for two separate signals. Another popular sync scheme is "sync-on-green", in which a composite sync pulse is mixed with the green component of the video signal. On monitors which use sync-on-green, there are only the three color inputs and no sync pins at all. But multisync must use separate sync, meaning two separate physical sync pins. Sync-on-green systems usually use a -0.3 Vpp sync signal. Composite sync and multisync systems use normal digital TTL-level sync signals. In multisync VGA, the sync signals may be either negative or positive; this usually does not make much difference, although it depends on the individual monitor. Also note that when the electron beam moves from the right side of the screen to the left (during a horizontal sync pulse), or from the bottom of the screen to the top (during a vertical sync pulse), the brightness of the beam is suppressed so that it does not actually draw anything on the screen while it is re-positioning. This is sometimes known as "horizontal blanking" and "vertical blanking". Now we come to an interesting and somewhat awkward topic. You may have noticed that although VGA uses signals to indicate when a line has been drawn and when a screen (or frame) has been drawn, it does not have any mechanism for indicating when a pixel is complete. How, then, does the monitor know when the data for one pixel is received, and to go to the next pixel? The answer is simple: It doesn't. A timer known as the "pixel clock" is derived, from the two sync inputs, and this pixel clock divides the video signal into a line of individual pixels. On some video systems, the pixel clock is another signal (making for three sync signals), but on standard VGA computer monitors it is not sent separately, and so the monitor must synthesize its own pixel clock based on the rates of the sync inputs it receives from the video card. Multisync monitors (monitors made to work at multiple frequencies) are made to count the number of horizontal and vertical sync pulses per second and "guess" the correct video mode. This is why, when changing resolutions, a monitor will blank out for a few seconds before the picture comes back; since the monitor doesn't know what resolution it has just changed to, it needs a moment to monitor the sync rates and try to figure it out. Once the monitor has figured out what resolution and sync rate it is running at, it will also try to figure out what rate it will draw pixels at. The time period during which the video signal is used to create a pixel is known as the "pixel period". The only other really important pins on a VGA monitor are the three pairs of color pins. These pins carry the info for each color on the screen. They are analog signals, meaning that their voltage is significant (they are not just "on" or "off", as digital signals are). The higher the voltage for these analog signals, the brighter their colors will be for the pixel currently being projected on the screen. On a VGA connector, pins 1, 2, and 3 are only 0.7 volts maximum. (More specifically, they are analog 0.7 volt positive signals with a 75-ohm load at each end of the circuit in the video card and monitor.) In other words, if all three of these pins are at 0.7 volts, the monitor will display the brightest white it can display. All other pins on a VGA connector are TTL-level signals, meaning 5 volts. There is a great deal of confusion, and a great lack of real information, on what format the VGA color signals actually have. Although many people understand that these signals are 0.7 volts, some people seem to be under the impression that the video signals are waves (in other words, that the signals must be constantly changing, and cannot simply be a constant voltage). This is simply not true; it is possible to put 0.7 volts DC (direct current, meaning a constant, unwavering 0.7 volts, rather than a wave) on a color wire to create the maximum brightness for that wire's color. While this is quite useless for drawing a real picture (unless the picture is all just one color), it does make it easy to create a test circuit which turns a monitor's screen all one color to see if it works. Note, however, that some monitors will not work correctly if all three color wires are not brought to zero volts outside of the visible video area. Some monitors expect that while either of the sync signals is active, the color signals should be at zero. Other monitors don't care and will work fine even if the three color pins are not at zero volts. This is something to consider if you're going to make a simple test circuit in which one color is "on" all the time; your monitor may require you to suppress the color signal while sync pulses are active. In fact, most monitors today require this. Keeping the color signals on during sync pulses may simply result in a blank screen. The "monitor ID" pins are used by the video card to determine what type of monitor is connected, for example whether it is multisync or not. Today, Plug-and-Play (PnP) signals are sent over these pins, and thus the computer can detect whether the monitor is PnP, and if so, what type of monitor it is. The typical procedure for creating one line on a VGA monitor is as follows: 1. Disable the horizontal sync signal. 2. Send the "back porch" on the video channels. 3. Send the actual active video on the video channels. 4. Send the "front potch" on the video channels. 5. Enable the horizontal sync signal. 6. Wait a set period of time (during which the electron beam slides back to the left side of the screen), and repeat, going back to step 1. The two "porches" are times when no video data is transmitted. This creates the black areas on each side of the monitor's screen, and allows some margin of error with regard to centering the image on the screen. The back porch is the portion of the video signal which comes between the end of the horizontal sync pulse and the actual video. The front porch comes between the end of the actual video and the horizontal sync pulse. Fundamentally, it seems like you could calculate the speed of the pixel clock using a simple formula: The number of pixels is the multiplication of the resolution (for example, at 640 x 480 resolution, there are 307,200 pixels), and since each of those pixels is drawn a certain number of times per second (whatever the vertical refresh rate is), you should be able to multiply that number by the vertical refresh rate. For example, at 640 x 480 resolution with a vertical refresh rate of 60, the pixel clock seems like it would be 640 x 480 x 60 = 18,432,000 cycles per second, or 18.432 MHz. Although this calculation is basically correct, it neglects to consider the time used to send the "porches", as well as the time used up during the sync pulses. According to the VGA standard, for each line of 640 x 480 VGA video, 40 cycles of the pixel clock are used for the back porch, 8 cycles are used for the black left border of the picture, then come the 640 cycles for the actual pixels of the video, followed by 8 cycles for the black right border, 8 cycles for the back porch, and a final 96 cycles during which the horizontal sync signal is active. That's a total of 800 cycles of the pixel clock for one line of 640 x 480 video. Similarly, when the entire screen is being drawn, the VGA standard for 640 x 480 resolution specifies 25 entire lines of time devoted to a back porch, 8 lines for the black top border, the 480 lines of video, 8 lines for the black bottom border, 2 lines for a front porch, and 2 lines during which the vertical sync pulse is active. That's a total of 525 lines of pixel clock time. The result is that you have 800 cycles of pixel clock time for each line, multiplied by 525 for each re-draw of the screen, giving you a total of 420,000 pulses of the pixel clock for each screen refresh. Assuming the basic refresh rate of 60 hertz, then, the pixel clock speed for 640 x 480 VGA at 60 hertz is 25,200,000 cycles per second, or 25.2 MHz. (Although most references insist that the correct speed is actually 25.175 MHz, to be precise.) If you're going to make a circuit to generate a VGA signal and drive a VGA monitor, it probably makes sense to create your own square-wave oscillator as part of the circuit. This oscillator will become the pixel clock. Each pixel of the VGA picture will be sent on the video wires for one cycle of the pixel clock. You can also use the pixel clock to time the lengths of the horizontal and vertical sync pulses, as well as the "porch" portions of the video. There exist quartz crystal oscillators made in the basic VGA speed of 25.175 MHz, and you can buy them online from mail-order giant Digi-Key. (Curiously, Jameco does not seem to sell them in that speed.) Some FPGA development boards even come with a 25.175 MHz oscillator built into the board, so that you can directly use it to drive an FPGA-controlled VGA system. Commercial-quality video cards need to be able to produce pixel clocks of many different speeds, since they need to be able to run in several different resolutions and refresh rates. These cards typically do not use crystals to synthesize all their pixel clocks, since it would require having several different crystals soldered to the surface of the board (although some older micros did indeed derive their pixel clocks by having several crystals on-board, one for each video mode). Modern video cards will usually derive their pixel clock from some division of the system clock or some other means, but for a simple home-made video controller which will not run in several different video modes, the use of quartz crystals to drive the pixel clock is a relatively simple and acceptable solution. Once you have your pixel clock established and running as an oscillator, it's not too complicated to have all the other signals controlled by it. The sync pulses will be active for a set number of clock cycles, and when the actual video is being sent to the screen, each cycle of the pixel clock will create a transition to the color levels for the next pixel. If you just want to generate the horizontal and vertical sync pulses to see how a monitor deals with them, you don't need to create a pixel clock. You could theoretically create the sync pulses with just a 555 chip, but that's not recommended, because although you could probably get pretty close to the right frequency with a 555, the duty cycle of the sync pulses is also important. Typically, a 555's output is on about half of the time, and off about half of the time; a video sync pulse is actually inactive most of the time, and only active for a very short period of time. Basically, in short: Don't use a 555 to generate VGA sync pulses. It's just not precise enough. Unless you make one yourself, you will probably have a hard time finding a 0.7-volt power supply for the RGB pins. Generally, power supplies with voltage ratings under 1.5 volts are uncommon, and the standard typical rating for an electronics power supply is 5 volts. The simplest way to solve this problem is by creating a 0.7-volt feed using a two-resistor voltage divider. For those who are not familiar with this concept, it will now be explained. A voltage divider is a very simple circuit that uses two resistors to create a voltage lower than the voltage being supplied from the power source. Visually, a voltage divider is constructed as follows: Connect one side of one resistor to the positive side of the power supply, and connect one side of another resistor to the negative side of the power supply. Join the two free ends of the resistors together, and the point where they meet has a lower voltage than what is being produced by the power supply. The formula to calculate the voltage produced by a voltage divider is as follows: (V * R1) / (R1 + R2) ...Where V is the voltage of the power source, R1 is the resistance of the resistor connected to the negative side of the power supply (in ohms), and R2 is the resistance of the resistor connected to the positive side of the power supply (also in ohms). This formula works proportionally. If the two resistors have equal values, then the resultant voltage will be exactly half of the source voltage. For example, if the source voltage is 5 volts, R1 is 1,000 ohms, and R2 is also 1,000 ohms, then the resultant voltage will be 2.5 volts. This will not change no matter what the values of R1 and R2 are, as long as they stay the same. You could increase them to 10,000 ohms, 100,000 ohms, or even one million ohms, but as long as the two resistors have the same resistance, the output will be 2.5 volts. If R2 is four times as resistant as R1, then the resultant voltage will be one-fifth of the source voltage, because R1 is one-fifth of the total resistance of the two resistors. For example, if the source voltage is 5 volts, R1 is 500 ohms, and R2 is 2,000 ohms, then the resultant voltage will be 1 volt, because the total resistance is 2,500 ohms, and R1 is one-fifth of that. (Note that this somewhat simplified explanation assumes the "ground" side of the power supply is the negative side.) Using this formula with a 5-volt power supply, you can easily make 0.7 volts with a 700-ohm resistor and a 4,300-ohm resistor. Unfortunately, although 4,300 ohms is a standard value of resistor, 700 ohms is not, so use the closest value you can find; 680 ohms and 750 ohms are the closest standard resistor values. Pick a point in your circuit workspace (let's call this point "Tom", just because we can). Connect the 4,300-ohm resistor from the positive side of your power supply to Tom. Connect the 700-ish-ohm resistor from the negative (ground) side of your power supply to Tom. Now Tom should be at +0.7 volts, and you can use Tom as a power source for your VGA RGB signals. There is an additional complication with this two-resistor voltage divider solution, however: Because the resistors are in the way of the current, you may not be able to produce enough current to drive the RGB wires the way the monitor wants them. Remember, the color signals are only supposed to have an impedance of 75 ohms on each end! Although you could fiddle with different resistor values for the voltage divider, the proper solution to this problem is to use a simple current amplifier (also known as a power amplifier), which is an amplifier which doesn't amplify voltage, but simply increases how much current is available. A relatively simple device to use for this purpose is a bipolar transistor. In fact, a bipolar transistor is fundamentally a current amplifier, and nothing more. Bipolar transistors can be used for many other purposes as well, but in their most basic configuration, they really serve no more purpose than to take some low-current input voltage, and supply a high-current power supply of the same voltage. To use a bipolar transistor for this purpose, select a basic NPN bipolar transistor and connect your 0.7-volt point to the base of the transistor. This sets the base voltage, and ensures that the emitter on the transistor will be close to that voltage. All that you need to do, then, is connect the collector of the transistor directly to the positive side of your power supply, and voila! The emitter of the transistor will be constrained to the voltage applied to the base, but the emitter will still be able to draw a lot of current through the collector. There is *another* complication to this solution, however: The transistor drops a little bit of voltage over the base-emitter junction, meaning the emitter will be SLIGHTLY lower in voltage than the base. Exactly how much this voltage drop is will depend on the transistor itself, but the drop is usually in the range of 0.3 volts to 0.7 volts. This is normally not a huge design consideration, because even when using relatively low voltages like 5 volts, a drop down to 4.3 volts or so isn't a huge deal. However, we are working with a signal that is 0.7 volts maximum! You could theoretically drop your ENTIRE voltage across the transistor. What this means is that you will have to actually increase the voltage coming out of your voltage divider slightly, to perhaps 1.0 volts, or maybe as much as 1.5 volts. If you start doing something like this, however, make sure that you use a voltmeter to check exactly how much voltage is on the transistor's emitter BEFORE you connect it to any monitor inputs. Remember, the RGB inputs are supposed to be 0.7 volts MAXIMUM, and going over this level is quite liable to permanently damage the monitor. Ensure that you have a good voltage that is no higher than 0.7 volts before you feed it into your monitor. If you intend to do any electronic work with VGA, I recommend you get a D-Sub High-Density 15-pin to Dual Inline Package (HD-15 to DIP) adapter, which will allow you to use a monitor plug as if it were a simple DIP chip. Some companies may make HD-15 to PCB (printed circuit board) mount adapters, but an HD-15 to DIP adapter is better because you can use it with a breadboard. I only know of one company which makes such an adapter: Technological Arts (www.technologicalarts.com), which makes a VGA-to-DIP adapter under the part number ADHD15S (the AD means it's an adapter, the HD represents high-density D-Sub connector, the 15 is the number of pins, and the S indicates it's a socket, i.e. a female rather than a male connector) for a straight-through adapter, or ADHD15S-RA for a right-angle adapter. If you wish to prove that the VGA color signals can in fact be DC (i.e. not waves), here is a very simple way to do it. First, connect pins 10, 13, and 14 from a video card to a monitor. This will produce the sync signals needed to keep the monitor's scan beam aligned (and, for most newer monitors, the signals needed to keep the monitor from going into power-save mode). Leave the rest of the video card's pins disconnected; you won't need them. Tie the monitor input cable's pin 6 to the ground of an external voltage source (this is the red ground pin). Using a voltage divider, create a source of about 0.7 volts (or slightly higher, since this will be dropped over a transistor). Then take an NPN transistor and connect the 0.7 volts to the base of the transistor so that the transistor's emitter will be at about 0.7 volts as well. Connect the emitter to pin 1 on the monitor (the red input). We will now attempt three things to get the monitor to turn red. The first is to simply connect the transistor's collector to the positive side of your power supply. If this does not work, it's because the voltage input is staying on constantly, and the monitor requires the color signal to only be on when the sync signals are inactive. There's an easy way to fix this, and it is the second thing to try: Connect the transistor's collector to pin 13 of the video card, the horizontal sync signal. The horizontal sync signal will always be inactive when color data is to be sent, so when the horizontal sync signal becomes inactive, this automatically triggers the sending of the color signal. If this still doesn't work, it's because the horizontal sync signal is of the wrong polarity (if this is the case, you'll probably see a thin vertical line of red at the right edge of the screen, where the color just starts to show before the sync signal takes effect and suppresses the red electron gun). To fix this, run the horizontal sync signal through a TTL inverter (also known as a NOT gate) before you connect it to the transistor's collector. Now your screen should turn all red, proving that a constant DC color signal is sufficient for VGA, as long as the color signal is suppressed during the sync signals. Now that we've looked at the general specification of how VGA works, let's create a specific VGA scenario. Suppose that we wanted to make a simple circuit which would set a VGA monitor to 640 x 480 VGA at 60 hertz, and turn the screen all red. Let's assume that we already have an oscillator circuit which is running at this video mode's frequency of 25.2 MHz. Bear in mind that in this video mode, one line of video actually uses 800 ticks of the pixel clock, and one screenful uses 525 lines of video time. To accomplish our goal, our routine of events would look like this: 1. Set both the horizontal and the vertical sync to 0 volts. Since these signals are active-low, this means that they will both be active, beginning the sync sequence. They should remain low for 1600 ticks of the pixel clock. This is two lines of video time, which is the length of time during which the vertical sync pulse should be active. During this time, also, all three of the color signals should be at 0 volts. 2. Set the vertical sync signal to 5 volts (logical high) to disable it. 2a. Since the vertical sync signal is now disabled, the vertical back porch begins. Set the horizontal sync signal high to disable it, and leave it disabled for 704 ticks of the pixel clock. Then, turn it on for 96 ticks. This adds up to one line of video. Perform this step 33 times, to allow for the vertical back porch and black top border. 3. When the horizontal sync signal goes high after the top black border is complete, the first line of active video begins. Wait 48 ticks of the pixel clock (to allow for the horizontal back porch and black left border), then set the red analog color input to 0.7 volts for 640 ticks of the pixel clock. After this, set the red input back to 0 volts, wait 16 ticks for the horizontal front porch and black right border, then set the horizontal sync line low for 96 ticks. Perform this step a total of 480 times to draw the 480 lines of video. 4. Now that the actual video has been sent, it's time for the vertical black bottom border and front porch. When the horizontal sync signal goes high again, wait for 704 ticks, then bring the horizontal sync low for 96 ticks. This is one blank line of video; perform this step 10 times, for the 10 lines of vertical front porch and bottom black border. 5. Return to step 1. Creating a relatively simple circuit to turn a VGA monitor all one color doesn't require that much digital logic. In fact, you can just use a couple of digital counter chips and count how many ticks of the pixel clock have occurred, then set the sync and color signals to respond to certain counts. This, again is only useful for making a monocolor rectangle out of the screen. For "real" image displays, you need circuitry that can say stuff like "at 250,000 ticks of the pixel clock (for example), set the green output to 0.45 volts". If you're pondering what kind of circuit might be needed to do that, you're now encountering the reason for programmable logic. True VGA controllers need specialized digital logic that can take image data, turn it into a stream of red, green, and blue values, and send those values as analog signals (through a digital-to-analog converter (DAC)) in sync with a couple of TTL synchronization signals, and do it all several times a second. Not only is the logic to do this a bit more involved, the circuitry needs to be quite fast (because the pixel clock is several megahertz), so the logic needs to be capable of sub-microsecond response times. That's no casual little circuit, but if you made a circuit to do that, you'd have a commercial-quality computer VGA video card.