Make your own free website on Tripod.com

VIDEO OVERLAY CIRCUIT WITH PIC 18F258



This project is based on Microchip's PIC 18F258 microcontroller and was built using only conventional (THT) parts.

1. Main features :

        • static text display: 14 rows in 525-line systems / 16 rows in 625-line systems (max. 35 characters each)
        • smooth scrolling text display: 1 row of 40 characters
        • 8*16 pixel monospaced VGA fonts
        • over 200 selectable fonts (via PC)
        • 3 selectable speeds in the scrolling text mode
        • changeable vertical text position on the screen
TVO Project v.3
download button

The circuit uses as input a composite/RGB video signal. The font and the scrolling text for displaying are sent by a small PC app. (tvo_v3.exe) to the PIC and stored somewhere in its code memory area. This way there is no need to send data after every power-up of the circuit (last sent data will be available). In the scrolling text mode up to 24KB of data can be sent (or equivalent of a maximum 1h 10min duration can be displayed at default speed). Because the static text will be much more often changed than the scrolling one, it is saved in PIC's RAM. If you want to keep the same text position on the screen on every power-up or save the static text - do a master clear reset (reset on PIC pin 1).


2. Functional description

The microcontroller receives font and text data from the computer's COM port over the MAX232 at RB1 pin at 4800 bps (asynchronous reception emulated in assembly code for this pin). The PIC must also be synchronized to the incoming video. This is done over LM1881 - /VSYNC is needed to refresh some internal register values and horizontal sync pulses (taken from /CSYNC) needed to know when to drive the 4052 analog switch over the PIC's internal synchronous serial port.
The PIC is driven by a 27 MHz crystal clock source (an exact multiple of PAL and NTSC line frequency). Despite that, a jagged text on the video screen is displayed because this frequency is not fully synchronized to the incoming video line frequency (there is no genlock). You can use a programmable clock IC to improve that, but such chips are manufactured only using SMD technology - my search on the internet returned dissapointing results, unfortunately. My idea was to build the entire project with conventional parts still available on the market (i hope !) and an easy design for a home purpose. Keep in mind that the PIC must work at 27 MHz in order to accomplish its tasks properly. Some assembly routines are heavily dependent on this clock rate, and if your video source is not a standard or a good quality one, you may encounter problems. I have tested it on my satellite receiver with PAL and NTSC signals and it worked well.


schematic picture
Main schematic

