I've been trying to generate some composite video signals based on the following website
http://www.rickard.gunee.com/projects/video/pic/howto.phpBasically each horizontal scan the electron gun shoots corresponds to a 64uS waveform. The first 4uS are the sync pulsem the next 8uS prime the electon gun, and the last 52uS correspond to the asctual image you see( .3V is black and 1V is white)
I'm using the same Digital to Analog converter shown on the website

to generate 0V, .33V, .67V, and 1V based on pin 2(D0) and pin 3(D1). I tested the different voltage to make sure I haven't wired anything wrong, and the hardware seems to be fine.
My code should just continously display lines white, but I'm getting moving white and black lines.
http://www.datablue.net/random/badVid.AVI/* 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
*/
int d0 = 2;
int d1 = 3;
void setup()
{
pinMode(d0, OUTPUT); // sets the digital pin as output
pinMode(d1, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(d0, LOW); //sets out to 0V for sync pulse for 4 uS
digitalWrite(d1, LOW);
delayMicroseconds(4);
digitalWrite(d0, HIGH); //sets out to .33V for beam ready pulse for older tvs
digitalWrite(d1, LOW);
delayMicroseconds(8);
digitalWrite(d0, HIGH); //sets out to 1V(White)
digitalWrite(d1, HIGH);
delayMicroseconds(52);
}
I've tried some other waveforms( another site said the wave form should be a 2uS black pulse, a 4us sync pulse, another 4uS black pulse, and a 54uS image data) but still didn't get proper results.
I've also read that it should be 63.5uS not 64uS.
I beleive it's a timing problem with my sync pulse (possibly becuase the digitalWrite() function is taking a few microseconds or beacuse the delayMicroseconds() isn't accurate enough?)
Has anyone tried this or have any ideas/tips?