Generating Composite Video

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.

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.)