Generating Composite Video

I disabled the interrupts but nothing noticable has changed. Thanks for the suggestion though.

Any news? :slight_smile:

Here is a video overlay project using the ATmega8 [...]

http://www.knology.net/~gdion/videoverlay.html

Hi, do you understand what's Q1 specifications in that schematic?

Thanks,
Superware

Any news? :slight_smile:

Still working on it, though classes seem to be getting in the way :3
I might get a chance this weekend to tinker some more, but no real progress as of late.

Also q1 in the schematic is a pnp transtor. I'd imagine a 2n3906 would work fine.

I'm going to start work on an ASM version of this to get the timing exact.

How would I go about writing a block of ASM code in C? Would you just stick all the lines in an asm() ?

Looking forward to any updates on this. Also, anyone knows if it would be possible to create a video overlay (OSD) with Arduino?

Looking forward to any updates on this. Also, anyone knows if it would be possible to create a video overlay (OSD) with Arduino?

http://www.knology.net/~gdion/videoverlay.html

Thank Erik,

That is a very valuable link!

Cheers,

JD

hello,

I had the same idea : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1176757335.

Now I'm giong to read your post, I have some timming pbroblems in interruption mode...

Hello,

I've read the post. You have the same problems :slight_smile: of timing.

Could we try to resolve them together ? My project is working in the loop() function, everything is ok. I try do it with interupt but I don't have an oscilloscope to fine tuning synchro.

Hi everyone,

I just stumbled on this thread while looking into something else entirely (curse you stream of consciousness browsing).

Some of us did this a few years ago with a pair of PIC 18f452s in CSS C at 40MHz. One PIC set up the video environment, and on interrupt we used a second one to read inputs and do our "drawing" routines.

As I recall, it was a pretty crude effort, but it worked well enough for our purposes. You can look at the project notes and code here : http://droolcup.com/pictv

~s

Hello droolcup,

Thank's for your post. I've just seen the video of your project. I have the same result with interrupt, one somme image configuration there some lines are "overshooting", it depends of the white surface on screen...

I think I'll have to write some parts of the code in asm to be sure of timings.

The best way that I've seen to do this is by using 2 micros- one of them is programmed in ASM and reads the pixel data from a ram chip, which the other micro updates. There would be a sync line between the two to make sure one isn't trying to write while the other is reading. This would eliminate timing problems and also allow for more complex programs to be run.

I'm thinking of giving this approach a try soon- what does everyone think?

Maybe this is just crazy talk, but couldn't you try and generate your sync signal with a bi-stable oscillator, you'd want to watch that with the MCU so that you don't keep sending data as your sync goes off, if not using the oscillator directly, you could use it to keep track of were you are in your output (send the sync with the MCU, but use the oscillator to time everything right.

(Please excuse any tyops I've made, it's late, and it's hard for me to keep up with my high standard of typing when I'm tired.)

Hello,

Yes, I'm thinking about soltions with external components. But, at first I want to do it the best without active components. It's a challenge with Arduino Board :). I will try with some asm code include in C code...

Hey Benoît ROUSSEAU,

Just want to say good luck! I hope you'll find a way to get it to work eventually, meanwhile I can dream about arduino pong!

-Z-

I stumbled upon a site where they sell all kinds of electronic video/audio instruments. There's a lot of interesting information about how these guys managed to get the video output running.. They use a ARM7TDMI Microcontroller in conjunction with an AD725 RGB to PAL/NTSC encoder IC from Analog Devices. They run a crystal at 4 times the video burst frequency to get stable output, it still only handles 256 colors at a 160 x 128 resolution. But it looks like lots of fun to play with, it could also be interfaced with an arduino board. Programming the microcontroller itsself requires C skills and the GNU toolchain, a flash utility and an USB board (i bet the arduino can also be used as an Serial/USB interface to program this board).

http://www.critterandguitari.com/catalog/index.php?main_page=product_info&cPath=1&products_id=13

Hi All,

Possibly this should be a new thread, but the "generating video bboard" is pretty close to my question:

Has anyone written code to detect the vertical blanking interval in an incoming NTSC composite video signal (RS-170A)?

