Maker Pro

How to Build a Color Mechanical TV, Part 5: Software Tools

August 18, 2017 by Vincent Portet

Part five in this series about building a color mechanical television covers the software tools needed for the project.

Editor’s Note: This is part of a several part project by Vincent Portet. If you would like to see a specific chapter, refer to the table of contents below.

The following software tools are provided in this archive:

a) Basic tools for tuning the system * The WAV files "colorploop-60.wav" and "colorploop-30.wav" containing a prepared color bar pattern:

(Black line and mid-height, and darker level in the bottom part.)

For Linux users: The executable "playloop-48k" allows to continuously play in loop the WAV file to be used. It can be compiled as follows:

# gcc playloop-48k.c -o playloop-48k  (oss-devel package to install through your package manager)

Then launched this way:

# ./playloop-48k colorploop-60.wav (for a 60-line system)

For Windows users: No loop playing tool is available from me at this time. So, unless you already have one preferred player which does not implement equalization (!), Audacity ( is highly recommended. You will have to use the "looping" feature ( or to import and paste the WAV file several times on the track. Indeed, "colorloop-x0.wav" is too short to be played in single shot while giving the time to analyze and tune. Also ensure that loop join is perfect and does not bring any phase step in the synchronization. Otherwise you would encounter troubles during synchronization tuning!

b) Tools for converting videos to NBTV WAV files
Once the system is tuned, everyone is impatient to see how it behaves with "real" videos.

The third party software to be used in addition to the provided tools is FFMPEG. It is available as well for Linux (installed through the package management wizard of your distribution) as for Windows:

Windows binaries are provided, while Linux users can compile the single file sources as follows:

# gcc nbtv60color.c -o nbtv60color

# gcc nbtv30color.c -o nbtv30color

# gcc grey2rgb.c -o grey2rgb

These binaries, as well as FFMPEG, are intended to be called by scripts which perform an "all-in-one" process. So once everything is installed, the script "" or "video2nbtv_x0.bat" has to be launched, according on the OS you run. However, considering your disc spinning direction and your spiral profile, first edit the script to check at the last line if the arguments passed to nbtvx0color correspond to what you need:

Argument "-i" sets line rasterization order from the bottom to the top (but remains left to right).

No argument means classical rasterization: Left to right, top to bottom.

(This applies if you create the picture at the top of disk while encoding non-rotated videos. Otherwise you will have to cogitate a little bit with spatial considerations.)

If the process ends successfully you should get an output file "NBTV60-OUT.wav" or "NBTV30-OUT.wav". Having a short look at it with Audacity can help checking that it looks like NBTV video. You can then rename this output file in a more user-friendly way, so that it will not be overwritten at the next script call.

c) Possible line offset correction

When creating NBTV WAV files it is possible to take into account a possible positioning error made when drilling the disc holes. Of course this correction can only apply in the line scanning direction by adding variable delays in video lines. This is why each version of converter gives the possibility to add a text file named "shifdef.dat" which will be loaded from the place where the converting script is called.

In this file featuring 29 or 59 lines depending on the used video resolution, line delays are expressed in pixels via decimal signed integer values which just have to be entered without any other characters.





(... until the 29th or 59th line...)

A negative value means a "negative delay" (first pixels lost and black pixels added at end-of-line).

A positive value means a "positive delay" (black pixels added at the beginning and last pixels lost).

The settings can be tweaked through several iterations to get the best result while using an encoded bar pattern. An interactive tool can help for this (end of document), so that Linux users can create  "shiftdef.dat" automatically after having "moved" bars line by line to align them through keyboard controls. This kind of tool was used for the prototype shown in the Youtube video.

Note for color systems: In a SECAM transmission one single color line is shared by two scanned lines (blue is acquired while red is replayed, then red is acquired while blue is replayed, etc...). This means that line offsets cannot be corrected as well as in black and white. This can be observed in the Youtube video (case of a very bad Nipkow's disc) where color pictures are much more scrambled than black and white pictures shown earlier.

However, the color NBTV converting tools do handle "shiftdef.dat" anyway by applying a trade-off for color: The offset applied to the currently transmitted color is the intermediate value (average) between the currently scanned line offset and the next coming line offset. This can help in case of moderate corrections, but not in the case of the disc prototype spinning in the Youtube video.

Code for Programming the Color Decoder Microcontroller

The assembled code file "colordec.hex" is ready for programming the PIC16F819 with any Microchip programmer. For example, Pic Kit2 or more recent versions (like this PICkit debugger from Microcontroller) are very affordable and efficient tools.

The source file "colordec.asm" is provided for information or for your own modifications, if you're interested.

Note: It's easier to program the microcontroller on a separate DIP IC socket where you will solder five wires according to the programmer device documentation.

Related Content


You May Also Like