Resistor values for 64 GreyScale VGA output from the Propeller — Parallax Forums

# Resistor values for 64 GreyScale VGA output from the Propeller

Posts: 4,404
edited 2012-07-31 23:00
The Propeller's VGA output typically outputs 6 bits of colour (RrGgBb) plus two sync signals on an 8 bit "port". Using two resistors per colour, the Red, Green, Blue video signals can each have one of four levels, giving 64 possible colours, but only 4 true grey scales (Black, Dark Grey, Light Grey, White).

For some applications (photographic, video processing) it is more desirable to use the 6 bits available purely for intensity. The result is a smooth 64 levels of grey.

The resistor ladder connected to the 6 output pins is a sequence of doubling resistors - R, 2R, 4R, 8R, 16R and 32R.

Since the Red, Green and Blue signals are tied together to always make 'grey', the 'loading' impedance is 25 ohms, rather than the usual 75 ohms for separate signals.

CALCULATING THE EQUIVALENT RESISTANCE REQUIRED TO GET THE CORRECT VIDEO LEVEL

VGA standard expects a 0.7 volt peak signal for "full on" (white). Since the r,g and b are tied together to make 'grey' the 'loading' impedance is 25ohms, rather than 75 ohms.
Prop with all 6 pins on (3.3v) ---/\/\Requiv\/\/---x---/\/\25\/\/----GND
We want 0.7 volts at node 'x' when all 6 bits are on (3.3v)
0.7=3.3*(25/(25+Requiv))
117.86 = 25 + Requiv
Requiv = 92.86 ohms

CALCULATING THE ELEMENTS OF THE LADDER ("R")

Requiv is the equivalent resistance of the overall 6 pin network, using the formula for resistors in parallel:-
Requiv = 1/(1/R + 1/2R + 1/4R + 1/8R + 1/16R + 1/32R)
Requiv = 32R/63
R = 182.81 ohms

PRACTICAL E12 RESISTOR VALUES

We know the equivalent resistance required, but what about the individual values that make up the R~32R ladder? What resistors can we use to achieve a close to ideal result? Incorporating the ~ 27 ohm internal Propeller FET resistance,
P23: R = 182.8125 ohms - less 27 ohms internal - use 154 ohms
P22: 2R = 365.63 - use 340 ohms
P21: 4R = 731.25 - use 698 ohms
P20: 8R = 1462.5 - use 1430 ohms
P19: 16R = 2925 - use 2870 ohms
P18: 32R = 5850 - use 5760 ohms
P17: use 220ohms as usual (sync)
P16: use 220ohms as usual (sync)

CHECKING THE PROPOSED RESISTOR VALUES

Using the above "practical" values, the resultant equivalent resistance is 91.9 ohms. The peak voltage level would therefore be 3.3*(25/(25+91.9)) = 0.706 volts peak.

TEST CODE

The following code is based on Kye's 160x120 6 bit per pixel VGA driver. The engine stays the same, the intensity of each byte is (greyscale) Ggggggxx instead of RrGgBbxx.

• Posts: 6,445
edited 2011-05-12 06:10
Nice work! Very useful for vision apps, as you noted.
• Posts: 4,404
edited 2011-05-12 15:29
Thanks Bill.

The other thing it could do well, would be view avatars... should the world ever need that!

(I was trying to think what else is around the 160*120 pixels in native format...)
• Posts: 4,404
edited 2011-07-10 18:29
This theory needs to be ammended to allow for the driving impedance of the prop (about 27 ohms I think). Essentially each driving resistor needs its value lowered by 27 ohms.

I'll amend it once I have a bit more of an idea about the range of output impedances across a few prop chips. The 27 ohm estimate is based on measuring just one device at 3.3v.
• Posts: 5,484
edited 2011-07-10 21:24
Nice work. With a little program to convert color to grayscale you should have some nice pictures. I'm looking forward to some screenshots
• Posts: 2,027
edited 2011-07-10 22:41
It's 06:35 here, I'm at "work", and I was also here 8 hours ago. My bleary eyed thoughts are ruminating on whether Gamma curves should be taken into account.
• Posts: 253
edited 2011-07-11 07:12
I have often mused about VGA grey scale too, but my approach would be to try the Duty DAC idea used on the 1PinTv code.

You could try it on just green for a retro monitor, or tie RGB together to get greyscale.