Instead of MAX232 you can use a simple RS232 to TTL level converter like this one instead of MAX232 (i've found it on the internet). I think using other common NPN transistor or diode should work. In my design i've used a 100k resistor instead of the 10k one (the transistor is less saturated when on). The circuitry (in the main schematic) built around the 2 BC547B transistors act as low voltage regulators aimed to ensure constant levels on variable output loads (the 4052 inputs on/off). The 4052 switch has to "see" also 75 Ohm impedances on its inputs when switching between input video and inserted text and vice-versa. The output levels of the regulators must be adjusted in order to get proper video voltage levels, otherwise problems with the video may occur.
There are also switches at PIC pins available to perform other functions :

BKGD on/off - switches the background stripe on and off
HIGH/LOW SPEED - speed adjustment available only in scrolling text mode. If both switches are off the text will scroll at default speed
LINE UP/DOWN - changes the text position on the video screen
525/625 (or TV) syst. - important for the static text mode. If connected to GND 16 rows of text will be displayed (for 625-line systems), otherwise 14 when connected to Vcc (for 525-line systems). Don't let this pin unconnected !

If you live in Europe and have a SCART connection (or whatever connection where the R, G, B components are available as standalone signals), you can use the circuit to display color characters and background, but you have to add some extra hardware to it. In principle, an extra switch and a voltage level regulator for every component (R, G, B) is needed. A part of the circuit is already used in the main schematic (the luminance or B/W part). It should look like this:

color extension picture
Color extension to the main circuit

The transistors are common NPNs (prefferably with a high DC gain factor, 200 or above). Instead of normal resistors, series and parallel R networks can be used. The transistors can be replaced by an integrated array (like CA3082).
Please consider that some equipments which output signals over the SCART do not provide video components (R, G, B), only the composite signal. Even if they do, the input/display device may not accept them.


3. Demos

Here is some demo material of what the circuit can do:



static demo 

pic
Static text snapshot (video comming soon)



4. How to use it within your project

If you want to use this circuit as display module the static text mode can be relatively easyly implemented. I have decided to simplify the static text transmission making it more suitable to the practical use.
Do as follows:

    - transmission parameters: 4800 bps, 8 data bits, no parity, 1 stop bit
    - send BYTE1 + BYTE2 + your data (max. 35 chars) for every row
    - BYTE1 must not be 0x01 or 0x02 (used for other purposes)
    - you don't have to send all bytes of a row. In this case after a time of aprox. 2 RS232 packets length the PIC reception goes in time-out and the transmission will be considered terminated

BYTE1 should be either CR (CARRIAGE RETURN) or NL (NEWLINE) (0D or 0A hex). This signalizes to the PIC that new line of text is comming and the old lines will scroll up by 1 position. If you don't send it the lowest text row on the screen will be written, but if the text is longer that 35 bytes, the remaining bytes will overwrite the row from left to right untill the end of the sent text is reached. The value of BYTE2 doesn't matter, but it has to be transmitted always when other bytes follow quickly after that. During that time the PIC does some internal processings. If you send some relevant data during this byte it will be ignored. In the following lines you can see some examples:

Ex. 1.:
CR + NL + your text (max. 35 chars)
NL + CR + your text (max. 35 chars)
CR + NL + your text (max. 35 chars)
CR + NL + your text (max. 35 chars)
........
CR + NL (empty line)
........

Ex. 2:
your text (max. 35 chars) + NL + CR
your text (max. 35 chars) + CR + NL
your text (max. 35 chars) + CR + NL
NL+XX (doesn't matter) (empty line)
CR+XX (doesn't matter) (empty line)
........

It runs much like the text of an PC OS terminal window.

If you want to delete the whole screen send 16 times BYTE1+BYTE2. If you use the tvo_v3.exe chose "Enter static text (16 rows mode)" option, type ENTER key 16 times and chose "Send text" from the menu.
If you want to keep some rows empty just send BYTE1+BYTE2. If you use the tvo_v3.exe just press ENTER key as many times as you want to make room between rows like in any other text editor. In 525-line systems only 14 rows are visibile. Because the rows 1 and 2 are not, when using the "16 rows static text" options of tvo_v3.exe you should press the ENTER key twice before every 14 rows for your complete text to be displayed continuously on your next transmision.


5. How to use it on the USB port

This solution is suitable for PCs with no serial port. The direct connection of the circuit to the USB port is not possible. An USB to RS232 adapter/converter has to be used. Such hardware can be found on the market and is relatively cheap (for ex. chipsets based on versions of FTDI FT232 IC). You have to install a driver first (from the chipset's manufacturer or FTDI site). This driver will allow you to acces the USB+adapter pair as a virtual serial interface (you can check the Device Manager to find out which COM port is assigned to the adapter - it should be a new one). Then you have to set the communication parameters of the driver (the same as those for normal serial transmission described above). Your application should use the new port or you can use the tvo_v3.exe, but select the new port first.
I have a DELOCK 61460 chipset which works flawlessly on Windows Vista, but i would like to make it work on Linux (Mint). Untill now i managed to make tvo_v3.exe work only on the serial port using Wine 1.3. I would be grateful if someone could help me !


6. Changelog to the tvo v.2

   - 525/625-line system pin
   - PIC pins' assignement changed. Please take care (see the main schematic above) !
   - new and simpler way of sending static text data (less data/separately for every row)
   - no "complement" option anymore

If you have already downloaded and designed the circuit from the previous version, you have to change the PIC pins' connections. You have to reprogram the PIC and use the tvo_v3.exe from the package above (these 2 parts work only together - you can't use any old ones with any new ones).

Important notice !

This is a low resolution text overlay circuit and not a high resolution graphic overlay generator ! It doesn't make any kind of ASCII control character interpretation (except CR & NL) or special streams rendering (for ex. GPS) . You should use your own interface hardware and/or software to do that.
For troubleshooting please check the README file in the downloaded package.


Last change: May 2012
Powered by