Welcome to the Parallax Discussion Forums, sign-up to participate.

# Resistor values for 64 GreyScale VGA output from the Propeller

Posts: 2,713
edited July 2012
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,419
edited May 2011
Nice work! Very useful for vision apps, as you noted.
www.mikronauts.com / E-mail: mikronauts _at_ gmail _dot_ com / @Mikronauts on Twitter
RoboPi: The most advanced Robot controller for the Raspberry Pi (Propeller based)
• Posts: 2,713
edited May 2011
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: 2,713
edited July 2011
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,479
edited July 2011
Nice work. With a little program to convert color to grayscale you should have some nice pictures. I'm looking forward to some screenshots :)
Answers: 1) A quadcopter. 2) Very high. 3) The internet. 4) A lot. 5) No.
• Posts: 2,009
edited July 2011
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 July 2011
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: 2,713
edited July 2011
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 July 2011
Very nice job!
Nyamekye,
• Posts: 253
edited July 2011
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: 20,602
edited July 2011
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
Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away.

-Antoine de Saint-Exupery

We had many discussions at the galley table and there had been many honest attempts to understand each other's thinking. There are several kinds of reception possible. There is the mind which lies in wait with traps for flaws, so set that it may miss, though not grasping it, a soundness. There is a second which is not reception at all, but blind flight because of laziness, or because some pattern is disturbed by the processes of the discussion. The best reception of all is that which is easy and relaxed, which says in effect, "Let me absorb this thing. Let me try to understand it without private barriers. When I have understood what you are saying, only then will I subject it to my own scrutiny and my own criticism."  This is the finest of all critical approaches and the rarest.

The smallest and meanest of all is that which, being frightened or outraged by thinking outside or beyond its pattern, revenges itself senselessly; leaps on a misspelled word or a mispronunciation, drags tricky definition in by the scruff of the neck, and, ranging like a small unpleasant dog, rags and tears the structure to shreds.

-John Steinbeck, The Log from the Sea of Cortez
• Posts: 2,713
edited July 2011
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: 20,602
edited July 2011
What's your pixel clock rate? That will be the determining factor.

-Phil
Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away.

-Antoine de Saint-Exupery

We had many discussions at the galley table and there had been many honest attempts to understand each other's thinking. There are several kinds of reception possible. There is the mind which lies in wait with traps for flaws, so set that it may miss, though not grasping it, a soundness. There is a second which is not reception at all, but blind flight because of laziness, or because some pattern is disturbed by the processes of the discussion. The best reception of all is that which is easy and relaxed, which says in effect, "Let me absorb this thing. Let me try to understand it without private barriers. When I have understood what you are saying, only then will I subject it to my own scrutiny and my own criticism."  This is the finest of all critical approaches and the rarest.

The smallest and meanest of all is that which, being frightened or outraged by thinking outside or beyond its pattern, revenges itself senselessly; leaps on a misspelled word or a mispronunciation, drags tricky definition in by the scruff of the neck, and, ranging like a small unpleasant dog, rags and tears the structure to shreds.

-John Steinbeck, The Log from the Sea of Cortez
• Posts: 2,713
edited January 2012
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 February 2012
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
micro-power experiments with the propeller.
Drivers for TAOS TSL3301 line sensor Forum thread, and OBEX
Lumen Electronic Jewelery Website
My AWD motorcycle Website and action video
What I'm paid to work on. UW Lidar Group.
FME, a Spin-only floating point library with trig, exponential, and logarithm functions. OBEX and Forum.
• Posts: 870
edited February 2012
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 :innocent:

Lawson
micro-power experiments with the propeller.
Drivers for TAOS TSL3301 line sensor Forum thread, and OBEX
Lumen Electronic Jewelery Website
My AWD motorcycle Website and action video
What I'm paid to work on. UW Lidar Group.
FME, a Spin-only floating point library with trig, exponential, and logarithm functions. OBEX and Forum.
• Posts: 20,602
edited February 2012
I'd like to see a pick-and-place machine that could do that! :)

-Phil
Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away.

-Antoine de Saint-Exupery

We had many discussions at the galley table and there had been many honest attempts to understand each other's thinking. There are several kinds of reception possible. There is the mind which lies in wait with traps for flaws, so set that it may miss, though not grasping it, a soundness. There is a second which is not reception at all, but blind flight because of laziness, or because some pattern is disturbed by the processes of the discussion. The best reception of all is that which is easy and relaxed, which says in effect, "Let me absorb this thing. Let me try to understand it without private barriers. When I have understood what you are saying, only then will I subject it to my own scrutiny and my own criticism."  This is the finest of all critical approaches and the rarest.

The smallest and meanest of all is that which, being frightened or outraged by thinking outside or beyond its pattern, revenges itself senselessly; leaps on a misspelled word or a mispronunciation, drags tricky definition in by the scruff of the neck, and, ranging like a small unpleasant dog, rags and tears the structure to shreds.

-John Steinbeck, The Log from the Sea of Cortez
• Posts: 2,009
edited February 2012
Stonehenge, for the electrons.
• Posts: 2,713
edited February 2012
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 July 2012
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 July 2012
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
micro-power experiments with the propeller.
Drivers for TAOS TSL3301 line sensor Forum thread, and OBEX
Lumen Electronic Jewelery Website
My AWD motorcycle Website and action video
What I'm paid to work on. UW Lidar Group.
FME, a Spin-only floating point library with trig, exponential, and logarithm functions. OBEX and Forum.
• Posts: 769
edited July 2012
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.