Shop OBEX P1 Docs P2 Docs Learn Events
Line-to line video jitter - why? How to avoid? — Parallax Forums

Line-to line video jitter - why? How to avoid?

Andrey DemenevAndrey Demenev Posts: 377
edited 2011-04-06 21:20 in Propeller 1
Are there some techichues to avoid line-to line VGA jitter? See attached picture. This is supposed to be a nice white rectangle, but the edges are not straight, and not stable - they look like waves, each line moves left and right, while the next moves in opposite direction
891 x 726 - 821K

Comments

  • ericballericball Posts: 774
    edited 2011-04-06 05:50
    Tough to say without looking at your code, but I would guess that you are exceeding the WAITVID to WAITVID timing during horizontal blanking (probably after sync). Cycle count each WAITVID to WAITVID interval. Assume 6 cycles for WAITVID (I know the manual says 5, but I've seen glitches if the timing is too perfect) and 22 cycles for the first HUBOP after a WAITVID (remaining instructions will be sync'd to the HUB until the next WAITVID). Check the time for the number of cycles at your clockspeed versus the time for the number of PLLAs in FrameCounter.
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-04-06 06:03
    pixel clock is 63.5 MHz. All blanking interval generation consists of exactly 7 instructions:
    :loop       mov     VSCL, vscl_hsync            ' 4
                waitvid sync, #0                    ' 6
                mov     VSCL, vscl_bp               ' 4 
                waitvid blank, #0                   ' 6            
                ' line generation here
                mov     VSCL, vscl_fp               ' 4
                waitvid blank, #0                   ' 6
                djnz    line_counter, #:loop        ' 4
                                                    ' = 34
    
    the shortest waitvid is for front porch - 48 pixels, translating into over 60 propeller clock cycles, which is much more than 34
  • kuronekokuroneko Posts: 3,623
    edited 2011-04-06 06:05
    @Andrey: I've seen jitter like this before. My monitor only auto-adjusts at resolutions above 800x600. Everything below has to be manually adjusted. Once adjusted the waves disappeared. Do you have a test case?
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-04-06 06:09
    I am observing this on small 7" monitor, on 19" monitor, and on big LCD TV. I am suspecting this is due to pixel clock chosen. I have seen 5 MHz granularity in Chip Graceys' drivers. I am using timings calculated according to VESA coordinated video timing.
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-04-06 06:13
    I can post generated code run through disassembler if anyone wants to have a look. Not a big pleasure to read it though.
  • kuronekokuroneko Posts: 3,623
    edited 2011-04-06 06:16
    As long as it can generate runnable code it's acceptable :)
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-04-06 07:25
    Here you go. Do not rely too much on comments. The code is generated, and the comments have been added manually after disassembly.
    CON
        _clkmode = xtal1+pll16x
        _clkfreq = 80_000_000
    
    PUB main
        cognew(@entry, 0)
    
    DAT
    entry
    '' 1024x768, 60 HZ, VESA CVT
    '' Pattern : 6 groups. Each group contains 128 lines :
    ''      64 lines of white-black-white ... sections
    ''      64 lines of black-white-black ... sections
    '' producing 16x12 "chess field"
    l_000 mov     FRQA,  $008   '   LONG $A0BFF408
    l_001 movi    VCFG, #$040   '   LONG $58FFFC40
    l_002 movs    VCFG, #$0FF   '   LONG $50FFFCFF
    l_003 movd    VCFG, #$002   '   LONG $54FFFC02
    l_004 mov     DIRA, #$0FF   '   LONG $A0FFECFF
    l_005 shl     DIRA, #$010   '   LONG $2CFFEC10
    l_006 movi    CTRA,  $009   '   LONG $58BFF009
    l_007 jmp           #$00D   '   LONG $5C7C000D
    l_008                           LONG $19800000
    l_009                           LONG $0000000E
    l_00A                           LONG $00000000
    l_00B                           LONG $00000000
    l_00C                           LONG $00000000
    
    '' vertical back porch- 4 lines
    l_00D mov     $00A, #$004   '   LONG $A0FC1404
        '' hsync
    l_00E mov     VSCL,  $1C9   '   LONG $A0BFFFC9
    l_00F waitvid $1C8, #$000   '   LONG $FC7F9000
        '' h back porch
    l_010 mov     VSCL,  $1CB   '   LONG $A0BFFFCB
    l_011 waitvid $1CA, #$000   '   LONG $FC7F9400
        '' h visible
    l_012 mov     VSCL,  $1CC   '   LONG $A0BFFFCC
    l_013 waitvid $1CA, #$000   '   LONG $FC7F9400
        '' h front porch
    l_014 mov     VSCL,  $1CD   '   LONG $A0BFFFCD
    l_015 waitvid $1CA, #$000   '   LONG $FC7F9400
    '' loop
    l_016 djnz    $00A, #$00E   '   LONG $E4FC140E
    
    '' vertical back porch- 23 lines
    l_017 mov     $00A, #$017   '   LONG $A0FC1417
        '' hsync
    l_018 mov     VSCL,  $1C9   '   LONG $A0BFFFC9
    l_019 waitvid $1CE, #$000   '   LONG $FC7F9C00
        '' h back porch
    l_01A mov     VSCL,  $1CB   '   LONG $A0BFFFCB
    l_01B waitvid $1CF, #$000   '   LONG $FC7F9E00
        '' h visible
    l_01C mov     VSCL,  $1CC   '   LONG $A0BFFFCC
    l_01D waitvid $1CF, #$000   '   LONG $FC7F9E00
        '' h front porch
    l_01E mov     VSCL,  $1CD   '   LONG $A0BFFFCD
    l_01F waitvid $1CF, #$000   '   LONG $FC7F9E00
    '' loop
    l_020 djnz    $00A, #$018   '   LONG $E4FC1418
    
    '' group - repeat 6 times
    l_021 mov     $00A, #$006   '   LONG $A0FC1406
    '' line - repeat 64 times
    l_022 mov     $00B, #$040   '   LONG $A0FC1640
    
        '' hsync
    l_023 mov     VSCL,  $1C9   '   LONG $A0BFFFC9
    l_024 waitvid $1CE, #$000   '   LONG $FC7F9C00
        '' h back porch
    l_025 mov     VSCL,  $1CB   '   LONG $A0BFFFCB
    l_026 waitvid $1CF, #$000   '   LONG $FC7F9E00
    '' section - white
    l_027 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_028 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_029 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_02A waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_02B mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_02C waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_02D mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_02E waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_02F mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_030 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_031 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_032 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_033 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_034 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_035 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_036 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_037 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_038 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_039 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_03A waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_03B mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_03C waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_03D mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_03E waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_03F mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_040 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_041 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_042 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_043 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_044 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_045 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_046 waitvid $1D2, #$000   '   LONG $FC7FA400
        '' h front porch
    l_047 mov     VSCL,  $1CD   '   LONG $A0BFFFCD
    l_048 waitvid $1CF, #$000   '   LONG $FC7F9E00
    '' lines loop
    l_049 djnz    $00B, #$023   '   LONG $E4FC1623
    
    '' line - repeat 64 times
    l_04A mov     $00B, #$040   '   LONG $A0FC1640
        '' hsync
    l_04B mov     VSCL,  $1C9   '   LONG $A0BFFFC9
    l_04C waitvid $1CE, #$000   '   LONG $FC7F9C00
        '' h back porch
    l_04D mov     VSCL,  $1CB   '   LONG $A0BFFFCB
    l_04E waitvid $1CF, #$000   '   LONG $FC7F9E00
    '' section - black
    l_04F mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_050 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_051 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_052 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_053 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_054 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_055 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_056 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_057 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_058 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_059 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_05A waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_05B mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_05C waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_05D mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_05E waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_05F mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_060 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_061 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_062 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_063 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_064 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_065 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_066 waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_067 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_068 waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_069 mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_06A waitvid $1D1, #$000   '   LONG $FC7FA200
    '' section - black
    l_06B mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_06C waitvid $1D2, #$000   '   LONG $FC7FA400
    '' section - white
    l_06D mov     VSCL,  $1D0   '   LONG $A0BFFFD0
    l_06E waitvid $1D1, #$000   '   LONG $FC7FA200
        '' h front porch
    l_06F mov     VSCL,  $1CD   '   LONG $A0BFFFCD
    l_070 waitvid $1CF, #$000   '   LONG $FC7F9E00
    '' lines loop
    l_071 djnz    $00B, #$04B   '   LONG $E4FC164B
    '' groups loop
    l_072 djnz    $00A, #$022   '   LONG $E4FC1422
    
    '' v front porch - 3 lines
    l_073 mov     $00A, #$003   '   LONG $A0FC1403
        '' hsync
    l_074 mov     VSCL,  $1C9   '   LONG $A0BFFFC9
    l_075 waitvid $1CE, #$000   '   LONG $FC7F9C00
        '' h back porch
    l_076 mov     VSCL,  $1CB   '   LONG $A0BFFFCB
    l_077 waitvid $1CF, #$000   '   LONG $FC7F9E00
        '' h visible
    l_078 mov     VSCL,  $1CC   '   LONG $A0BFFFCC
    l_079 waitvid $1CF, #$000   '   LONG $FC7F9E00
        '' h front porch
    l_07A mov     VSCL,  $1CD   '   LONG $A0BFFFCD
    l_07B waitvid $1CF, #$000   '   LONG $FC7F9E00
    '' loop
    l_07C djnz    $00A, #$074   '   LONG $E4FC1474
    '' repeat frame
    l_07D jmp           #$00D   '   LONG $5C7C000D
                 LONG 0[$14A]
    '' Constatnts pool
                 ORG $1C8
    L_1C8         LONG $00000001
    L_1C9         LONG $00008068
    L_1CA         LONG $00000003
    L_1CB         LONG $00008098
    L_1CC         LONG $00008400
    L_1CD         LONG $00008030
    L_1CE         LONG $00000000
    L_1CF         LONG $00000002
    L_1D0         LONG $00001040
    L_1D1         LONG $000002FE
    L_1D2         LONG $00000202
    L_1D3         LONG $00000000
    
  • kuronekokuroneko Posts: 3,623
    edited 2011-04-06 07:40
    Thanks. I can see what you mean. Oddly enough my monitor lists the timing as 1280x768, your source claims 1024x768. Anyway, this'll have to wait until tomorrow.
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-04-06 07:48
    Yes, all mine say 1280 as well. 1280x768 is a valid 15:9 format. As I understand, aspect ratio is determined by vertical sync pulse length - possibly I made a mistake there- but VESA CVT spreadsheet produces same results as my code generator
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-04-06 08:47
    I have tried to play with pixel freq. If I make it a rough approximation to calculated value, rounding to nearest 5 MHz multiply (before that I was using 250 kHz as VESA CVT recommends) - I get a nice stable picture. My guess is that the reason is PLL jitter - without that rounding, the PLL clock only equals calculated frequency in average. Why I cannot actually use that rough rounding - because the objective is to get VESA standards - complying signal.

    Anyway, I would appreciate if someone looks at the code - possibly I am missing something. kuroneko - I mean you :)
  • kuronekokuroneko Posts: 3,623
    edited 2011-04-06 16:54
    pixel clock is 63.5 MHz. All blanking interval generation consists of exactly 7 instructions:
    I'm slightly confused by your 250kHz comment (previous post). Is that some recommended step size? Anyway, the PLL setup you posted comes down to 63.75MHz, 80_000_000/4K*408*(16/2) = 63_750_000. With that setting I get a small amount of jitter of I look closely. Changing the PLL setup to actually generate 63.50MHz ($19800000 -> $19666666) results in a stable picture (on my monitor that is). Can you give that setting a try?

    Both frequencies differ by 250kHz which makes me wonder which frequency you actually want. Can you clarify?
  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-04-06 21:20
    That was an error in my CVT calculation. The freq must be 63.5 MHz. With corrected calculation, at 63.5 MHz I do see notable jitter on 7" monitor and big LCD TV. An old 15" monitor designed specifically for 1024x768 gives sharp stable picture. If I change frame rate to 75 Hz, both TV and 7" show even more jitter, and subtle jitter can be seen on 15" monitor.

    I am attaching CVT description and spreadsheet, my CVT calculator and code builder, along with test code.
Sign In or Register to comment.