A PAL challenge…
One day My friend Thomas needed a PAL video signal for testing some old monitor (Thomas has a YouTube channel where he tears down and repair vintage equipment for your entertainment).
We both have the SDG6022X Arbitrary Waveform Generator from Siglent.
This device , apart from being a excellent signal generator, is capable of generating fast complicated waveforms by essentially replaying and looping large samples from internal memory.
This thing must exist have a PAL test pattern right?!
Assuming that a TV test pattern is a pretty normal thing to need we started pouring over the settings of the SDG6022 and found that this the rig didn’t have any video test pictures in it. After a rather exhaustive search of the internet we realized that there were no data available for a PAL test signal.
No. So what do we need?
With the usual ‘how hard can it be’ attitude we thought we could just make the data ourselves.
The generator simply takes a file containing samples in 16 bit resolution and replays it any desired rate in the 0-200 Mega samples per second range.
We were convinced that somewhere on the internet someone had made a sample file containing the waveform for a PAL test picture that could either be used directly or modified.
It turns out that we could not find one.
So what _is_ out there?
We found this python script that allowed us to render some video data from a supplied image file.
The script was designed to provide data for live video transmission with GnuRadio and did not exactly contain the video waveform.
It rather contained the constituents of the video signal minus the so called chroma carrier that would be added by the GnuRadio application later.
(I am not going to go into all the details about PAL here. Check links below)
Eager to just make something work we loaded the waveforms into Audacity, pretending that they were audio signals:

The top waveform represented the luminance or brightness of the video, essentially a black and white signal. To obtain the color information the two lower waveforms needed to be multiplied with a sine and cosine signal, respectively at the chroma carrier frequency and then added to the luminance signal to achieve the final PAL waveform.
In Audacity we pretended that the waveform was sampled at 13.5kHz. We then used Audacity to generate a sine wave at 4.43361875kHz. A copy of this signal was shifted by hand to achieve something resembling a cosine waveform.

Audacity has a scripting language that allow multiplication of tracks so by multiplying and adding the results a single composite PAL frame could be made:

In theory this final waveform should be one frame of PAL video and if looped by the signal generator it should produce a nice video signal right…
Well it kind of worked…
The waveform was exported as 16bit signed values, loaded it into the signal generator and played back at 13.5MSps.
While the signal looks totally fine on an oscilloscope none of the screens we connected would show the image correctly.

Some screens would completely fail to synchronize the picture like in the video above. Some would show an somewhat ok picture but the colors would be all screwed up.
So what went wrong?
After exhaustive examination of the signal line by line we found that all the timing was correct and all the frequencies and color information were apparently as they should be. Something more subtle was wrong.
The color information in a PAL signal is encoded using a phase modulation technique. We suspected that simply looping one frame would create some sort of phase discontinuity that prevented the receivers to properly lock on to the signal.
If you want something done properly…
We decided to write some code that could generate a PAL frame with all the phases properly wrapped so that the frame could be looped.
..you can do it right here in your browser:
The imbedded program takes a image (or the built in test picture) and render it into to two frames of loop able PAL video. Two frames are needed to make sure all phases wraps properly.
The sampling frequency is chosen to be the chroma carrier times 8 (35.468950MHz) but in practice anything between 20-100MHz seems to work fine.
The data file can be downloaded in 16bit signed format. Some generators require a 12 bit (scaled) version. This may be achieved by changing the level values accordingly.
Black and white video can be achieved by setting the color gain and optionally the burst amplitude to zero.
So what now?
Obviously we may add other video standards to the code above as we need them in the future but this whole exercise have taught us a bunch about generating complex signals that can be re-played by arbitrary waveform generators.
We can imagine creating all sorts of test signals needed for experimentation or for emulating long lost vintage equipment.
Useful links
To learn more about how all this video stuff works here are some links that helped us a bunch:
PAL video timing specification by Martin Hinner
