Simulating VGA Signal

Hello !

/*basically, we do this: lines 0-9 front porch lines 10-11 Vsync lines 12-44 BackPorch lines 45-524 ActiveVideo

so, the logic is, if we're on line 10, start vsync, line 12, stop vsync. If we're in 45-524, do an hsync. */

I've just been reading these lines, and there are some mistakes :

  • every (i mean every) line must start with a front porch, not only the 9 first lines. These are black lines. A typical line is : 0.63µs high (front porch, video must be stopped at this point) 3.81µs low (hsync signal) 1.906µs high (back porch) 25.42µs still high (visible area, video can be sent) The first 9 lines are build like above, except there's no video during the 25.42µs of visible area.

  • On lines 10 & 11, we do the vsync pulse thing by putting the vsync line low during 2 lines (that's 0.06355ms). During those lines, we continue the hsync routine. Vsync pulse (remember that the front porch of the vsync pulse has been done during the first 10 lines of the screen) : 2 lines low (pulse) 33 lines high (vsync back porch) 10 + 2 + 33, we get 45 non-visible lines for a 640x480 resolution (800x525 actually)

  • We continue the hsync routine with black lines until the 45th. You can send some color from the 46th line to the 525th.

  • It's important to remember that you shouldn't send video signal during the sync pulses (that is, front porch + sync pulse + back porch time), H or V. That could be interpreted by the screen as a sync pulse.

  • my advice is : do no try to make fancy stuff at first. Start with trying to display a nice & solid red, blue or green. If you want to put 1v on the color lines with the 5v of your arduino, put a 300ohms resistor in series. It will do a voltage divider with the 75 ohms resistor that's in your screen. You can also try to send 5v directly to your screen, mine has survived ! Concerning the sync lines, you need a 75 ohms in series.

  • try my code and tell me if it works ;)

  • ok, I read the rest of your post, you don't need every word i wrote, but hey, it's typed ;D

Ahh. My code commenting is a bit out of date, and incomplete, I see. When I started this project, I thought you only had an HSYNC in the active video area. It didn't work at all. :P After reading your source, though, I added HSYNCs every line, and it got closer to working.

The comment you quoted was actually just talking about VSYNC. lines 0-9 the Vertical line is held high, for lines 10 and11 , the line is held low for the pulse, and then it comes back up. lines 12-45 are the vertical 'back porch', between the vertical pulse and the start of actual active video.

Yeah, I really need to clean up my comments. :D

I tried your code, connecting vsync and hsync directly, and your 'video ready' to VGA red, with the resistor in series. It still had sync issues. I'm out of town for the weekend, but when I get home, I'll try putting the 75 ohm resistors in line for the syncs, and see if it makes a difference.

Out of curiosity, have people tried this on LCD monitors? I was thinking the problem might be that older, actual CRT, monitors actually used the HSYNCs and VSYNCs, and so a bit of timing difference wouldn't be a big deal, but the modern electronics might expect more exact timing.

The 75ohm resistors should make the difference, I had similar issues without : red screen coming and then going away.

Some screens don't like my sync signals : I'm driving 16 identical CRT screens with 1 arduino, they all sync correctly. I had to change one screen, this is the only one not syncing ::)

I didn't have 75 ohm resistors, so I tried 100 ohm. I still have the same sync problems. I have the same problem both with my program and yours.

Here you are!
http://www.linusakesson.net/scene/craft/

I am the one who posted the eagle schematics in the reply :3

I came across that project before. It’s very impressive. :slight_smile:
I notice that it just ties HSYNC and VSYNC to the pins, so I suppose that’s doable. I tried to slog through the pure-assembly source, but I’m tired at the moment.

Well, I have good and bad news! I tried generating NTSC signals, and was having similar sync issues. I then had an epiphany - perhaps the standard timer was popping up at inconvenient times and throwing things off?

I disabled Timer0, and things were smooth and perfect!

However, now my arduino is stuck in a watchdog loop, and the only way to fix, apparently, is to re-burn the bootloader. This may or may not be related. Once I get that fixed, I'll see if it works for VGA, too.

;) thumbs up !

I can confirm now, on VGA as well - Disabling Timer0 makes things work nicely. Of course, this means you can't use PWM on certain pins, or millis(), but who needs those anyway? :P

Sorry to be dense, but I have to ask, how do I disable Timer0? Is it simply adding "cbi (TIMSK0,TOIE0);" to the setup routine? Also, if I want to generate some basic rgb pulses like little-scale does, should I use the analog ports? or the digital ports? Thanks in advance!

I want to know too how to send some RGB signals, just some lines f.x.??

hey guys,

sorry for reopening this thread again and again but this seemes the most relevant thread on the vga topic. i just wanted to know if someone of you really gettings things done? it seems that i got sync working with the code of dwan, but how sending signals is a bit confusing me. can someone post an example on how you managed sending colorsignals and how you connected the vga cable? i am bit confused about conecting the mass cables of the vga, are they all conected to grnd?

has someone atached the sending of color information to dwans code?

i am getting quite desperate about this whole thing.

Hi there Actually, i have another arduino sending the colors.

In order to generate the colors, i used 3 TLC5940, 16*3 homemade vactrols, and 16*3 low-pass filters. The TLC can generate 16 PWM waves, running into LEDs, facing LDRs, going thru a LPF, part of a voltage divider, running into an opamp. I would certainly simplify this if i had to make it again, but i was running out of time and used only things that i knew they were working.

You have to know that the color signals must occur only when you're supposed to see colors on the screen. I've spent days to figure that ;D, just because I thought that the screen was "reading" color values when it needed. It means that the second arduino (color manager) has to be aware of when it have to send colors, and when not. Luckily, i found a video-purposed opamp (AD813ANZ) that makes it easy to do, because it has three "disable" pins. These pins are plugged to the pin of the first arduino (sync manager) that is LOW when color can be sent, and HIGH otherwise. That's the purpose of this special pin.

Concerning the ground cables, i soldered them all together, as i was using the same ground reference. You have to do some experiments, as i had sometimes to deal with noise. I used CAT5 cable (8 wires, cheap and reliable), so i had not that much possibilities for wiring. I had to make 16 cables, 6.5m each, worked well. Using the same ground or not depends on if you use the same ground ref for sync and colors. If i remember, each wire (2 syncs and 3 colors) has its own ground wire, so it means that you could send 5 signals with 5 differents ground refs : the screen would accept, as it's isolated (that's the assumption i made ;D )

Picture of the beast :

hey dwan thanks for your reply. your beast looks amazing. do you think that it is possibel to sync two arduinos without an extra ic? are there examples of what your videosynth generates? i managed to get the code of YenTheFirst run, with his help, to generate both sync and colors with one arduino. until now the sync doesnt work realy nice, so i have to do some tests. does someone know if there is an trick to generate random values on low level assembler base. or is it possibel to speak to random pins? switch it on and of randomly?

Thanks :) Well, i guess you can use the serial ports to sync two arduinos, but since you're doing something both time and data critical, it won't be easy : that's why i'm using two arduinos : one to manage the serial link, one to generate the interrupt-intensive sync signal. I tried with only one arduino (generating color and sync, and handling midi messages) but it would lose either bytes or sync ;D

This videosynth only generates plain colors (127³), no fancy stuff. It's controlled via midi, with a Pure Data patch.

If you want to address random pins, you could read the value of a floating analog pin.