I'm creating a project in which I need to switch a circuit on and off, precisely in sync with the video fields from an NTSC video source. In order to do this, I would need to sample the video signal fairly frequently and write an analyzer/detector for the vertical blanking interval, which is used to synchronise the video frames.

Any advice would be greatly appreciated before I bore headlong into the oscilloscope.
Thanks,
Golan

hi

you can get a single-chip solution for that: they're called sync separators. The LM1881 comes to mind. It only needs +5V, 3 capacitors and two resistors. In return, it provides the vertical and horizontal sync, as well as the field (odd/even) and the back porch signal form a composite video signal. It's about $3 US.

D

PS: there is an interesting article at this link, with code and schematics, on using the above chip with an AVR to create a motion detection system.

this was just posted via Make Magazine... an AVR based video overlay. Interestingly, it uses the LM1881 to separate sync, and then one pin pulls the video level to generate the overlay.

D

I managed to get the Arduino generating a PAL signal. My TV syncs to this signal without any problems. I followed the specs for a PAL signal as close as possible. It uses asm nops to try and get more precise delay times. Each nop is a 65ns delay (1 instruction at 16 Mhz...it should be 65ns but i don't have a good enough oscilloscope to check). The PAL signal has +- 0.3 microseconds leeway on the sync signals anyway so it works ok.

The code generates a white bar in the middle of the TV. Here is the first half.

int pixel = 6;  // Connected to 550ohm resistor (Should be 470ohm)
int sync = 7;   // Connected to 1k ohm resistor
int i;

void setup()
{
  pinMode(pixel,OUTPUT); // Switch to output pin
  pinMode(sync,OUTPUT);  // Switch to output pin
  cli();                // Turn off interupts
}


void loop()
{
  //
  // Generate 5 Narrow Equalization pulses
  //
  PORTD = B10000000; // Make the sync high to start with
  for(i=0;i<5;i++)
  {
     PORTD = B00000000; // Sync pulse goes low and delay 2.3 microseconds
     delayMicroseconds(1);
     delayMicroseconds(1);
     __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
     PORTD = B10000000; // Sync pulse goes high and delay 29.7 microseconds
     delayMicroseconds(29);
     __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
  }
  
  //
  // Generate the 5 Field Sync Pulses
  //
  for(i=0;i<5;i++)
  {
    PORTD = B00000000; // Sync goes low and delay 27.3 microseconds
    delayMicroseconds(27);
    __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
    PORTD = B10000000; // Sync goes high and delay 4.7 microseconds
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
  }
  //
  // Generate 5 Narrow Equalization pulses
  //
  for(i=0;i<5;i++)
  {
     PORTD = B00000000; // Sync pulse goes low and delay 2.3 microseconds
     delayMicroseconds(1);
     delayMicroseconds(1);
     __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
     PORTD = B10000000;
     delayMicroseconds(29); // Sync pulse goes high and delay 29.7 microseconds
     __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
     
  }
  // Generate 18 Blank Frames
  for(i=0;i<18;i++)
  {
    PORTD = B00000000;    // Pull sync pin low -> 0 volts
     delayMicroseconds(4);
    __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
    PORTD = B10000000; // Pull sync pin high
    delayMicroseconds(59);
  }
  //   
  // Generate half the Image 
  //
  for(i=0;i<285;i++)
  {
    //
    // Front Porch
    // 
    PORTD = B10000000;
    delayMicroseconds(1); // Front Porch: 1.65 microseconds
    __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
    
    //
    // Generate sync pulse
    //
    PORTD = B00000000;    // Sync pulse pulled low: 4.7 microseconds
     delayMicroseconds(4);
    __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
    
    //
    // Back Porch
    //
    PORTD = B10000000;    // This is the back porch: 5.6 microseconds.
    delayMicroseconds(5);
    __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
    
    //
    // Drawing starts here: Total time available is 53 microseconds
    //
    PORTD = B10000000;    // Draw black
    delayMicroseconds(20);
    PORTD = B11000000;    // Draw white
    delayMicroseconds(10);
    PORTD = B10000000;    // Draw black
    delayMicroseconds(22);
    

  }