Go Down

Topic: Turn your Uno into a VGA output device! (Read 28 times) previous topic - next topic

Nick Gammon

Apr 20, 2012, 09:12 am Last Edit: Apr 21, 2012, 12:50 pm by Nick Gammon Reason: 1
After playing with the MicroVGA card, I was wondering if it was possible to simply output VGA video directly from the Uno?

And it turns out, yes it is ... see photo:



This is the result of quite a bit of research. It seems that a few other people have done something similar, which helps, because their research and examples were a big help.

However this is the first example, that I know of, that simply runs on an ordinary Uno, using the standard Arduino IDE (no assembler code).

The only additional hardware was:


  • 5 resistors

  • A DB15 socket to plug the VGA cable into

  • Wires to connect



There are some unavoidable limitations in trying to squeeze this sort of performance out of a small chip like this, such as:


  • Monochrome output

  • 20 characters wide by 30 characters deep (160 x 480 pixels)



But, hey, this is more data than you can show on a 2-line LCD screen, or even a 4-line one.

The chip is kept quite busy refreshing the screen ... there is a horizontal sync pulse every 32 uS, which means there isn't a heap of spare processing time. But I have set it up to receive "print" commands via I2C from another Uno. That way one can be doing the calculations, and the other the displays. You could have the one do the lot, but the screen might have to go blank, or flicker, if it was doing a lengthy computation. But still, for the cost of a $5 Atmega328 chip, this is still quite a cheap output device (assuming you have an old LCD monitor lying around).

I'm going to spend the next couple of days documenting how it works, posting code, and so on.

Nick Gammon

#1
Apr 20, 2012, 09:42 am Last Edit: Apr 20, 2012, 09:55 am by Nick Gammon Reason: 1
For anyone keen to see the sketch, here it is:

http://gammon.com.au/Arduino/VGA_output.zip

You need the "timer helpers" library, available from here:

http://gammon.com.au/Arduino/TimerHelpers.zip

JO3RI

Nice work Nick.

I'm very interested in this. I also found this: http://code.google.com/p/arduino-vgaout/ which has currently : 64x64 - 64colors
Maybe it can help you improve your code?

keep us informed.

Nick Gammon

#3
Apr 20, 2012, 10:13 am Last Edit: Apr 20, 2012, 10:16 am by Nick Gammon Reason: 1
I didn't see any code in that link, but thanks for that!

(Edit) I spotted the code. :)

His example of 64 x 64 pixels is a total of 4096. My screen shows 160 x 480 pixels which is a total of 76,800 pixels.

So there is a trade-off. For much fewer pixels you probably have time to output colour information.

I'll be documenting the design decisions, and how it all works. I found that time was extremely critical in trying to output even 20 characters (160 pixels) horizontally. For example, I had to restructure the font table in such a way as to save a single divide by 8 (or shift right 3 bits).

It's not even as if assembler would help. It takes 16 clock cycles to output 8 pixels, so you have a limited amount of time to work out what the next 8 pixels are going to be.

JO3RI

Quote
His example of 64 x 64 pixels is a total of 4096. My screen shows 160 x 480 pixels which is a total of 76,800 pixels.


Yep I know, something in between would be nice ;-)

Would it be possible to blow up fonts, without the need of adding a bigger font? Let's say you have a 7x5 font could you make it 14x10? For my project I would need large fonts, but for now I had to change resolution to achieve this:
http://www.youtube.com/watch?v=EnherW4hM-g

Go Up