VGA library - now with TV output

Hi,

What about UNO board support? It makes sense to have light version of lib...

The

2leon76:
Hi,

What about UNO board support? It makes sense to have light version of lib...

DueVGA is too dependent on hardware features only available in the SAM3X chip in the Due (particularly DMA) so it would be impossible to port it to the Uno.

Not to mention going from 96k of ram to 2k..
Great work on this library. I've been looking for something cool to do with my Due, now I may have found it. :slight_smile:

I have been working on drawing bitmapped graphics with this library using a couple of techniques:

8-bit, 256 colour PNG images converted to unsigned char arrays of pixels

I have written a utility in Ruby that I'm finalising, which will convert 8-bit PNGs for display using Due VGA. It references a colour-palette PNG image that contains all the displayable colours on the Due, re-ordered so that they are correctly converted to their binary value.

8-bit, 16 colour PNG images converted to one-pixel-per-nibble unsigned char arrays

I have written a utility which, when given a 16-colour index palette, will produce an image at half the storage size. You will only have access to 15 actual colours, as index 0 is reserved for transparency.

Both of these things are in my GitHub and are highly experimental and very unfinished; https://github.com/Gadgetoid/Due-Megadrive-Controller/tree/Tinkering

See the Tools and MDC_VGA folders.

I have also produce an 8-bit palette which can be used with Adobe products (and possibly others) for compressing images for optimal display, see Tools/8bit-truecolor-palette.act

And, finally, a couple of photos to show what you can achieve with these tools:


UPDATE: I have now migrated the Arduino Due VGA specific stuff to a new repository, it was getting cluttered in with my MegaDrive controller library: GitHub - Gadgetoid/Arduino-DueVGA-Tools: Tools and code examples for converting/displaying bitmapped graphics on the Arduino Due using the DueVGA library.

And I've also thrown together a colour table which you can see here: http://pi.gadgetoid.com/arduino-due/DueVGA-colour-table

UPDATE 2: From an idea I had this morning. HSV to RRRGGGBB conversion: Arduino-DueVGA-Tools/DueVGA_HSV.ino at master · Gadgetoid/Arduino-DueVGA-Tools · GitHub

@Stimmer this code could be dropped straight into a SetPixelHSV function.

Hi,
I'd like to know what is the real reason to use the MOSI pin (A26).
Isn't it possible to use another pin, allowing to obtain a simpler connector ?
Thanks in advance for the reply,

gadgetoid: Wow, impressive work! Thanks for the HSV code, I may well add it to the library because it would simplify my fractal demos (which use an ugly look up table at the moment)

fog44: Monochrome mode uses the SPI hardware to generate pixels. Therefore the output has to be on the MOSI pin. I am experimenting if it is possible to use the SSC hardware (in which case output would be on port A.16 / Arduino pin A0) but I don't know if it will work yet.

Stimmer,
Is there a similar library for VGA input? I want to convert a VGA signal from my computer to a composite RCA output to a TV.

I figure the problem with this is the processor speed and not being able to both read the incoming signal and generate the outgoing signal quickly enough. Is that the limiting factor here?

I suppose I could write a PC application that would capture the screen and send it over serial to the Arduino and fill the frame buffer, and then simply have the Arduino generate the composite video signal. That may be doable, as long as I can cram that much video data over serial quickly enough to get it to appear to be video instead of stop-motion.

At 320x240 at 8-bit color, that'd be 76800 bytes of data for the frame buffer, at a baud rate of 115200 (bits per second) or 14400 Bytes/sec. By my calculation, it'd take 5.3 seconds to transfer one frame, which is far too slow.

I do have a wifi shield. I wonder if I can get better throughput using that. It looks like the wifi benchmarks are pretty good for throughput (can range from 0.7 Mbps to 3.4 Mbps reasonably). Although, that won't overcome the memory constraint.

From what I understand, the 480i (interlaced) TV format is equivalent to 640x480 resolution. Does the fact that the TV format is interlaced mean that that the frame is actually half the size (half-line or every-other line)? Or will I have to downsample my video to fit the memory of the microcontroller?

You're right about the limiting factor of processing and I/O speed. Also, grabbing a VGA signal would need 3 A/D converters running at 12.5Msps each just for 320x240 :slight_smile:

In composite mode there still isn't much processing capacity left for input. The closest thing to what you are doing that I have tried is the SD card animation demo, which loads uncompressed animations from an SD card straight into the framebuffer ram. In VGA mode the frame rate is acceptable but in composite mode it slows to a few frames per second (I can't remember exactly how slow it was, but it was unwatchable)


