Search This Blog

Thursday, May 17, 2012

NTSC Composite Video

   As usual, one thing distracts another.  The hardware is set up for the first VGA test, but the code has not come out yet.  In the meantime, I found an old LCD screen that I wanted to examine.  It comes from an old DVD player for the car.  The main unit has a DVD player and 7" LCD screen.  It also comes with a second 7" LCD that attaches to the main unit via a three prong RCA cable.  The signal should be composite video.  The screen on the main player is broken, but the second one works.  It is small, thin, and portable.

   It is ripe for hacking, so VGA will now have to wait.  This screen is just waiting for a game of Pong or just a cool, big, text terminal!  The NTSC and PAL standards are quite taxing to implement in software.  Questions to the Google revealed a few possible shortcuts.  Here then are my notes thus far.  The project will attempt to write black and white ( and maybe some gray ), using my new Pic18F4550, clocked with PLL at 48MHz.  This gives a Pic a working speed of 12 MIPS.  The links below provide some of the shortcuts that should make the vertical synching less of a hassle.

==========================
    Composite Video
==========================

-------------
17 May, 2012
-------------

    References
    ----------

Rikard Gunee's Pong and Tetris on a Pic
The Post That Gave Me Inspiration
Uzebox
The Shortcuts from AVRFreaks


    Going to try the simplest method.  This will not try to do interlaced lines.  Instead, it will only do the even line field over and over. 

Frame = 2 fields of both even lines.

Timings
--------
Line = 63.5 us
262 lines per field
Time per Field = 262 x 63.5 = 16.637 ms

Line Parts
----------

Name        Voltage        Time    Instructions @ 12 Mips
_______________________________________________________

Front Porch        .3V         1.4us         17 ( actual 16.8 )
HSynch             0V         4.4us         53 ( actual 52.8 )
Back Porch        .3V         4.4us         53 ( actual 52.8 )
Active         .3-1.2V    53.3us        639 ( actual 639.6 )

Total Instructions = 762
Freq = 8.333 x 10^-8
Total Time = 762 x 8.333x10^-8 = 63.5us


Vertical Synch
---------------

Try just setting the line to 0V for the whole 63.5us on the 3 VSynch lines.

Field Layout
------------

Lines        Function
------------------------------------
  3            Dummy H lines
  3            VSynch lines
 14            Dummy H lines
242            Visible lines

Dummy H line:
Front Porch, HSynch, Back Porch, .3V for active 53.3us

During the active time of the dummy lines, 639 free instructions are available per line.
Use this time to set up the line arrays.


Pin Setup
----------

Pin 1 has a 470 Ohm resistor
Pin 0 has a 1k resistor

Pins    Result
---------------
00         0V (synch)
01        .3V (black)
10        .6V    (gray)
11         1V (white)


Interrupts
-----------

Use Timer 0 in 16 bit mode.  Interrupt every 63.5us ( every 762 instructions at 48MHz ).
65536 - 762 = 64774
In binary = 0b1111110100000110
The High byte is 253
The Low byte is 6
High = 0xFD
Low =  0x06

Need to keep track of line numbers.  At start of interrupt, immediately set output to 01 ( black ).
If it is a vertical synch, set output port to 00 ( 0V ) and return to process data.
Else, waste time and do the horizontal synch ( porches and synch ).
If it's a dummy line, return to main for processing.
If it's an active line, process the line.

Need to figure out the line and array housekeeping, too.

Need to look for a way to use the 106 instructions of porch and Hsynch time effectively.























No comments:

Post a Comment