Skip to content

NTSC Video Out

Kurt Kiefer edited this page Mar 2, 2016 · 11 revisions

Notes before starting

Boards from Get round 1 (green boards) and round 2 (blue boards, also store orders before Mar 2016) have the wrong resistor values to support video out. Additionally, round 2 boards have the uFL connector on upside-down. Round 3 (closing beginning of Mar 2016) will be ready for video. See the end of this document for the necessary modifications.

Code

See branch analog-video-dma-gpio

Cabling

The PureThermal 1 board has a Hirose u.FL coax connector on the back that you can adapt into standard RCA video cable. There are quite a few ways to do this. The most common option (besides a custom cable) is a standard u.FL-SMA pigtail paired with SMA-BNC and BNC-RCA adapters. Here are some examples.

To terminate in an RCA jack, e.g. to connect a longer cable:

To terminate in an RCA plug for a short connection:

Of course, if you have a lot of standard BNC cables with two plug ends sitting around like we do, you can adapt to the BNC jack, use your BNC cable, and terminate it with a BNC jack to RCA plug. Clearly, there's a few options here ;)

Performance

Composite video-out on PT1 is performed by a basic 4-bit DAC. Currently the output is only grayscale, so the luminance resolution is somewhat poor. See this PT1 example video output.

The 14.318182 MHz system clock provides the clocks that make color technically possible (it was prototyped with a test pattern), and that should go a long way to improving the resolution visually on this system. However, it will require some more development work to realize this. If you feel like working on this feature, pull requests are very welcome ;)

Methodology

A single timer (TIM1) runs at 30x the NTSC color carrier rate (30x 3.57955 MHz, or 107.386 MHz). Its auto-reload register (ARR) is set to 14, so it generates a timer update event at 7.15909 MHz, which in turn is hooked up to a DMA controller that outputs to the GPIO Port B value register. GPIO Port B consists of 4 outputs that are wired through resistors in parallel to the video connector, which forms a rudimentary 4-bit DAC.

We can generate an output waveform by creating a series of values that get sent out to the 4-bit DAC with DMA. In general, this is done one line at a time. The beginning of the line contains the embedded horizontal sync. After the sync, the voltage amplitude of the DAC basically controls the brightness level you see for each pixel on the screen as you scan from left to right.

A square wave on this waveform can approximate the color carrier on the composite video signal, and then changing the value of the TIM1 auto-reload register (ARR) by small amounts allows us to shift the waveform left or right to realize color.

Modifications for R1/R2 boards

You'll have to change out the following resistors (0402 footprint, 1%) to form the correct values for the 4-bit DAC:

R5  (PB0)  -> 237Ω
R22 (PB1)  -> 470Ω
R23 (PB6)  -> 931Ω
R4  (PB10) -> 1.87kΩ

PT1 resistor modifications for analog video

Note that these values were available in small quantities on digikey. Should you be unable to find these exact values, do your best to approximate the values: { 235, 470, 940, 1880 }

If you have an R2 board, the u.FL connector (J1) is also upside-down. Note the bottom image in the following picture where the ring/shield is connected to a raised pad. This raised pad should face down, and should not be soldered to the PT1 board. In the top image, you can see the center pin connected to the correct signal pad that should be soldered.

Hirose u.FL connector