Full Version : Vasilis Video Color Bar Generator (ASM)
avr >>GAME & VIDEO PROJECTS >>Vasilis Video Color Bar Generator (ASM)


Admin3- 04-19-2006
AVR composite PAL colour bar generator

After lof of reading books, articles and discussions with lot of electronic technicians, finaly I did it. I make an 6 colour bar generator entire-in-software with AT90s2313-10 overclocked at 17.734475 MHz !!!

Designed by: Serasidis Vasilis

I start this project 3 weeks ago, because I was wonder " is that possible, some AVR MCU to create simple colour bars? " At the beginning I believed that its easy. So, I ask some people who they knew more about PAL composite video signal. Some of them told me that is impossible to product color entire-in-software with AVR MCU (microcontroller) because there is not enough power (frequency).

The first idea they was to work with 8.867238 MHz crystal (2 times the color carrier). When I read more about PAL video composite signal creation, I saw that, if you want to product colors entire-in-software you must to create the color-carrier (4.43 MHz), to change 4 times the phase of color-carrier (one time for each color), to show 4 colours. Except that, you have to change the color-burst from 135 deg to 135+90= 225 deg.

So, the 8.86 MHz its not enough, that`s why I used 17.7 MHz crystal (4 times the color carrier). The only easy is to create the white and the black bar, the rest of this project, beleave me, its not easy.


The timing (clock cycles) of any instruction is very important for the phase-shift of the color-carrier and color-burst signals. Calculate the cycles before add or remove any instruction.


The circuit (See Attached File)

The circuit it is constituted by AT90s2313 running at 17.734475 MHz (overclocked) and one, 5 bits DA converter (R2R-ladder) with 10 resistors.

I know, its not good to overclocking 77 % up from the working frequency of the MCU, but for a few hour, nothing wrong it will happen.

Programm the MCU with colour_bar_gen.hex that its included in colour_bar_gen.zip file, connect it on composite video connector (or scart adapter) of your TV, power-on the circuit and you will see on TV, 6 vertical bars, 4 in color, 1 white and 1 black.



I don't make any explanation about "how does the PAL video signal its working" because nor and i I understood exactly how does its work. Thats why my circuit have some problems with color-hue. May be some one of you, have the knowledge and the time, to continue this project..
CODE

;
;**************************************************************************************************************************************************
;*
;*  PAL VERTICAL COLOUR BAR GENERATOR
;*
;*  Author:  Serasidis Vasilis
;*  Writed:  14-08-2003 with AVR Studio 4.02
;*  Version: 0.1 beta
;*  Target:  AT90S2313-10 overclocked at 17.734475 MHz
;*  Web site: http://www.serasidis.gr
;*  eMail:  info@serasidis,gr
;*  
;*
;*  This PAL vertical colour bar genarator based on AT90s2313-10 MCU, overclocked at 17.734475 MHz !!!
;*  because there is no AT90Sxxxx at this frequency. Near to 17 MHz is AT90S1200-16 but i could`n find it on the market.
;*  For Analog to Digital converter i used R2R-ladders with 500 ohm and 1 Kohm resistors connected to PortD.
;*
;*  This source code its not complete. Its working, but the colour-hue its not the same in all TVs.  
;*  The colors from the left of the screen are: white, magenta, orange, green, blue and black.
;*  I leave this source code, to continue it, someone else.
;*  I dont make any economy to the flash-memory. I leave the code extended, for modifications.
;*
;*  Remember!!!
;*   - The timing of the instructions is very important.
;*    - Do not remove any 'Nop' intruction without replace it with someone else instruction.
;*
;*  Inform me if you improve this source code
;*  Good luck
;*
;***********************************************************************************************************************************************
;
;
;
;
;
.include"2313def.inc"
.def temp  =r16
.def delay =r17
.def burst =r18
.def zero =r22
.def one  =r23
.def up_color =r20
.def down_color  =r26
.def color_bar =r27
.def wreg2   =r30
.def up    =r28


 ldi temp,RAMEND
 out SPL,temp;Init Stack Pointer


 ldi     temp, 0b01111111       ;set port D bits to outputs
 out     DDRD, temp

;----------------------------------------------------------------------
reset:
 clr  zero ;zero voltage level
 ldi  up,30 ;high voltage level (1.2V - white color)
 ldi  burst,1 ;
 ldi  one,8 ;low voltage level (0.2V - black color)
 ldi  up_color,10;High level for color carrier (1V)
 ldi  down_color,6;Low level for color carrier (0.38V)
 ldi  wreg2,6
 

start: ldi  color_bar,4;Number of color bars (4 color bars + 1 white + 1 black)
 ldi  one,8
 out  portd,one

 ldi  up_color,10 ;set the up-voltage level for color burst  
 ldi  down_color,6;set the down-voltage level for color burst
 ldi  one,8  ;set the midle-voltage level for color burst

 ldi  delay,2  
 rcall again  ;17 cycles delay

 out  portd,zero ;start the orizontal sinchronization
 rcall delay2  ;delay 6.44uS (115 cycles. 1 cycle=0.056uS at 17,734475 MHz)


 out  portd,one
 nop
 nop

 ldi  delay,2  
 rcall again ;17 cycles delay


 dec  burst ;starting color-burst with 135 deg the 1st scan-line. To the 2th scan-line add 90 deg more. Sum 90+135=225 deg.
 breq color_burst;If its on the first scan-line, go to 'color_burst'
 ldi  burst,1 ;if its on the 2th scan-line...
 nop ;
 nop ; invert 90 deg (sum 135+90=225 deg)
 
color_burst:
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one


 out  portd,up ;Show the white color (1st color bar)
 rcall delay

 ldi  up_color,29 ;set the up-voltage level for color carrier
 ldi  down_color,10 ;set the down-voltage level for color carrier
 ldi  one,14   ;set the midle-voltage level for color carrier
 nop

color_carrier:
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one

 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one

 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one

 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one
 out  portd,down_color
 out  portd,one
 out  portd,up_color
 out  portd,one  ;146 cycles
 out  portd,down_color

 dec  color_bar ;check if is the 5th color-bar (blue)
 breq start2  ;if yes, go to start again from the beginning
 rjmp color_carrier;if not, go to show the next color-bar (151 cycles)
;------------------


start2: out  portd,wreg2 ;Show the black color (6th color bar)
 rcall delay
 rjmp start
;--------------------

;
;---------------  Delay   ----
delay:;delay 152 cycles (51,072uS/6 bars = 8,512uS = 152 cycles)    
 ldi  delay,63;55;48
again: dec  delay
 brne again
 ret
;-------------------------
delay2:;delay 115 cycles    
 ldi  delay,24
again2: dec  delay
 brne again2
 ret




Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.