Pages: [1]   Go Down
Author Topic: Generating composite video signals  (Read 754 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I am using an atmega328P running at 14MHZ.

I've been reading tutorials about how composite video signals works. For exmaple rickard's tut.
And I've been trying to generate something by myself. I got a white screen (I am not really sure what I am doing though). The white screen works fine though.
However, when I try to "paint" an specific line on the TV with other color, black for example, I get a flickering image, and it is not what I want.

I have a variable incrementing by one every 64us (that's one line, after the 4us sync signal, the next line should be painted and so on....). When that variable reaches 525, it will be reset to 0 (since the TV has 525 lines). It is not working for me though. here is the C code (not using the arduino code right now):

Code:
//PORTB |= ([b]PIN NUMBER[/b]); makes a pin HIGH
//PORTB &= ~[b](pin number[/b]); makes a pin LOW
int count = 1;

//(4us pulse) Sync with tv (like the enter key)
void sync()
{
        PORTB &= ~(1<<PB3); //SYNC : 0V (low)
        PORTB &= ~(1<PB2);
      _delay_us(4);

      count ++;

}

//Paints one line
void paintLine( int color )
{
    if( color == 0 ) //BLACK
    {
       PORTB |= (1<<PB2); //LOW
      _delay_us(60);
      PORTB &= ~(1<<PB2); //HIGH
      _delay_us(0);

    }

    else if ( color == 1 ) //WHITE
    {
       PORTB &= ~(1<<PB2); //LOW
      _delay_us(16);
      PORTB |= (1<<PB2); //HIGH
      _delay_us(44);

    }

    else if( color == 2 )
    {

        _delay_us(8);
        PORTB &= ~(1<<PB3); //LOW
        PORTB |= (1<<PB2); //HIGH
      _delay_us(51);
      PORTB |= (1<<PB3); //HIGH
      PORTB &= (1<PB2);
     _delay_us(1);

    }

}

int main() {
//PB3 AND PB2 AS OUTPUTS
DDRB |= (1<<PB3);
DDRB |= (1<<PB2);


  while(1) {

if( count <= 400 )
{
paintLine(0);
paintLine(2);
sync();
}
else sync();
}

if (count >= 525) count = 1;

  }


  return 0;
}
« Last Edit: January 31, 2010, 09:25:49 pm by lcruz007 » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It is not working for me though
What isn't working?
Your RS170 signal is missing something?

Your program has a "main", so it isn't really an Arduino problem, is it?

(Could you maybe edit your post to use the code (#) button, please, and get rid of the highlighting?)
« Last Edit: January 31, 2010, 02:52:36 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
God Member
*****
Karma: 32
Posts: 506
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your code doesn't look like it does the vertical sync correctly. The first 6 lines and the last 3 have a different sync pattern to the others. Look at the diagram condemned posted at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264187235/15#15 (but remember NTSC is 262 lines instead of 312)

Also you are sending all 525 lines at once, that isn't right, you should only be sending 262 lines each frame. 525 lines requires interlacing which has even more complicated sync timing. Unless you understand interlacing it's best to just do 262 lines.
Logged


MD, USA
Offline Offline
God Member
*****
Karma: 2
Posts: 663
A jack of all trades and a master of none!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've played around with this myself. You will run into allot of timing issues on this. You will also be limited to black and white. Adding more colors is outside the ability of the arduino.

Here is my code for it.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264187235

The most successful working of composite for the arduino has been done here. Your better off with a TellyMate shield to handle it all.
http://www.batsocks.co.uk/products/Other/TellyMate.htm#nogo

He outlines how to use the arduino itself as the TellyMate in this thread.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1258854659
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies. I will make sure to add the VSync and let you know my progress. Just some few questions...

The Vsync should be a 64us signal? Is the horizontal sync be 64us too?
Shouldn't be the whole signal for each line a 64us signal with the VSync, blanking, and display? smiley


Thank you!
« Last Edit: January 31, 2010, 10:48:12 pm by lcruz007 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bump
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24321
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's a fairly simple description of the signals:

http://www.sxlist.com/TECHREF/io/video/ntsc.htm
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: