Close

Rendering with Arduino Mega 2560

A project log for VGA with Arduino

Yet another project trying to generate VGA signals using small avr mcu.

pavelPavel 2 days ago0 Comments

I have Arduino Mega 2560 board in addition to the Nano I used in previous logs. This has more RAM, so I am able to load and render slightly more detailed image, 50 by 51 rectangular pixels.

Here is the example:

-----

This is possible when using the smallest resolution with the lowest frame rate that is acceptable by the monitor, which is 720*400 @ 50Hz (this was described at the end of previous post). This choice gives minimal horizontal stretch per clock cycle, and with drawing each pixel taking 11 cycles, the horizontal extent of the pixel is made smallest possible. Vertically, each pixel takes 8 lines.

-----

Creating stable image on the monitor using avr microcontroller turned out a bit painful: there is a jitter introduced because interrupt handling is delayed by different number of cycles depending on instruction currently executed by mcu. Because of this each line often starts drawing with slightly different offset, and gives "toothed" vertical edges, with this "teeth" pattern moving up or down. In some cases the image is static, but with rough vertical edges. At some other times image has straight vertical edges, but vibrates as a whole. By introducing or removing NOPs in specific places one can achieve the stable sharp image, but this takes some trial and error to make it work. Also if changing timings - i.e. to change frame rate and/or resolution, all this balancing is thrown out, and for the new settings the trial and error process to find a sweet spot has to be performed once again.

-----

This project was done mostly to quickly test the tolerances of my small display, find which synchronization parameters are acceptable to it to show an image. Using an AVR mcu for this is a very hacky way to do it. Now, as I have data, I am finishing this project.

To make stable signal there is a need a specific hardware, a videocard of sorts, that has its own dedicated memory, and shows its contents, as well as creates sync signals on its own, without using main processor.

I intend to start with FPGA implementation, and then to make one using 74HC family of logic chips. These will be their own projects.

Discussions