Shop OBEX P1 Docs P2 Docs Learn Events
Monochrome VGA... — Parallax Forums

Monochrome VGA...

siljamickesiljamicke Posts: 66
edited 2011-01-23 19:30 in Propeller 1
Is it possible to cut down on the number of pins required for a VGA connection if, say i only wanted Green monochrome output, i.e. variable luminances of green? Or for that matter, even just green and black? Or red and black... cool ;D

Comments

  • ericballericball Posts: 774
    edited 2011-01-20 08:23
    Yes, how few pins depends on how much you are willing to modify the VGA driver or write your own. For monochrome VGA you need to drive three outputs: one for the pixel output, one for Hsync and one for Vsync. The easiest change from the normal 8 pins would be to 4 pins (4 shades: GgHV) or 3 pins (2 shades: GHV). Getting down to two pins means some external transistors to multiplex the Hsync & Vsync onto one pin and then use high/low/tristate to drive the two outputs. Down to one pin is probably possible but you'd need a special circuit which could change a PWM generated DC level to determine the three outputs.
  • SapiehaSapieha Posts: 2,964
    edited 2011-01-20 08:27
    Hi siljamicke.

    Look on Yours Private massage BOX on forum.
  • siljamickesiljamicke Posts: 66
    edited 2011-01-20 09:44
    Sapieha wrote: »
    Hi siljamicke.

    Look on Yours Private massage BOX on forum.

    I have a massage box? Nice! ;)

    Just kidding, no offence!
  • siljamickesiljamicke Posts: 66
    edited 2011-01-20 09:51
    @ericball

    Thanks! Since i want to both go for simplicity as well as low pin count, i will probably start off by trying to modify the driver to use 3 or 4 pins!
    Why is there no such driver already? Surely someone more than me would love that green ATM-style video. Or am i off here, wouldn't it look as cool as i picture it?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-20 10:01
    You could use the existing driver. Just modify it so the pins you don't want to use are not set to output. Then you can use them for something else in other cogs. For example, if you want yellow on a black background, just enable HSYNC, VSYNC, and the two pins closest to them (can't remember which color those are). Then connect separate resistors from each (that'll be four resistors) to the red and green pins on the VGA connector. Then ground the blue pin. When outputting, you will have to select the color that corresponded to the pins neighboring the Prop's sync outputs.

    -Phil
  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-01-20 12:20
    siljamicke wrote: »
    Just kidding, no offence!

    I think you meant no offense. :)

    The grammar police are everywhere....
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-20 12:29
    'Depends on whose grammar police you're talking about. We U.S. Americans are the only ones who spell it with an "s". Even in Canada it's "spelt" with a "c".

    -Phil
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-01-20 14:42
    It certainly looks fine. And if you don't need different levels, you can do this with just one pin driving green, so that would be only 3 pins being used.

    I like the retro green on black. And yes, it will free up some precious pins.

    As for 'offence', that is how it is spelt in Australia too. Along with colour, and centre.
    The grammar police are everywhere....
    The Pedant Police have just pulled up with lights and sirens, to point out that this may provoke a demarcation dispute, as this is not the jurisdiction of the Grammar Police, but rather the Spelling Police *grin*.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-20 17:10
    Phil published a circuit to use 1 pin for the HS & VS using tristate as neither. Four series resistors from 3V3 to GND as follows:
    3v3 --- 10K --(A)-- 5K --(B)-- 5K -- (C) -- 10K --- GND
    (B) is the prop HS/VS pin.
    (A) is connected to an inverter so that when HS/VS=1 the inverter outputs low for, say HS.
    (C) is connected to a buffer (or 2 inverters) so that when HS/VS=0 the buffer outputs low for, say VS
    When HS/VS=tristate, both the inverter and buffer output high.

    The inverter & buffer (2 series inverters) can be built using 3 inverters from 74LVC04. I have suggested using a 74LVC2G86 dual xor 8pin chip instead by tying the second input to the (A) gate to gnd and the second input to the (C) gate to 3v3.

    Both of these circuits have been published in previous threads. I don't think any VGA code has been done to implement this.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-01-20 17:24
    Cluso99. That sounds cunning. So that means you could get this down to two pins?
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-20 17:52
    Stay tuned... Something in the pipe <grin>
  • lanternfishlanternfish Posts: 366
    edited 2011-01-20 18:46
    Would sync on green (SOG) require only one pin an a couple of transistors? Oops, resistors?
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-01-21 02:04
    I reduced the pins used down to 4 for an attempt to free up as many pins as poss. This left the two "blues", H-syncs and V-syncs. This would give only bright(er) blue on a blue background, but as the Prop can give more mA on a pin it is possible to put resistors over onto the Green and Red pins too and get white on blue/red/green/black background. The pins used can be shifted over to the start of any of the groups of eight.

    All this is just a couple of altered lines in the driver and rewiring the 15 pin, I will have to find the bits to show you (HDD failed, a while back)
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-01-21 02:32
    I imagine there might be some work required on the code. Some spin code assumes 8 bits so it will be important to go through all the pre-processing that is done and look at masks etc.

    Then in pasm also look at masks and the actual bits. Maybe it is easier than that, but I would expect that it would be worth a quick glance at every line of code with a view to asking whether the code needs changing.

    I wonder if you could use external logic to do other color combinations than green on black? eg white on blue - a 1 would be decoded to 111 on RGB. And a 0 would be 001 (RGB). Though technically the blue will be a brighter cyan, so maybe you need some resistor logic as well so that 1 goes to 111 and 0 is 0,0,1/2.

    I guess it depends if you want the mildly retro early 90's white on blue, or the mid retro mid 80s orange on black, or the even more retro 70's green on black.

    All of these ought to be possible with one color pin and maybe one logic chip.

    Cluso99 is probably going to show us some magic soon with the hsync and vsync signals. I have a vague feeling that with one-shot timers and logic chips it is possible to reduce from 3 pins...
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-01-21 13:32
    I tried going really cheap on the pins and trying to cheat the background into being just the H-sync signal (assuming it is neg going) but the clamping ccts in my newer monitors hated it. One of the anchient ones was happy to play nice though.

    Although I cheated the output logic to only use the bottom four of the eight usuals, I made no effort in sorting out the driver software. It did work with it being the bottom half of the top eight ie P24-27 without messing up the I2C or serial (the I2C switched over to be the KBD on H-sync startup, via a 4053)
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-21 16:22
    I am loking for a detailed spec on the HS & DS but despite a fairly long look via google didn't find one.

    What I want to know (for the 1pin cct for HS/VS) is if while VS is active=0 there are continued HS=0 pulses as this would require an extra bit of processing?

    Next, in the colors of the waitvid command, are the lower 2 bits actually used. The spec says they are not, yet otherwise how is the HS & VS achieved?

    Here is what I intend to do...
    Put the XOR circuit on both of the BB pins, one to drive the VS when tristate, and one to drive the HS when tristate. This way, 2 pins will give me 4 colors including black, and HS & VS. However, I am going to feed those 2 pins into a cheap CPLD to recreate an 8pin VGA output for use with the normal 240R & 470R resistor network to a VGA connector. Now, more pins could be connected to the CPLD such as GG and then RR.
  • siljamickesiljamicke Posts: 66
    edited 2011-01-22 05:58
    JasonDorie wrote: »
    I think you meant no offense. :)

    The grammar police are everywhere....

    It just keeps coming back at you, doesn't it :)
  • siljamickesiljamicke Posts: 66
    edited 2011-01-22 06:11
    What a nice spinoff! 2 pin multicolor video, who would have imagined!

    I am nowhere able to understand what is involved in making this thing work. Just a dumb question, could you use the "1 color pin"-approach, and route via a simple switch to which pin (R/G/B) the color signal ends up in? Or pots for sweepable color?
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-22 11:40
    You can use different values of resistors from the pin to the R+G+B pins (need to check current drive requirements but most likely ok) in a 1pin color design (2 pins total)

    Still looking for the following answers...
    Looking for detailed timing specs (I googled but didn't find them with the time avail) - any good links?
    While in VS do we also get HS pulses?
    Colors in the waitvid command, are the lower 2 bits actually used? The spec says they are not, yet otherwise how is the HS & VS achieved?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-22 15:59
    Here's another idea for extracting two sync signals from a single output pin that also includes one-color VGA data. It does not rely on tri-stating the pin but, rather, on frequency. The pixel rate for 640x480 VGA is about 20MHz. This means that there will be no oscillations occurring faster than 10 MHz. By outputting a 20 MHz clock, say, when you want VSYNC and 50 MHz when you want HSYNC, you can embed the syncs in the data line. To extract the sync signals, use a circuit something like this:

    attachment.php?attachmentid=77507&d=1295740089

    The crystal-looking thing is a cheap three-pin ceramic resonator for the frequency you want to detect. In this configuration, it will pass that frequency only, while blocking everything else. The first Schmitt trigger inverter is biased so that only an output from the resonator that's high enough will will trigger it. Its output gets passed to a second Schmitt inverter configured as a one-shot, which sustains an output as long as the input keeps getting pulsed low.

    I used the following program to test the concept. The resonator was a 20MHz unit from my junk drawer. I didn't have any DIP Schmitt triggers, so I had to settle for 74HC00 NAND gates. I wrote a program to output two frequencies in continuous sequence: 20 MHz and 20.25 MHz. Here's the code:
    CON
    
       _clkmode     = xtal1 + pll16x
       _xinfreq     = 5_000_000
    
       OUT          = 0
       TRIG         = 1
    
    PUB  Start
    
      ctra := %00100 << 26 | OUT
      dira[OUT]~~
      dira[TRIG]~~
      repeat
        outa[TRIG]~~
        frqa := $4000_0000
        outa[TRIG]~
        frqa := $4100_0000
        waitcnt(8000 + cnt)
    

    Here's a screen shot from my scope:

    attachment.php?attachmentid=77506&d=1295740089

    The top trace (cyan) is the frequency output from the Prop. The next trace (magenta) is the separate Prop output used only for triggering the scope, since it's hard to get a consistent trigger on two such close frequencies. The Third trace (yellow) is the output from the second inverter. (The glitch at the end of the pulse is a consequence of not using a Schmitt trigger.) The "on" delay for the sync output from a change form 20.25 MHz to 20 MHz is about 5.6 us; the "off" delay from a change from 20 MHz to 20.25 MHz, nearly zero. To be useful as an HSYNC output, the "on" delay would have to be shortened considerably, due to the front- and back-porch requirements. This might be realized by using a much higher frequency, such as 50 MHz. For vertical sync, it's not so critical.

    Anyway, whether this is at all practical for a one-pin VGA implementation remains to be seen.

    -Phil
    640 x 480 - 23K
    547 x 206 - 2K
  • ericballericball Posts: 774
    edited 2011-01-22 19:10
    Hmm.. that's an interesting idea Phil. Is there any risk of harmonics from active video passing through?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-22 19:15
    Eric,

    I checked, but I haven't seen evidence of that being a problem. But, if it's a concern, just make sure that the frequencies selected for sync are not multiples of ~10 MHz.

    -Phil
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-22 21:13
    Phil: That's a nice circuit :)

    I have been trying to verify if HS occurs during the VS. I also thought that HS & VS were "0" pulses but they appear to be "1" pulses. I have been unable to find a waveform on google and my scope is burried in storage :(

    My best efforts to understand the waitvid are indicating the RRGGBBHV in the colortable could actually be in any order and that all bits work identically. So we could just as well define them as RGBHRGBV and wire the hardware accordingly? Is this assumption correct? (BTW, Kye's VGA64_BMPEngine seems to be the easiest to understand the working of the video section of the prop.)

    So, if my understanding is correct, then we should be able to exploit the video counters for many other purposes besides video.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-22 21:23
    Cluso99 wrote:
    So we could just as well define them as RGBHRGBV and wire the hardware accordingly?
    Yes, absolutely! The Prop's video circuitry is complete agnostic regarding what it's attached to.

    See this page regarding VGA timing and sync polarities:

    It's probably the most succinct of any I've found.

    -Phil
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-22 22:36
    Thankyou Phil. Sure is a real shame with all those goodies in these counters, we don't have a configuration bit (and gates) to reverse the function from outputting the longs to inputting them. There has to be a lot more ways to exploit these counters!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-23 12:08
    This may be jumping the shark somewhat, but here's another way to embed both syncs in a one-pin VGA output (without tri-stating). It relies on the fact that each pixel pulse -- high or low -- must be at least 50 ns long (20 MHz pixel rate). It uses a Shmitt-trigger-inverter delay line with three-input NAND gates to detect pulses narrower than, say 40 ns. Each NAND output is used to toggle its flip-flop and to preset the other sync's flip-flop. (For positive sync, just connect the NANDs to the /CLR inputs instead.) Here's a schematic:

    attachment.php?attachmentid=77534&d=1295812893

    -Phil
    886 x 480 - 7K
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-01-23 19:30
    Thanks Phil. I have just posted a 2pin version that should produce 4 colors including black on a new thread. Thanks for your inspiration and your input and ideas. It is something I have had on the dwg board for some time. This discussion certainly has helped. Originally I expected to reduce the HS & VS to 1 pin and then other pin(s) to produce more than 2 colors. However, moving the HS and VS to 2 color pins saves a pin while retaining the ability to get more colors. By adding extra pins, more colors can be achieved.
    http://forums.parallax.com/showthread.php?128991-VGA-Cluso-s-2-pin-4-color-(inc-black)-VGA-circuit-(untested-amp-uncoded)&p=970544#post970544
Sign In or Register to comment.