circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

October 2006, Issue 195

Generate Video from Software

 


by René Geraets

Start Video Signal Anatomy Transforming Digital I/O Output Resolution Memory Restrictions Using DMA Perfect Fit Sources and PDF

VIDEO SIGNAL ANATOMY

Video is a sequence of still images (frames) that produces the illusion of motion when it is played fast enough. The European TV system (PAL) produces 25 frames per second. The American system (NTSC) produces 30 frames per second. Each frame consists of image lines that form the vertical resolution on your television. Each frame in PAL consists of 625 lines. NTSC frames have 525 lines. Therefore, although PAL has fewer frames per second than NTSC, it has more image lines per frame, and thus a higher resolution.

With respect to line frequency, the lower frame rate and higher number of lines per frame cancel each other out. PAL and NTSC signals contain about the same number of lines per second. In both PAL and NTSC, each video line is produced in 64 µs.

Showing video at 25 or 30 frames per second can result in visible flickering on traditional CRT televisions. Illuminated phosphor particles in the picture tube produce images. The particles slowly dim before they are illuminated again for the next image. The human eye is fast enough to notice these variations in light intensity if the image is updated only 25 (or 30) times per second. The solution is to update the screen twice as fast.

An image is divided into two fields. One consists of all even lines. The other consists of all odd lines (see Figure 2). Thus, each field spans the complete screen area but can be written to the screen in half the time it would take to write the entire image. This way the screen is updated 50 (or 60) times per second. This process is called interlacing.

(Click here to enlarge)

Figure 2—The even field (solid) ends in a half image line. The odd field (dashed) starts with a half image line. The two fields form one frame. This is called interlacing. In reality, each field is made up of more image lines than what you see here. In PAL, a field has 312.5 lines. In NTSC, a field has 262.5 lines.

A varying analog voltage can represent a black-and-white video signal. Note that 1 V represents white and 0.3 V represents black. The voltages between them represent corresponding shades of gray. The voltage changes over time to represent the different shades of gray that build up the image lines. The faster you update this voltage during an image line, the more features you can show horizontally. This determines the horizontal resolution.

It doesn’t make sense to have a big difference between the horizontal and vertical resolutions. You know the vertical resolution (the number of lines per frame) and the duration of each image line, so you must be able to vary the voltage about 10 million times per second for a high-quality television picture. With its 24-MHz clock frequency, the M16C/62P is not fast enough to reach this 10 million mark, but a factor of three or four less still provides a reasonable resolution for small applications.

To make sure the picture is stable on your screen, you need a way of identifying exactly where each image line starts (i.e., horizontal synchronization) and where each field starts (vertical synchronization). H sync is encoded in the video signal by lowering the voltage below the 0.3-V black level for 4 µs. Figure 3 is a typical image line. The V sync pattern is more complicated. It consists of a series of pulses and also distinguishes between the even and odd fields. V sync patterns are shown in Figure 4 (p. 26).

(Click here to enlarge)

Figure 3—This is a typical image line for a black-and-white video signal. The image line starts with a 4-µs sync pulse. The video data starts 8 µs after that. CRT televisions need this time to move the image-producing electron beam back to the left of the screen. A color video signal has a 3.58- or 4.43-MHz carrier wave superimposed on this holding the color information.

 

(Click here to enlarge)

Figure 4—Check out this V-sync pattern for even fields (top) and odd fields (bottom). The V-sync of the even field starts and ends at the image line start points. The V-sync of the odd field starts and ends in the middle of an image line.

 

Adding color to the black-and-white signal is accomplished by superimposing a 3.58-MHz (NTSC) or 4.43-MHz (PAL) carrier onto the black-and-white signal. The amplitude and phase of the carrier determine the color saturation and hue. The analog value that forms the black-and-white signal determines the color’s intensity, or luminance. The resulting signal is called a composite baseband video signal (CVBS). This is the standard used for television broadcasts. It’s also the kind of signal that comes out of a VCR.

Creating a CVBS signal from software is probably impossible for any one microcontroller on its own. Generating the 3.58- or 4.43-MHz carrier wave and varying its amplitude and phase with enough precision and resolution to create a nice-looking color signal would require additional dedicated video hardware. But that doesn’t mean you can’t create color video from software. With the advent of new types of video equipment, new video encoding standards are also implemented as inputs for television. For example, DVD players not only create a CVBS output signal, but also present the video in the form of an RGB signal. An RGB signal is much easier to create with software.

With the CVBS signal, all video information (luminance, color saturation and hue, and synchronization pulses) is transported via one wire. The RGB signal uses four wires. In the RGB representation, the color information is broken down into its red, green, and blue constituents. Each of the R, G, and B components is transported as a 0.7-VPP signal over its own wire (much like the black-and-white video signal was). The fourth wire carries the synchronization pulses (and thus forms a 0.3-VPP signal). By separating the color information over three wires, the need for the hard-to-generate 3.58- or 4.43-MHz carrier has disappeared. The RGB format brings color video back within the reach of the M16C/62P microcontroller. That’s why I used it.