Shop OBEX P1 Docs P2 Docs Learn Events
NTSC & PAL templates — Parallax Forums

NTSC & PAL templates

ericballericball Posts: 774
edited 2009-06-21 23:30 in Propeller 1
The purpose of this code is twofold. First, it shows the NTSC/PAL color gamut for Propeller baseband video.
Second, this code is intended to be a relatively simple template which may be used by others to develop
Propeller video drivers. Note: this code creates an 29.97 Hz 525 line (NTSC) or 25 Hz 625 line (PAL) interlaced display.


I have finally completed the PAL version. Thanks to Coley for his testing assistance and the autodetect code (which I've also added to the NTSC code).






Composite NTSC sprite driver: http://forums.parallax.com/forums/default.aspx?f=25&m=343999
NTSC color bars (template): http://forums.parallax.com/forums/default.aspx?f=25&m=347839


Post Edited (ericball) : 6/21/2009 11:32:01 PM GMT

Comments

  • ericballericball Posts: 774
    edited 2009-05-14 14:25
    I have updated NTSC colorbars.spin - both with bugfixes and lots of comments.

    I have also made a PAL version (attached), but there is at least one bug I haven't been able to puzzle out yet.· So if anyone out there has a good knowledge of PASM, PAL,·the equipment to test things out (i.e. PAL TV with 576 visible lines) and wants to help let me know!· Note: PAL colorbars.spin is not finished - in addition to the bug, it hardcodes the alternating phase colors.


    I've removed the attachment as a later version is attached below.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: http://forums.parallax.com/showthread.php?p=800114
    NTSC color bars (template): http://forums.parallax.com/showthread.php?p=803904


    Post Edited (ericball) : 5/24/2009 10:29:02 PM GMT
  • RaymanRayman Posts: 14,130
    edited 2009-05-14 14:53
    Thanks! This is much easier than TV.SPIN to decipher... I've already asked you via PM, I know, but: How do your "colors" values relate to the ones used in TV.SPIN? Is there a simple relationship?

    Also, I would like to start with non-interlaced, which you say is 262 line frame but that odd # frame is better... Is there any easy way to make it an odd # frame?

    Also, if you don't mind... Is there an easy way to reduce the number of active lines?· I guess just output the background color for top and bottom lines, right?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • ericballericball Posts: 774
    edited 2009-05-14 15:42
    Rayman said...
    Thanks! This is much easier than TV.SPIN to decipher... I've already asked you via PM, I know, but: How do your "colors" values relate to the ones used in TV.SPIN? Is there a simple relationship?

    I'm checking into this.· The question is whether $xA and/or $xF are valid colors.· Note: my original submission had the colorburst as color #0, which meant color $0C was yellow.· I've changed this so colorburst is color #8 so color $0C is blue, to match PAL and TV.spin.
    Rayman said...
    Also, I would like to start with non-interlaced, which you say is 262 line frame but that odd # frame is better... Is there any easy way to make it an odd # frame?
    For non-interlaced, an odd number of [noparse][[/noparse]u]lines[noparse][[/noparse]/u] per frame is recommended.· The easy way is to reduce the number of active lines from 241 to 240.· Note: my original submission had the JMP for interlaced in the wrong place.
    Rayman said...
    Also, if you don't mind... Is there an easy way to reduce the number of active lines?· I guess just output the background color for top and bottom lines, right?
    Yep.· Increase the number of blank lines before the active lines and add blank lines after the active lines.· Just keep the total number of lines the same and add the same number of lines to the top and bottom.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: http://forums.parallax.com/showthread.php?p=800114
    NTSC color bars (template): http://forums.parallax.com/showthread.php?p=803904
  • RaymanRayman Posts: 14,130
    edited 2009-05-14 16:01
    Thanks. Maybe the colors are 1:1 one with TV.SPIN now... I'll have to check this out tonight...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • ColeyColey Posts: 1,108
    edited 2009-05-14 18:40
    Eric,

    This is what I got on my Demoboard and Hybrid.
    The flicker on demoboard is quite pronounced, phase is off somewhere...it is clearer on Hybrid but still a problem with the phase in the top 1/8th of the display.

    Coley

    EDIT, I should note that these are from the PAL version, NTSC is rock solid smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX - The home of the Hybrid Development System and PropGFX Lite

    Post Edited (Coley) : 5/15/2009 7:41:35 AM GMT
    842 x 495 - 99K
    842 x 497 - 96K
  • RaymanRayman Posts: 14,130
    edited 2009-05-14 23:54
    Just tested on my little Parallax monitor with a protoboard and it's rock solid...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • RaymanRayman Posts: 14,130
    edited 2009-05-15 00:03
    Ericball:· Changed your colors to TV.SPIN colors and I think it looks better...· Try this:
    colors                  BYTE    $02                            ' LONG padding
                            BYTE    $07, $06, $05, $04, $03, $02   ' white to black (6 levels)
                            BYTE    $0A, $0B, $0C, $0D, $0E, $88                    ' 16 hues, 6 shades/hue
                            BYTE    $1A, $1B, $1C, $1D, $1E, $98
                            BYTE    $2A, $2B, $2C, $2D, $2E, $A8
                            BYTE    $3A, $3B, $3C, $3D, $3E, $B8
                            BYTE    $4A, $4B, $4C, $4D, $4E, $C8
                            BYTE    $5A, $5B, $5C, $5D, $5E, $D8
                            BYTE    $6A, $6B, $6C, $6D, $6E, $E8
                            BYTE    $7A, $7B, $7C, $7D, $7E, $F8
                            BYTE    $8A, $8B, $8C, $8D, $8E, $08
                            BYTE    $9A, $9B, $9C, $9D, $9E, $18
                            BYTE    $AA, $AB, $AC, $AD, $AE, $28
                            BYTE    $BA, $BB, $BC, $BD, $BE, $38
                            BYTE    $CA, $CB, $CC, $CD, $CE, $48
                            BYTE    $DA, $DB, $DC, $DD, $DE, $58
                            BYTE    $EA, $EB, $EC, $ED, $EE, $68
                            BYTE    $FA, $FB, $FC, $FD, $FE, $78
                            BYTE    $02                            ' LONG padding
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • RaymanRayman Posts: 14,130
    edited 2009-05-16 13:54
    I think I see what's going on now... this driver does the "phaseflip" (flipping the bits in the upper nibble of a color) only for PAL, but TV.spin only does it for NTSC. So, this is probably the colors are different...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-05-16 14:53
    The colour errors at the top of frame and general beating over the rest is just as my, home built Demoboard gives. That is with the bog standard 5MHz Xtal, with 6MHz it is a lot better. The reason is probably down to the relationship of the 4.43MHz chroma subcarrier and system clock. I wish I could work out exactly what or why, I bet there are a lot of basic truths that would unfold to me if that nugget was found.
    I tried to use 4.43 and 8.86 Xtals, with code changes, to try and give the counters an easy time, but the whole video driver seemed to fail (min 80MHz????) 17.74 was deemed to be just plain spitefull.
  • mosquito56mosquito56 Posts: 387
    edited 2009-05-16 23:33
    Mine is rock solid on education board. If you stare at it for a few seconds it begins to waver but that may just be the tequilla I drank talking. Sweet. Well Done.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·······

    ······· "What do you mean, it doesn't have any tubes?"
    ······· "No such thing as a dumb question" unless it's on the internet
    ········
  • ericballericball Posts: 774
    edited 2009-05-17 00:48
    Just a note, Coley and Toby are referring to PAL colorbars which has .. umm ... issues. Coley has me thinking it's like the problem I had with an early version of my 240H driver. Toby is probably correct that the 4.43MHz colorburst will show more problems with a typical 5MHz setup.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: http://forums.parallax.com/showthread.php?p=800114
    NTSC color bars (template): http://forums.parallax.com/showthread.php?p=803904
  • ericballericball Posts: 774
    edited 2009-05-24 22:36
    I found the problem in the PAL version - I wasn't accounting for the change in phase flip between frames.· This still isn't the final version - but I need people to test out this version on PAL equipment.· I'm playing with FRQA - the "real" value of $0E30_053E (for 80MHz) versus $0E30_0500.· On my capture card $0E30_053E has diagonal bands of color shift.· (Also, I'd like to know whether the ADD lines in serration/equalizing makes any difference.)

    edit: removed attachment as the final version has been added to the first post.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: http://forums.parallax.com/showthread.php?p=800114
    NTSC & PAL templates: http://forums.parallax.com/showthread.php?p=803904


    Post Edited (ericball) : 6/22/2009 4:49:29 PM GMT
  • ColeyColey Posts: 1,108
    edited 2009-05-25 11:45
    Ericball,

    Tested OK on my PAL TV.
    Nice and steady but I notice that there are two colours that don't seem to be quite right.
    1st Purple band in from the left and second blue band in from the right are alternating between the colour and black.
    I change the colour table to be white to black all the way across the line and these black lines disappeared.....

    Adding in the equalisation and serration pulse make the image more stable, there is more dot crawl when left out.

    I've also modified your code to auto select the hardware it's running on, Hydra, demoboard or Hybrid.

    Regards,

    Coley

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX - The home of the Hybrid Development System and PropGFX Lite
  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-05-25 15:56
    I think that this is a good approach for ALL Propeller software development:
    ericball said...
    Rules for developing video drivers:
    1. Start simple. Hardcode values and static display.
    2. Add complexity and changes incrementally. Verify at each step.
    3. If something doesn't work it's either because you have made an incorrect
    assumption or made a coding error.

    Programming is an art that requires discipline.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • ericballericball Posts: 774
    edited 2009-06-15 01:27
    Coley said...
    Tested OK on my PAL TV.
    Nice and steady but I notice that there are two colours that don't seem to be quite right.
    1st Purple band in from the left and second blue band in from the right are alternating between the colour and black.
    I change the colour table to be white to black all the way across the line and these black lines disappeared.....

    I've also modified your code to auto select the hardware it's running on, Hydra, demoboard or Hybrid.
    I think that weirdness is a side effect of the chroma & luma changing combined with the phase change.· There's some similar fuzz in my TV colorgrid (although the colors in that case have a white/black border). Correction - there was a typo in my color tables.

    The autodectect code is quite cool.· However, it's a little advanced for something which is supposed to be as simple as possible.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: http://forums.parallax.com/showthread.php?p=800114
    NTSC color bars (template): http://forums.parallax.com/showthread.php?p=803904


    Post Edited (ericball) : 6/20/2009 6:45:32 PM GMT
  • ericballericball Posts: 774
    edited 2009-06-21 23:30
    I have finally completed the PAL version (attachment in first post).

    A big thanks to Coley for his testing assistance and the autodetect code (which I decided to use).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: http://forums.parallax.com/showthread.php?p=800114
    NTSC color bars (template): http://forums.parallax.com/showthread.php?p=803904
  • Hi @ericball

    I've been trying to increase the active video time of the PAL template as there's only 42.7uS and it should be just over 50uS. I have tried without success and really need some help.

    I initially thought increasing the plla cycles for each pixel would do the job but it made no difference increasing this past 31.

    I've shifted the active section so that it's in the correct start position by reducing the back porch but because I haven't been able to increase the active video section, I've had to increase the front porch to maintain the correct line length.

    Really struggling to see where to go now so any help would be greatly appreciated.

    Rob
  • Hello Rob,

    I'm not sure what you're trying to accomplish, but let me see if I can explain how timing works on the Propeller.

    All timings are in cycles of 16 times the colorburst clock (70,937,900Hz for PAL or 14.097ns per cycle). Each line is 64us, or 4540 cycles which the sample driver divides into:
    vsclsync                333 cycles                                 ' sync = 4.7us
    vscls2cb                397-333 cycles                             ' sync to colorburst
    vsclbrst                16*10 cycles                              ' 10 cycles of colorburst
    vsclbp                  (745-397-16*10)+232 cycles                 ' back porch+overscan
    vsclactv                104*31 cycles                               ' active video (104 pixels, 31 cycles / pixel)
    vsclfp                  233+106 cycles                             ' overscan+front porch
    

    If you want to increase the active video time, you need to decrease the overscan values (232 & 233) by equal amounts.

    Eric
  • Thanks Eric

    as it was, the overscan values meant the active video was only 42.7uS so the video only occupied the middle of the screen with large black bands either side. I just couldn't get all the info' on the screen.

    I am a real novice at the video generation side of the propeller even though I've been programming in PASM for nearly 8 years, shocking I know. It's only now that I have to deal with video that I've started to look into it seriously.

    The main reason for trying to understand your excellent templates is I really need to modify the TV Overlay object that Phil Pilgrim wrote because it's for NTSC and I live in the UK and need it to be PAL.

    While trying to see the workings of your template I noticed (may be wrong here) that you don't do half lines for the odd/even fields. Is that correct?

    That's not to say it doesn't display okay but I've used the blank lines at the start of each field to superimpose telemetry data and initially I had problems until I only used the odd field. I used an LM1881 sync separator to get the composite sync pulses and the odd/even field.

    Sorry for babbling on but wanted to give you some idea what I was up to.

    Thanks again

    Rob


  • Hi Rob,

    It's been a while, but I'm 99% certain the code does the correct halflines for even/odd fields. See the comments. Make sure you aren't adding lines (i.e. more than 312.5 lines per field).

    I was never 110% happy with the PAL code, and being in Canada I didn't have a PAL TV to test with - only a capture card. PAL is a lot finickier when it comes to color modulation. And for some reason I was never quite able to get results as good as Chip's code.

    I haven't looked at Phil's code, but I know there are some architectural differences between my NTSC and PAL code. (Doing both with the same code, like Chip's code is amazing, but also confusing.) So it may be tricky to modify Phil's code to PAL.

    Eric
  • Hi Eric,

    nailed it this morning. If you look through the code I've attached you'll see the differences. I changed the number of waitvids to 31 to reflect the size of the colour table and changed a few of the timings to get it to 64uS total for the line and 52uS for the active part of the video. It now shows a standard colour bar that fills the monitor.

    It did require a little tweaking to stop the top of the image tearing due to the line time being a fraction of a uS out. I've not looked any further in to the half line issue as "it's working" so don't try and fix it!

    Thanks for all your help.

    Rob
  • Hi Rob,

    Okay, I think I see what you're trying to accomplish. You want to display 124 pixels per line (31 WAITVIDs, 4 pixels per WAITVID). The maximum active part of the line is 3,689 cycles, which would mean 29.75 cycles / pixel. You want ~50us of active display, which is 3,547 cycles or 28.6 cycles / pixel. However, this needs to be an integer value.

    124 pixels @ 29 cycles / pixel = 3,596 cycles = 50.7us
    vsclbp                  long    1<<12+(745-397-16*10)+(3689-124*29)/2           ' pal back porch+overscan
    vsclactv                long    29<<12+29*4                                     ' pal 29 plla per pixel, 4 pixels per frame
    vsclfp                  long    1<<12+(3690-124*29)/2+106                       ' pal overscan+front porch
    
    124 pixels @ 28 cycles / pixel = 3,472 cycles = 48.9us
    vsclbp                  long    1<<12+(745-397-16*10)+(3689-124*28)/2           ' pal back porch+overscan
    vsclactv                long    28<<12+28*4                                     ' pal 28 plla per pixel, 4 pixels per frame
    vsclfp                  long    1<<12+(3690-124*28)/2+106                       ' pal overscan+front porch
    

    Hopefully this works.

    Eric
  • Thanks Eric

    It's been very helpful and the penny has finally dropped regarding the video generator in the propeller, I now understand how it works (mostly).

    I'm now going to look at making a pwm object using the video generator. I need to generate a 50Hz or 60Hz sine wave and doing it via the video generator allows me to play a lot with the pwm frequency, among other things.

    Thanks again for all your help.

    Rob
Sign In or Register to comment.