Better VGA DAC resistors
Phil Pilgrim (PhiPi)
Posts: 23,514
I needed to make a VGA plug-in board for the Propeller Backpack, so I could render some captured video. I used 510-ohm resistors, paralleling where needed to get 255 ohms (vs. Parallax's usual 470/240 combo). In order to test it, I used Kye's excellent 160 x 120 VGA driver from the OBEX to create a test pattern. (Unlike the Propeller library drivers, Kye's worked out-of-the-box with my display. Yay, Kye!) I discovered that I was only getting three easily-discernible intensity levels, rather than the four I expected: %10 and %11 looked almost the same.
Checking the output with the scope showed a signal that's 1V P-P. But one volt is not right. The VGA spec requires 0V for black and 0.7V for maximum intensity. That's why %10 (0.75V) and %11 (1.00V) looked almost the same: both were above the maximum level. So I checked my Propeller Demo board and saw the same problem.
In order to come up with a minimally-invasive fix, I computed that a 100-ohm resistor from each of the RGB pins to ground would reduce the maximum output to just below 0.7V. A convenient place to add these resistors is between each color input pin on the DB-15 footprint and its associated Vss return connection. 0603 SMD resistors fit perfectly:
Here are the before and after pictures taken directly from the VGA screen:
Before the fix.
After the fix.
Here's a scope trace of one RGB channel after the fix:
The fix, although simple, is not perfect. The problem is that the output impedance (about 43 ohms) is wrong. It should be 75 ohms. (But, hey, the unmodified output impedance is 159 ohms, which is even further from optimum.) The optimum VGA DAC circuit (using 5% resistors) for each RGB pin is this:
It outputs 0.7V when both DAC pins are high and has a 75-ohm output impedance. If Parallax wanted to correct the output voltage (but not the impedance) without changing the PCB layout to add the loading resistors, the best 5% DAC resistors would be 820R and 430R, instead of 470R and 240R.
-Phil
Checking the output with the scope showed a signal that's 1V P-P. But one volt is not right. The VGA spec requires 0V for black and 0.7V for maximum intensity. That's why %10 (0.75V) and %11 (1.00V) looked almost the same: both were above the maximum level. So I checked my Propeller Demo board and saw the same problem.
In order to come up with a minimally-invasive fix, I computed that a 100-ohm resistor from each of the RGB pins to ground would reduce the maximum output to just below 0.7V. A convenient place to add these resistors is between each color input pin on the DB-15 footprint and its associated Vss return connection. 0603 SMD resistors fit perfectly:
Here are the before and after pictures taken directly from the VGA screen:
Before the fix.
After the fix.
Here's a scope trace of one RGB channel after the fix:
The fix, although simple, is not perfect. The problem is that the output impedance (about 43 ohms) is wrong. It should be 75 ohms. (But, hey, the unmodified output impedance is 159 ohms, which is even further from optimum.) The optimum VGA DAC circuit (using 5% resistors) for each RGB pin is this:
It outputs 0.7V when both DAC pins are high and has a 75-ohm output impedance. If Parallax wanted to correct the output voltage (but not the impedance) without changing the PCB layout to add the loading resistors, the best 5% DAC resistors would be 820R and 430R, instead of 470R and 240R.
-Phil
Comments
From what I understand, the series resistors for H & V sync are not that important, so would 820R for VS and 430R for HS be acceptable? If so, this would make an ideal solution for 3 smt quad resistor packs [EMAIL="4@820R,"]4@820R,[/EMAIL] [EMAIL="4@430R"]4@430R[/EMAIL] and [EMAIL="3@130R"]3@130R[/EMAIL].
I already have provision for your 191R termination resistors on my TV (composite video) pcbs. I shall add these changes to any new VGA pcbs I do.
-Phil
-Phil
Can you please post a complete schematic (I take it there are 3 resistors now for each pin - how many resistors now in total?). I can change this easily on the next revision of the dracblade.
-Phil
The net effect of this is to shrink those external resistor values back towards 240 and 470 ohms, since "27 ohms of each resistor is internal to the prop".
This may help explain why your CRO picture is reading "under". While the auto measure shows 676 mV I think its including the noise spikes rather than the "average baseline" of the high and low plateaus. By my eye I make it more like 3.25~3.3 divs or 650~660 mv. Calcs based on a 27 ohm internal resistance (297||537) into (130||75) yields an estimate 658mV peak, and an effective source impedance of 77.4 ohms.
I agree for linearity you want to aim just under 0.7 volts, including a small margin for resistor tolerances (1% resistors? or more margin for 5%?)
The scope trace was from 510||255 driving 100||75 (i.e. the quick fix), which computes to 0.664V without considering the 27 ohms. Adding in the 27 ohms (i.e. 537||282 into 100||75) results in 0.621V, which is lower than the scope trace would indicate. So the effective internal resistance must be somewhat less than 27 ohms and is probably current-sensitive.
-Phil
(edit: the above measurements are for a Vdd around 3.3v, the usual case).
"PNP drive mode" (resistor load to ground), Vdd = 3.28v
Rext = 150 ohms, measured 150 ohms. Vext = 2.768v / 150 = 18.45mA. Rint = 0.515v / 18.45mA = 27.9 ohms
Rext = 470 ohms, measured 470 ohms, Vext = 3.104v / 470 = 6.60mA. Rint = 0.1795v / 6.6mA = 27.2 ohms
Rext = 1000 ohms, measured 1002 ohms, Vext = 3.198v /1002=3.198ma Rint = .0857v / 3.198ma = 26.8 ohms
Rext = 10kohms, measured 9.98 kohms, Vext = 3.27v/9980 = .327mA. Rint = .0093/.000327 = 28.4 ohms <-- relatively large error possible due to low mV reading
"PNP drive mode" (resistor load to small signal diode (0.71v node) then to ground), Vdd = 3.28v
Rext = 243 ohms, measured 240 ohms, Vext = 2.301v / 240 = 9.59mA. Rint = 0.262v/9.59mA = 27.3 ohms <-- this setup is closest to VGA driving
"NPN drive mode" (resistor load to Vdd), Vdd=3.28v
Rext = 150 ohms, (same 150 ohms). Vext = 2.761v/150 = 18.41mA. Rint = 0.523 / 18.41mA = 28.4 ohms
Rext = 470 ohms, (same 470 ohms), Vext = 3.097v/470 = 6.59mA. Rint = .1875/ 6.59mA = 28.4 ohms
The only real advantage to using 5% is you can read the color code easier (or text if smt)
-Phil
This is probably a stupid question, but in post #7 the green inputs are labeled as going to the red output. Is this right?
Also, the color charts that you showed could just indicate that you need to adjust the contrast and brightness for the monitor. Did you take readings on other monitors as well?
I'll have to redo the math later today to come up with the 1% values.
prof_braino,
Funny how errors propagate when you copy and paste! Yes, green goes to green. Thanks for catching it.
Peter,
Adjusting the brightness and contrast was the first thing I tried -- to no avail. But specs are specs. The VGA spec calls for 0.7V max into a 75-ohm load, and Parallax's circuit pushes 1.0V with a 150-ohm source impedance. Granted, there are differences among monitors, but the best way to accommodate most of them is to get the signal right to start with. That's why I created this thread. Think of it this way:
1. The monitor showed symptoms that it was saturating (i.e. being over-driven).
2. Checking with the scope confirmed that the output was too high.
3. Parallax's circuit was fixed so output was in spec.
4. Saturation symptoms disappeared.
Science doesn't get any cleaner than that!
-Phil
However, I hate using discrete resistors and especially all those different values as I much prefer resnets. if you use 270R resnets you could end up with this:
-Phil
*Well, exact if you disregard the Prop's internal resistance. (I don't want Tubular to think I'm ignoring him. )
Perish the thought, lol.
There's something else... the middle step on your CRO image is less than a division, so less than 1/3 of the full 3.3ish divisions of the full amplitude. The internal resistance may help explain this. But looking at your capture images, if anything I'd be saying the jump from 01 to 10 is *more* than 1/3, especially for the green channel. But that could be the LCD at my end too, and so it goes on.
At the end of the day, "what looks good/sounds good/works best with my equipment" certainly has some validity, we've seen that with the C3 audio discussion. But its good to understand the science thoroughly too*
* there is an excellent chance I will trip myself up with this statement
I think you're over-analyzing things. The color test patterns are photographs taken with a digicam from a VGA screen (with who-knows-what-kind of gamma correction in place) in subdued lighting with the camera's lowest EV setting, then rendered as jpegs without dealing with the visible Moire interference. <understatement>There is likely to be some non-linearity introduced by this process.</understatement> But that does not compromise the main thrust of this thread, since the resistor mods produced a significant visible improvement in the linearity.
-Phil
(Note that the net resistance to ground includes the 75-ohm load. The computed impedance is the output impedance.) It would be hard to ask for better linearity, maximum output, and impedance matching than that!
-Phil
vga_tv_resistors.xls
Attached is your spreadsheet with the analysis I originally did for the Propeller Backpack, which uses 4x430R resistor packs exclusively, and which analysis did not include consideration for the Prop's internal resistance. If you add the internal resistance, you also have to add it to the 215R ground resistor, since that gets pulled to ground by a Prop pin (A16) in the Backpack.
-Phil
I wonder if this may account for some problems people are having with some TV monitors?
-Phil
VGA is much better for a more even palette of colors.
Re the VGA colors, are these the correct resistors?
Per the spreadsheet results shown in post #24, I'd change your 270's to 240's.
-Phil