|
|
Pushing 8 pins PIC to their limits : Here is the world's tiniest, cheapest and simplest PIC PAL video OSD superimposer ! See also my PIC PAL composite video generator library |
What's this for ?!
This project is designed to show how to build time-dependant applications on PICs in C and to deal with restricted hardware.
It will also help you to have a start point, if you need a simple way to add text to a PAL composite video signal in real time.
With only an 8 pins PIC and a few cheap components, you can superimpose constant or dynamic text to a composite video PAL signal.
How DOES IT work
To superimpose text to a PAL video signal, we need to control timing with precision to get a stable picture.
We have to deal with vertical synchronization, which tell us when a new frame starts, and with horizontal synchronization, which tell us when a new line starts.
Usually, and external circuit is used to extract both vertical and horizontal synchronization pulses from the PAL video signal, the LM1881 integrated circuit does it very well for example.
Since I wanted to have a very simple circuit, I had to find a way to make the PIC do this job.
First, we must be able to know when a video line starts : we will use the PIC internal comparator module to do it. The internal voltage reference module will be programmed with a voltage clip level, the comparator will then trigger an interrupt each time the input voltage will become lower or higher than the clip level. This will be our horizontal sync separator.
Second, we must be able to know when a frame starts do get vertical sync : PAL signal uses special sync pulses to announce a new frame. We have to detect a 28 µs low level pulse, there are five of them in the vertical sync and none elsewhere. The internal timer module of the PIC will be used to count time of low level pulses.
This done, we must be able to know what to superimpose to the video signal. A bitmap representation of the text to be displayed is built in RAM from a 5x7 fonts table. On each new line interrupt, we check if we are in display time window for adding pixels or not.
To add a pixel to the video signal, we change output pin from high Z state to output, the output then imposes +Vcc or 0V to display either a white or a black pixel. The result is a superimposed text on transparent background .
CIRCUIT DIAGRAM
The PIC is overclocked with a 25 Mhz crystal but it should accept it with no problem. If you want not to overclock it, then use a 20 Mhz crystal and see C source code to know what adjustment to do. The result will be thiner pixel width.
You can use GP0 as I/O and GP3 as input if you have to build your own software. These pins are not used for the demo program.
Superimposed text is directly mixed to video input by tying GP1 and GP2 together, we count on video source and video input stages to adjust impedance as best as possible.
Since the circuit is very simplified, it works but you must be aware that it is neither compliant to Microchip PIC12F683 specifications (oscillator frequency and maximum output load), nor to PAL video specifications (impedance and voltages), so use it at your own risks.
Note also that video input and ouput are exactly the same, you can switch them with no problem !
Source code
Here is the mikroC source code, you can also download the full project (see below).
Since 8-pin PIC12F683 does not have a full 8-bit port, the usual trick to shift a port can not be used to generate the video signal (see my PIC PAL video library), and an alternative method is used.
A PIC16 or PIC18 could be used with only a few adjustments : more RAM and ROM will extend the possibilities of this project.
|
Project download
You can use this software as you wish, if you accept to do it at your own risks.
Download picoOSD demo example for mikroC with schematic : zipped file, 35 Ko 
Project demo video
Please add comments, suggestions and report bugs to me in my forums