# Thread: Resistor values for 64 GreyScale VGA output from the Propeller

1. ## Resistor values for 64 GreyScale VGA output from the Propeller

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.

2. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

Nice work! Very useful for vision apps, as you noted.

3. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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...)

4. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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.

5. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

Nice work. With a little program to convert color to grayscale you should have some nice pictures. I'm looking forward to some screenshots

6. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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.

7. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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

8. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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?

9. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

Very nice job!

10. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

Originally Posted by Tubular
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!

11. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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

12. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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?

13. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

What's your pixel clock rate? That will be the determining factor.

-Phil

14. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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.

15. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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_R2...lation_en.html to figure these values out. Should be a big improvement over the 5 colors I'm using now.

Lawson

16. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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

17. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

I'd like to see a pick-and-place machine that could do that!

-Phil

18. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

Stonehenge, for the electrons.

19. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

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?).

20. ## Re: Resistor values for 64 GreyScale VGA output from the Propeller

Originally Posted by Lawson
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_R2...lation_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?