Arduino generated VGA (color) signal - Complete!

Hey guys,

By the picture above we can notice that the problem with the black area was solved, and now, the entire screen is filled, so we can print on any corner (640x480 @ 60Hz). The problem was the interrupt function, the time of calling and returning was taking so much time for an ATmega328, I replace the functio call for an "if", checking the timer register all the time. When the timer gets a defined value (31.3KHz), the "if condition" is true and the line is printed. This way the program is not wasting time calling and coming back from the interrupt function.

Another problem was that only CRT monitors were understanding my signal. The problem was the voltage level, now I am using a resistor in series with a diode for R, B and G, forcing my TTL (5V) signal to become 0.7V, as VGA standards says, and any VGA monitor (including LCD and LEDs) can print the signal.

So, everything is solved now, and we can generate color VGA sinal.

Now, I will try to create a library intelligent enough to design shapes and letters, and maybe generate more colors.

Everything using just an Arduino UNO. :))

Here is the code I wrote. Enjoy! We are here to share.

http://pastebin.com/F5Gnewm8

If you are going to try this, you must know this too:

And this:

"VGA industry standard" 640x480 pixel mode

General characteristics

Clock frequency 25.175 MHz
Line frequency 31469 Hz
Field frequency 59.94 Hz

One line

8 pixels front porch
96 pixels horizontal sync
40 pixels back porch
8 pixels left border
640 pixels video
8 pixels right border
---
800 pixels total per line

One field

2 lines front porch
2 lines vertical sync
25 lines back porch
8 lines top border
480 lines video
8 lines bottom border
---
525 lines total per field 

Be aware of turning your RGB signal off when sync pulsing.
And open your eyes for what the compiler is doing (or trying to do) when reading your code. A lot of time is wasted in many situations, and the non-repetitive ones are the most dangerous.

If your signal is not in perfect sync, the monitor will reject your signal.

Use the osciloscope to monitor all this things. 

Good luck and count on me if you need help!

Views: 54321

Comment by Marcelo Rodrigues on August 30, 2012 at 8:11am

Mark,

The diode will keep the voltage in 0,7V. That is why I use it in that picture. But I suggest you use resistors.

:)

Comment by Artur Pacholec on February 14, 2013 at 5:26am

Could you post a better picture or a drawing of how to connect VGA to Arduino? I know where R,G,B,VSync,HSync go, but I see that you also have ground there and I'm not sure where it's connected, is it just GND or RGND, GND, BGND or SGND.

Could you also tell me what kind of diodes are you using, cause I'm getting 0.8V when using mine and maybe that's why it's not working for me.

Comment by Artur Pacholec on February 14, 2013 at 12:02pm

Ok so I used 1N4148 diodes, 470 ohm resistors, connected ground to everything from pin 5 to 10 and I got it to work... sort of. I'm using only your code, nothing extra and I'm getting the color bars but the screen keeps blinking all the time. I'm guessing it has to do with the timing, but why would it blink for me and not for you? I tested on two LCD monitors, don't have a CRT :(

Comment by Marcelo Rodrigues on February 16, 2013 at 3:11pm

Artur,

Sorry the delay.

Man, perfect! If you are seeing the bars, you are almost there, even if it is blinking.

I worked for several weeks seeing absolutely nothing on the screen (was pretty frustrating).

Now, what you have to do is adjust the timing. If you have an osciloscope, this will be easier. If not, you can try changing the quantity of "NOPs" on the code, so you will be adjusting the delays, and then the frequency. You can try adding or subtracting NOPs.

First, reduce the NOPs for each color (all of them). The bars will get narrower. Probably the screen will stop blinking, then you can change the end of the code (less NOPs after the black).

Good luck!

Comment by Kirill Vasin Valerij on June 17, 2013 at 5:50am

Great project!

How can I draw pixel or rect on some x_y_ coordinates? Is it possible to draw small image(256x240 or other) from flash memory (progmem)?

Thanks.

Comment by Marcelo Rodrigues on June 17, 2013 at 6:33am

Kirill,

Thanks!

Sure you can, just set your code to change the color between a given line and another (black-any color), depending on the size you want. Same thing for the columns.

You can create a function for that, and call it anytime you want to draw a rectangle.

Good luck!

Comment by Kirill Vasin Valerij on June 17, 2013 at 8:17am

And...

BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
delayMicroseconds(3);NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP;
BLACK;
NOP;NOP;NOP;NOP;

How long does it take? I mean [.us]. I know that asm("nop") takes 62.5ns.
Comment by Kirill Vasin Valerij on June 19, 2013 at 10:22am

It takes: 1/[Line frequency]*1000000 = .us, isn't it?

Comment by Jay Curtis on August 20, 2014 at 3:36am

Hey, great stuff! Found this site through searching for a solution to get VGA to work with LCD and projectors via arduino.

Could you please post a schematic to demonstrate how to drop down the 5v to 0.7v? Knowing how to do this is beyond my knowledge level and it is a little difficult to see what you've done from the photo.

Cheers!

Comment by Marcelo Rodrigues on August 20, 2014 at 4:56am

Jay,

Here it is. Enjoy!

Comment

You need to be a member of GarageLab (arduino, electronics, robotics, hacking) to add comments!

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

Igor Golov is now a member of GarageLab (arduino, electronics, robotics, hacking)
Thursday
Marco is now a member of GarageLab (arduino, electronics, robotics, hacking)
Monday
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Thanks for the advice. I will persist with the code till I get it done. thanks once again."
Apr 18
Marcelo Rodrigues commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
""The output waveforms on oscilloscope for Hsync and Vsync and for that matter RGB pins are not…"
Apr 17
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Hi  Marcelo I am trying to make this code work with Attiny 44a operating @ 20 MHz. I have…"
Apr 17
Profile IconReal NOiseux, Muhammad Ali, bob v and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Apr 17
baiqian is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 10
Profile IconDavide and Almas Amandossov joined GarageLab (arduino, electronics, robotics, hacking)
Apr 6
Profile Iconvamoalrenga and John Ferrell joined GarageLab (arduino, electronics, robotics, hacking)
Apr 3
Marcelo Rodrigues replied to FiniousFingers's discussion New to group
"Yes, please share your progress here. Thanks and good"
Mar 27
FiniousFingers replied to FiniousFingers's discussion New to group
"Thanks, good to know someone is out there. I will be…"
Mar 27
Edward Evans replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Have you moved forward with any action?  I would be interested in discussing your…"
Mar 27
Marcelo Rodrigues replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Ed, No, they didn't deliver yet.  :( Good luck for us all."
Mar 23
Profile IconWesenachin Asfaw and Muhammad Basil joined GarageLab (arduino, electronics, robotics, hacking)
Mar 23
Marcelo Rodrigues replied to FiniousFingers's discussion New to group
"Hey man! A good point to start is reading basic tutorials on Arduino coding and wiring. Then, you…"
Mar 23
FiniousFingers posted a discussion

New to group

Couple quick things,I am just starting to learn, or wanting to learn, how to use the Arduino UNO…See More
Mar 23
Profile IconDan Urbauer, Bjorn and Jiaming Zhao joined GarageLab (arduino, electronics, robotics, hacking)
Mar 22
FiniousFingers is now a member of GarageLab (arduino, electronics, robotics, hacking)
Mar 20
Erva updated their profile
Mar 16
Erva and Mrs. Priscilla Bonneval are now friends
Mar 16

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service