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.

DSC01266.jpg
DSC01272.jpg


GREYSCALE RESISTOR LADDER

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

VGA_64grey.png


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)

DSC01268.jpg


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.
1024 x 680 - 81K
1024 x 680 - 36K
1024 x 680 - 54K
844 x 556 - 17K

Comments

  • 22 Comments sorted by Votes Date Added
  • edited May 2011 Posts: 0Vote Up0Vote Down
    Nice work! Very useful for vision apps, as you noted.
    www.mikronauts.com / E-mail: mikronauts _at_ gmail _dot_ com / Products and Projects:
    RoboPi: The most advanced Robot controller for the Raspberry Pi (Propeller based)
    SchoolBoard ][ Solderless Educational Development Board (Propeller, FPGA, more)
    Advanced prototyping & Parallax Propeller boards - Follow @Mikronauts on Twitter
  • edited May 2011 Posts: 2,258Vote Up0Vote Down
    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...)
  • edited July 2011 Posts: 2,258Vote Up0Vote Down
    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.
  • edited July 2011 Posts: 0Vote Up0Vote Down
    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.
  • edited July 2011 Posts: 0Vote Up0Vote Down
    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.
  • edited July 2011 Posts: 0Vote Up0Vote Down
    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
  • edited July 2011 Posts: 2,258Vote Up0Vote Down
    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?
  • KyeKye
    edited July 2011 Posts: 0Vote Up0Vote Down
    Very nice job!
    Nyamekye,
  • edited July 2011 Posts: 0Vote Up0Vote Down
    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!
  • edited July 2011 Posts: 0Vote Up0Vote Down
    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
    “Impossible is just a big word thrown around by small men who find it easier to live in the world they’ve been given than to explore the power they have to change it. Impossible is not a fact. It’s an opinion. Impossible is not a declaration. It’s a dare. Impossible is potential. Impossible is temporary. Impossible is nothing.” –Muhammad Ali
  • edited July 2011 Posts: 2,258Vote Up0Vote Down
    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?
  • edited July 2011 Posts: 0Vote Up0Vote Down
    What's your pixel clock rate? That will be the determining factor.

    -Phil
    “Impossible is just a big word thrown around by small men who find it easier to live in the world they’ve been given than to explore the power they have to change it. Impossible is not a fact. It’s an opinion. Impossible is not a declaration. It’s a dare. Impossible is potential. Impossible is temporary. Impossible is nothing.” –Muhammad Ali
  • edited January 2012 Posts: 2,258Vote Up0Vote Down
    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.
  • edited February 2012 Posts: 0Vote Up0Vote Down
    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.
  • edited February 2012 Posts: 0Vote Up0Vote Down
    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
    705 x 606 - 159K
    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.
  • edited February 2012 Posts: 0Vote Up0Vote Down
    I'd like to see a pick-and-place machine that could do that! :)

    -Phil
    “Impossible is just a big word thrown around by small men who find it easier to live in the world they’ve been given than to explore the power they have to change it. Impossible is not a fact. It’s an opinion. Impossible is not a declaration. It’s a dare. Impossible is potential. Impossible is temporary. Impossible is nothing.” –Muhammad Ali
  • edited February 2012 Posts: 0Vote Up0Vote Down
    Stonehenge, for the electrons.
  • edited February 2012 Posts: 2,258Vote Up0Vote Down
    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?).
  • edited July 2012 Posts: 0Vote Up0Vote Down
    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?
  • edited July 2012 Posts: 0Vote Up0Vote Down
    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.
  • edited July 2012 Posts: 0Vote Up0Vote Down
    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.
Sign In or Register to comment.