Shop OBEX P1 Docs P2 Docs Learn Events
Any way to calculate what comes out on TV output pins? — Parallax Forums

Any way to calculate what comes out on TV output pins?

RaymanRayman Posts: 14,877
edited 2011-03-16 10:18 in Propeller 1
I think there's some hidden magic inside the Prop that turns bytes of color into 3-bits at the output pins...

Anybody know how to do this conversion?

I'm thinking I could load a SRAM chip with an image and output on TV, if I knew how to convert...

PS:· Could one perhaps use 2 TV cogs and mix the outputs together to get more colors?
(asking because the SRAM is 8-bits wide, so there'd be a lot of waste only using 3-bits...)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

Comments

  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-09-29 19:35
    If I understand you correctly, the TV output is not in bits. It is an analog signal because the way a TV outputs is in a wave involving the picture signal followed by the color. The prop generates video signal by pulsing the output allong the 3 channels into the video pin. This, I believe, because of the resistors, makes them be at different frequencys or levels of the wave. I am not an expert so I may be wrong. I think that if you wanted to store an image onto SRAM to be loaded into the screen later then you would use the Parallax Graphics driver's pixal sprite command and load the image from the SRAM into the sprite address.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Computers are microcontrolled.

    Robots are microcontrolled.
    I am microcontrolled.

    But you·can·call me micro.

    Want to·experiment with the SX or just put together a cool project?
    SX Spinning light display·


  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-09-29 19:45
    Strictly speaking, the three bits control the intensity only. The Propeller hardware adds the color by modulating the intensity output at the colorburst frequency. The phase of this modulation relative to the phase of the colorburst at the beginning of each scan line, is what determines the hue (out of 16 possibilities), if any, of each pixel. In general, you have no control over the color saturation, and the stock colors are not very saturated. The exception to this comes when the modulation overflows the intensity (i.e. 7 + modulation == 0), which forces the color modulation tips to sync level, resulting in oversaturated colors that are 180 degrees out of phase from the standard colors.

    BTW, the output from the three bits is digital, not analog. The resistor DAC is what converts it to an eight-level analog signal.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 9/29/2009 7:50:49 PM GMT
  • ericballericball Posts: 774
    edited 2009-09-29 20:23
    See Chip's response in http://forums.parallax.com/showthread.php?p=586084

    In summary, the luma provides a base 0-7 value (-40 to +100 IRE).· Color (when enabled) adds or subtracts one from that output value depending on the value of the 4 bit counter driven by PLLA vs the color value.· Supersaturated colors are left as an exercise for the reader.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • RaymanRayman Posts: 14,877
    edited 2009-09-30 09:50
    Ok, well I think I'd have to output at several times the color burst frequency to do a good job then...

    I think I've found a better way... I'll just drop in an AD723 to do the conversion in good quality.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • ericballericball Posts: 774
    edited 2009-09-30 13:32
    Rayman said...

    I'm thinking I could load a SRAM chip with an image and output on TV, if I knew how to convert...
    If you use the Propeller native composite / S-Video modes you are limited by the lack of control over saturation and the ~128 color gamut.·

    For my NTSC sprite driver I took an alternate tack by using VGA mode and clocking out three 14.31818MHz (4x colorburst) values per pixel (240 pixels per line).· This allowed me to create any YUV color - limited only by the DAC.· (The driver assumes a standard Demoboard style 4 bit DAC, but it could also drive an 8 bit DAC for composite or a 4+4 DAC for S-Video.)

    NTSC is also bandwidth limited by color modulation, so the number of pixels per line will top out at around 300 (240 active) for composite and 455 (320 active)·for S-Video.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • RaymanRayman Posts: 14,877
    edited 2009-09-30 16:16
    Thanks ericball, that's exactly the kind of thing I was looking for... Still not sure how 3 values per pixel is sufficient to specify the phase shift though...

    But, now I'm leaning heavily toward AD723 because I can spit out either DVI, VGA or TV with the same data...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-09-30 16:24
    Rayman said...
    Still not sure how 3 values per pixel is sufficient to specify the phase shift though...
    It's not. The colors argument to waitvid uses eight bits to specify the luma and chroma values. The Propeller's hardware converts this into properly phase-shifted luma+chroma using three pins to get eight analog levels. If you think of the color output as being time-multiplexed (i.e. serial) data, it starts to make more sense.

    -Phil
  • RaymanRayman Posts: 14,877
    edited 2009-09-30 16:59
    I don't know Phil, I just looked at his driver and it's using VGA (not TV) mode for VCFG...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • ericballericball Posts: 774
    edited 2009-09-30 19:29
    Rayman said...
    Thanks ericball, that's exactly the kind of thing I was looking for... Still not sure how 3 values per pixel is sufficient to specify the phase shift though...
    It is and it isn't...

    In composite video color is encoded as two color difference (B-Y & R-Y, aka·U & V) signals quadrature modulated and added to the base luma signal (i.e. Y(t) + U(t) * sin(F*t) + V(t) * cos(F*t) where F is the colorburst frequency).· What my driver does is run PLLA at 4 times the colorburst frequency and then kick out samples for cos(F*t) = 1; sin(F*t) = 1; cos(F*t) = -1; sin(F*t) = -1; or Y(t) + V(t); Y(t) + U(t); Y(t)·- V(t); Y(t) - U(t).·

    Now, with only the Demoboard DACs my driver can't quite create exactly the same phases (hues) that the Propeller can generate.· However, it generates a much larger color gamut with a wide variety of color saturations.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • RaymanRayman Posts: 14,877
    edited 2009-09-30 22:08
    Ok, I think I almost get it now! Can U and V be negative in your example?
    Maybe I'm leaning back toward this method instead of a seperate chip now...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • ericballericball Posts: 774
    edited 2009-10-01 01:41
    Rayman said...
    Ok, I think I almost get it now! Can U and V be negative in your example? Maybe I'm leaning back toward this method instead of a seperate chip now...
    Yes, U & V can be negative, especially for greens.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • VIRANDVIRAND Posts: 656
    edited 2009-10-01 05:14
    Imagine a 16 bit rotating shift register with 8 bits in a row set, which go around 3,579,545 times a second.
    (It would have to be clocked at around 57 Mhz, or 16x 3579545.)
    It could look like a circle of 16 LEDs if slowed down to around 1 shift per second, with half on and half off.
    That would generate all 16 Propeller Color Phases of 3579545 Mhz at the same time.

    If each LED is numbered and colored like the Propeller colors, then ...
    if the bright yellow-green one is connected to a video signal for 6 microseconds after sync,
    then connection from a bit of the shift register to the video source at any other time will
    change the video to that color.

    I forgot how I was going to explain this as a 16 slice pizza with each slice it's own color, spinning
    3579545 times a second...

    It is simple to choose from 16 color phases with only 14.31818 Mhz and 2 dollars worth of CMOS logic chips,
    and make a bitmap image in a 64KB 27512 EPROM and a binary counter addressing it for continuous readout,
    perhaps to display color bars and a channel logo, as I did once. (Similar to the OP idea with SRAM).

    I figure there are 228x262 pixels in a complete non-interlace frame of NTSC, each one a cycle of 3579545 Mhz,
    and there should be very close to 60 of those repeating in a second. The bitmap in the EPROM could be exactly
    the color numbers of the Prop, with the 3 lowest bits going to resistor DAC and the 4 highest ones going to
    the color phase selecting logic whose output is added to the DAC through a 1K resistor.
    Bit 3 seems to gate the color, so I'd expect all of the undocumented numbers
    07 17 27 37 47 57 67 77 87 97 A7 B7 C7 D7 E7 F7
    to be white without having tested them all.
  • RaymanRayman Posts: 14,877
    edited 2011-03-16 06:14
    Been a while, but I'm thinking about this again in terms of Flash Point SuperQuad...

    Maybe I can fill the flash with an frame, put the 4 output pins right onto the 4 TV pins, then clock it out at 4FSC.

    I haven't figured out how I reset the address for the next frame yet though... I imagine a TV wouldn't like output during the blanking period...
    Maybe use another pin to force the DAC output to zero...
  • potatoheadpotatohead Posts: 10,261
    edited 2011-03-16 06:29
    If we deviated from the reference TV circuit, using more pins, we could get a significant improvement. Eric has actually written some brilliant code that exploits what we have rather well.

    Composite signals are difficult. People like the sharpness of VGA, and they will pay the pins for it. Component video is on par with that, but there are few handy displays. S-video is a pretty sweet compromise, particularly on the monochrome part of the signal. Most displays I've tried will do 640 luma pixels without any real trouble. It's not VGA, but it's great compared to composite.

    Maybe we could split the middle and start getting much better TV output?

    I'm thinking of a circuit where we go ahead and use 8 pins, maybe using three for a much better Eric style color signal, and the remaining ones for more greys. S-video lets us break the color up and do a manual signal. I've toyed with that driver Eric wrote, and it's got a lot of potential.

    TV also has lower sweep frequencies, which boil down to being able to do more in a single cog, or smarter color data, making better use of the RAM in the Prop.
  • ericballericball Posts: 774
    edited 2011-03-16 10:18
    Rayman wrote: »
    Maybe I can fill the flash with an frame, put the 4 output pins right onto the 4 TV pins, then clock it out at 4FSC.
    What's your design target? I'm thinking picture resolution, output hardware (standard 3/4 pin or custom, composite or S-Video), color gamut / number of colors, storage requirements & bandwidth (flash to HUB to WAITVID). Are you going to try to display a standard file format or will you be able to do some preprocessing & transcoding on a PC?
    Rayman wrote: »
    I haven't figured out how I reset the address for the next frame yet though... I imagine a TV wouldn't like output during the blanking period...
    Maybe use another pin to force the DAC output to zero...
    A composite TV signal is always active. Zero output is typically sync (aka -40 IRE) while black (0 IRE) is 40/140 of full range (100 IRE = white). Horizontal sync is a 4.7uS sync pulse (which is then followed by a colorburst wave). Vertical sync is several lines of sync & black in a fixed pattern. However, during that time period there is no requirement to retrieve picture data.
Sign In or Register to comment.