I created a shield to utilize this awesome library you made. I need to order a few more components before I can be sure I got it right, but I suspect it will work fine. I used jumpers to isolate the composite video resistors from the VGA resistors, and I went ahead and tossed in an LM386 amplifier hooked to the DAC0 and DAC1 pins with an audio out jack (may have accidentally selected the very small size audio jack, oops). Oh, and VGA has i2c data, I went ahead and broke out those pins. I left out support for monochrome mode, it just made things more manageable in the PCB layout.
I made a whole bunch of the boards, so once I confirm they actually work, I'll have them up on my Tindie store as DIY kits.. :slight_smile:

Wow, fantastic work 8)

One suggestion, if you are connecting to DAC0 and DAC1 put 4.7k resistors in series to make sure the output impedance is high enough, some of us have broken our DACs because RLOAD was too low.

I2C could come in useful, it can be used to tell the make and model of the monitor (quite easy, it's in ASCII) and the refresh rates and modes it supports (much harder, it is in a strange binary format)

I've got the DAC's capacitively decoupled from each other, and from the amp chip, definitely don't want to blow my or anyone else's DAC's. I'll keep everyone posted on when the parts come in, and I've had a chance to test out the board.

Ok, the shield I made "works".. I got the polarity backwards on the composite jack, the silkscreen is backwards on the jumpers, so you have to select VGA for composite, and composite for VGA.. DOH.. And the audio output jack is 2.5mm rather than 3.5mm.. It all works, so I'm going to respin the board and have another batch made. Anyone want one of these mostly working boards?
Great job on the library guys. I went ahead and added a jack for a Wii nunchuck adapter to the next rev, maybe someone can use this shield and this library to write video games. :slight_smile:

Ok, the board works well enough that I know the minor fixes will solve the minor mistakes of the first batch. I went ahead and listed them as a fundraiser on Tindie. Hope you don't mind me linking to your video stimmer, that was a pretty epic demonstration. :slight_smile:

Thanks For Awe Some Library :smiley:

I ask If you can Make tutorials for how you can make the Timing Signals Using The Arduino Board

And How you Write Library Like That If you can

I will be very Glad To learn from you

I know that my Request is strange some way :slight_smile:

Thanks In Advance

stimmer:
The

2leon76:
Hi,

What about UNO board support? It makes sense to have light version of lib...

DueVGA is too dependent on hardware features only available in the SAM3X chip in the Due (particularly DMA) so it would be impossible to port it to the Uno.

Sure, but some VGA out also possible at UNO board too - Turn your Uno into a VGA output device! - Displays - Arduino Forum

Hello, first of all! Awesome work!

I would like to ask you some questions abuot the project. Im interested in doing something similar.

The first question is if would be any problem to increase de nomber of bits to 12 (4 bits each color) with a new resistor matrix.

The second question is about my idea. I would like to ask you if you think it would be possible. Im thinking on joinin togueter the vga controller with a CMOS camera, thus streaming the image directly to the vga. Im planing to use a ov7670 + Fifo camera.

Thank you in advance,

Best,
Aitor!

There are a couple of problems with getting DueVGA to output 12-bit colour: firstly because of the way the DMA and external memory interface work it would mean using 16 bits for each pixel. The second problem is lack of memory - there would only be enough memory for a resolution of about 240x160 at 12/16bpp.

How were you intending to connect the two? It may be possible to use the Due to generate the VGA timing signals for tha camera, and possibly generate some graphic overlay. It would be hard to capture the frame into the Due (because of lack of memory) but may be possible at low resolution / grayscale.

Thank you for you response! I see, then i would keep the 8 bits output.

And aobut the camera, what do you think without of having two memorys? I mean, for instance creating a buffer line then, capturing one line of the camera, and while the second line is preparing (there is a delay between every line) drawing this information on the VGA. Using interrupts to get the data would interfere to the vga generation?

I have been reading through your library and it's a hard work what you have done. I am impresive! I would be very interested in knowing exactly how do you generate the signals with the timers. I already have been playing a little with tiemrs and interrupts in my arduino uno but no in the way it's written in you code.

If you have time and inclination I would thank you quite a lot (and I amb sure others people too) if you can explain a little lines responsible for this task!

Best,
Aitor Sanchez

How much ram does the pixel data take?
Can we have double buffering, by using 2 arrays of pixel data and then swapping pointers?
I'm considering purchasing the Arduino Due for this library and I'm wondering what to expect.

320x240 colour mode takes about 76k, 800x600 mono is about 60k. There really isn't enough memory for double-buffering so I am not likely to add it to the library.