Poitiers (France)
Offline
Full Member
Karma: 0
Posts: 136
Ca va j'vais le faire !
|
 |
« Reply #30 on: April 20, 2007, 09:22:40 am » |
Hello, I've read the post. You have the same problems  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.
|
|
|
|
|
Logged
|
Cordialement, Benoît ROUSSEAU
|
|
|
|
Brooklyn
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #31 on: May 10, 2007, 03:49:13 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Poitiers (France)
Offline
Full Member
Karma: 0
Posts: 136
Ca va j'vais le faire !
|
 |
« Reply #32 on: May 10, 2007, 04:10:37 pm » |
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.
|
|
|
|
|
Logged
|
Cordialement, Benoît ROUSSEAU
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 15
|
 |
« Reply #33 on: May 21, 2007, 07:43:17 pm » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 5
|
 |
« Reply #34 on: May 25, 2007, 01:43:15 am » |
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.)
|
|
|
|
|
Logged
|
|
|
|
|
Poitiers (France)
Offline
Full Member
Karma: 0
Posts: 136
Ca va j'vais le faire !
|
 |
« Reply #35 on: May 25, 2007, 06:04:42 am » |
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...
|
|
|
|
|
Logged
|
Cordialement, Benoît ROUSSEAU
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 221
|
 |
« Reply #36 on: May 25, 2007, 10:29:11 pm » |
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-
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 23
Arduino rocks
|
 |
« Reply #37 on: June 12, 2007, 07:01:40 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #38 on: June 16, 2007, 06:16:08 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
|
|
 |
« Reply #39 on: June 16, 2007, 09:00:31 pm » |
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.
|
|
|
|
« Last Edit: June 16, 2007, 11:37:52 pm by Daniel »
|
Logged
|
|
|
|
|
|
|
 |
« Reply #40 on: June 26, 2007, 07:00:17 pm » |
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. http://garydion.com/projects/videoverlay/D
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 40
Arduino rocks
|
 |
« Reply #41 on: July 14, 2007, 07:47:54 pm » |
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);
}
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 40
Arduino rocks
|
 |
« Reply #42 on: July 14, 2007, 07:50:15 pm » |
And the other half....just a copy of the first half  Cut and paste both of these into one file and it should be good to go. // // 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"); // 0.3 microseconds 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"); // 0.7 microseconds } // // 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"); // 0.3 microseconds 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"); // 0.7 microseconds } // Generate 18 Blank Frames for(i=0;i<18;i++) { PORTD = B00000000; //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"); //0.7 microseconds PORTD = B10000000; delayMicroseconds(59); } // // Generate the next half of 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); } }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 15
|
 |
« Reply #43 on: July 15, 2007, 03:30:09 pm » |
Nice, I'll have to give this a go in a bit 
|
|
|
|
|
Logged
|
|
|
|
|
Ponferrada, León (Spain)
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #44 on: July 22, 2007, 06:59:32 pm » |
Yet another link, this one is written for Arduino in pure C (not Processing nor assembly) http://hklab.net/wiki/TV_Video_Signal_Generator_with_ArduinoI'm a fortunate man because I have an oscilloscope and I have seen that - delayMicroseconds doesn't work for delays lower than ~5us
- digitalWrite() is terribly sloooooow so don't use it
- When the loop() function finishes, there is a 10us extra delay (?)
Conclusion: don't use Processing to accomplish a hard real-time task like this. Use C or assembly. Sorry for my poor english. Regards, Javi
|
|
|
|
|
Logged
|
|
|
|
|
|