Generating Composite Video

Hello, this is my first post after reading some months, please ignore any mistakes.

I just got this out of my arduino:

and no, i did not write the code myself, i only ported it to my arduino wich was not very hard, got the code from this website:

http://mitglied.lycos.de/polyxos/video.htm

I followed the (german) instructions and burned the resulting hex file into my board with my (eprom)programmer, had to use other fuse settings as the arduino uses a x-tal unlike the schematic on the site.

Now i would like to disassemble his code to make some mods, anyone know how to do this? is there a disasm with the arduino?

Maybe this is useful?

Oscilloscope using a microcontroller and a TV
http://www.nbb.cornell.edu/neurobio/land/PROJECTS/VideoScope/

Wow, lots of interesting links! I'm definitely gonna have a go at making a pong system when i get my arduino through! (after I get my darn university project finished too...)

http://mitglied.lycos.de/polyxos/video.htm

Since Germany uses the PAL TV standard it might not work on NTSC equipment.

http://mitglied.lycos.de/polyxos/video.htm

Since Germany uses the PAL TV standard it might not work on NTSC equipment.

as this is black&white (and there is no burst involved, PAL=4.43Mhz, NTSC=3.38Mhz) it might work on some Tv's because 50Hz * 625 lines = 31250 lines in PAL and 60Hz * 525 lines = 31500 lines so there is only difference of 250 lines/sec, it all depends on the vertical sync of the TV.

if we can get to the asm source I think it would be easy to change the 50Hz into 60Hz and the 625 lines to 525 lines.

Erik

I think possibly the problem might be that the DigitalWrite command takes a few microseconds to work... maybe you could try using port registers to switch the outputs?

http://www.arduino.cc/playground/Code/BitMath#registers

You might need to add up the cycles that you're using to make sure you get exact timing...

Sorry if all of what I've said is total rubbish... this is just my guess at a possible solution

I think possibly the problem might be that the DigitalWrite command takes a few microseconds to work... maybe you could try using port registers to switch the outputs?

Arduino Playground - BitMath

You might need to add up the cycles that you're using to make sure you get exact timing...

Sorry if all of what I've said is total rubbish... this is just my guess at a possible solution

I've actually had a feeling that that's where my problem is and I've been trying to figure out just how to figure out how long digitalWrites take. This page might help out though, I'll try it later tonight.
Thanks!

Yeah, the guy who did the pic pong counted each clock cycle- I'm hoping that the arduino's delay functions are accurate enough for this... does anyone know of a way to delay a specific amount of cycles in code? If a specific amount can be delayed, and one knows how many cycles each instruction uses, you could get perfect timing this way I should have thought...

The arduino does seem to have quite a bit more processing power than the pic he used, so i'm hoping you could get some better game logic in there...

Keep us updated with your progress though, this is one of the things i want to try when i get my arduino! Roll on a wave of arduino based games I say!

O.K. so after reading some about using the registers and applying it to some code I ended up with this


http://datablue.net/random/better_vid.AVI

Not perfect, but alot better than before!
This code still doesn't incorporate the vertical sync because I can't get the timing right. I think It might have something to do with the loop I'm using.

/* Composite Video Generation
 * ------------
 *
 * uses a 2-bit D-A converter to generate
 * voltages for composite video to RCA. This
 * code should generate continous white horizontal 
 * lines to create a fullly white TV
 *
 * Created 18 December 2006
 * copyleft 2006 Kyle Granat <http://www.datablue.net>
 * http://arduino.cc
 *
 * based on Rickard Gunée's pic work
 * http://www.rickard.gunee.com/projects/video/pic/howto.php
 * 
 * Register code from Cosine Kitty
 * http://www.arduino.cc/playground/Code/BitMath#registers 
 */


void setup()
{
        // set pins 0 (serial transmit) and 2 and 3 as output,
        // but leave pin 1 (serial receive) as input
        // (otherwise serial port will stop working!) ...
        DDRD = B00001101;  // digital pins 7,6,5,4,3,2,1,0
        // Turn off digital output pins 2 and 3
        PORTD &= B00000011;   // turns off 2..7, but leaves pins 0 and 1 alone

}

void loop()
{
  
  
    PORTD = B00000000;    // sets out to 0V for sync pulse for 4 uS 
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);

    PORTD = B00000100;//sets out to .33V  for 'porch'
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);
    delayMicroseconds(1);

    PORTD = B00001100;   //sets out to 1V(White)
    delayMicroseconds(52);   


}

My guess is that you might have some problems because of timer interrupts (or other interrupts?) messing up your timing. Just as an experiment, try adding this to the end of your setup():

cli(); // disable interrupts

Of course, this will mess up all kinds of stuff you might want to add later, like serial port I/O, use of timers, delay(), millis(), etc.

I say this because I was surprised when I tried generating radio frequency energy and encountered an unexpected tone modulated on top of what was supposed to be a pure carrier wave. See here:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1166896036

My guess is that you might have some problems because of timer interrupts (or other interrupts?) messing up your timing. Just as an experiment, try adding this to the end of your setup():

cli(); // disable interrupts

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

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.