Or use two cogs to drive RGB separately and do a 16bit color driver.

....Perry
• Posts: 4,404
edited 2011-07-11 07:53
Drac, yep should have some screenshots soon. Short movie clips may also be possible using the dataflash (~200 frames?)

Toby, Hmmm. Not sure if gamma can be easily corrected in the hardware domain. Think it must be a software problem...

Perry, I'd be very interested to see how well that might work. But how many levels might you get given the pixel clock requirements of vga?
• Posts: 2,200
edited 2011-07-11 08:13
Very nice job!
• Posts: 253
edited 2011-07-11 08:21
Tubular wrote: »
Perry, I'd be very interested to see how well that might work. But how many levels might you get given the pixel clock requirements of vga?

There are no clock requirements, instead of setting outputs to resistors you set the frequency of a "Duty DAC" you should be able to go over 255 grey scales if you use words!
• Posts: 23,045
edited 2011-07-11 08:43
The problem with DUTY mode output is that it has to be low-pass filtered to produce an analog voltage. The DUTY transitions occur every 12.5ns with an 80 MHz clock. One VGA pixel at, say, a 25 MHz dot clock lasts only 40ns. That's only 3.2 DUTY transitions, or enough for three gray levels. 64 transitions -- enough for six bits of gray-level data, requires 800ns, which spans (i.e. smears out over, when filtered) 20 horizontal pixels.

The reason the "DUTY gray" technique works with NTSC output is that each pixel lasts longer, so the output can be more aggressively filtered without producing horizontal smearing.

-Phil
• Posts: 4,404
edited 2011-07-11 14:37
I guess we're only using 160 horizontal pixels, so 160ns/transitions?

It might be that a duty approach combined with a multi pin resistor DAC may extend the number of perceived levels and smooth out the greys?
• Posts: 23,045
edited 2011-07-11 14:42
What's your pixel clock rate? That will be the determining factor.

-Phil
• Posts: 4,404
edited 2012-01-16 15:26
I updated the top post with the 1% resistor values I'm actually using. These values factor in the 27 ohm internal prop fet resistances.
• Posts: 870
edited 2012-02-21 16:18
I'll be testing this tomorrow with a R-2R networking using 91 ohm and 160 ohm (187ohm with pin resistance included) resistors. I used http://www.brischalle.de/JDAC/DAC_R2R_network_calculation_en.html to figure these values out. Should be a big improvement over the 5 colors I'm using now.

Lawson
• Posts: 870
edited 2012-02-22 22:43
Well the Proto-board modification worked exactly as planned. Everything would have fit better if I had found 0805 size resistors in the correct values, but 1206 size still worked fine. (see the attached picture) I also found out that the buzzer conductivity test mode of my multi-meter shows 0.000 resistance for >700ohms. Note to self, don't use the buzzer conductivity mode to double check solder joints on resistor sculptures

Lawson
• Posts: 23,045
edited 2012-02-22 22:55
I'd like to see a pick-and-place machine that could do that!

-Phil
• Posts: 2,027
edited 2012-02-22 23:55
Stonehenge, for the electrons.
• Posts: 4,404
edited 2012-02-23 02:45
Love it... i'd heard of air cored inductors before, but not resistor networks.

Bourns make R2R networks in SIP format, not sure if they go quite low enough however (100 ohms min?).
• Posts: 8
edited 2012-07-31 15:17
Lawson wrote: »
I'll be testing this tomorrow with a R-2R networking using 91 ohm and 160 ohm (187ohm with pin resistance included) resistors. I used http://www.brischalle.de/JDAC/DAC_R2R_network_calculation_en.html to figure these values out. Should be a big improvement over the 5 colors I'm using now.

Lawson

What did you fill in for RL and how did you hook it up to the vga port?
• Posts: 870
edited 2012-07-31 22:36
I filled in 25 ohms for RL as that's the resistance of three 75 ohm transmission lines driven in parallel. I hooked it up by connecting the red green and blue VGA lines where RL is in the schematic from the link. ( while the connection is mostly hidden, you can see this connection loop from the left of my "resistor henge" back to the three pads that go to the RGB signals.)

Lawson
• Posts: 1,049
edited 2012-07-31 23:00
Duty doesn't work with lcd. It samples and holds the signal. When I tried to generate 50% gray with duty signal I got all white, or all black, or strange black and white moving vertical strips, or all of these changing from time to time.