VGA project (questions before starting the project)

I saw a few people building their own VGA Video Chip via an Arduino and thought about doing the "same".

though i'm not entirely sure how to go about it. and for the start just want to know from some people who did stuff like this if this is even possible.

.

basically i would like to create a Video chip that could be used with External VRAM, does some internal processing (aka uses tiles instead of a direct bit for pixel image), and could be interfaced with a CPU like a Z80.

my idea was to use an ATmega1284 @ 20 MHz. with a target resolution of (at first) 128x96 (monochrome). which is a nice and round 4:3 resolution and requires a total of 1.5kB of memory (if 1 bit = 1 pixel)

.

now about the Timing, which i think i somewhat understand.

I assume running this 128x96 res. at 60 Hz would mean i need to pump out 1 pixel every 1,35633 µs. but what confuses me are the sync signals.

as far as i understand it the H and V sync are basically used to tell the Monitor what the actual resolution is so it can be scaled up/down to fit the entire screen. so if i were to cause an H Sync pulse every 128 pixels (every 173.61024 µs) and a V-Sync (plus H-Sync?) every 96 rows (every 16.66658304 ms), would that cause the 128x96 image to stretch out to the entire screen?

and if so how much time does the ATmega have between frames to do other things besides sending data to the VGA Monitor?

and if so could i just use interrupts for the signals and let other code run in the mean time?

i thought about doubling the resolution of the image while only drawing half of it (64 pixels to the left and right would be blank, and 48 rows to the top and bottom would also be blank. so the entire thing would be centered in the middle). only downside i can see with that is that it would be 4 times as many pixels so i would need to output them at 4x the speed (339.0825 ns per pixel)

.

now a bit about the CPU/VRAM Interface.

my idea was to put the VRAM into the same Memory space as the CPU, which takes a away a bit of RAM from the CPu but makes data transfer a lot less stressful as otherwise data would need to be routed through the ATmega into VRAM.

this was my plan and the reason i need a bit of processing time between frames:

|280x500

basically if the CPU is accessing VRAM it will redraw the same image it already generated until it's done, then it checks again to see if it can access VRAM.

.

so, i'm sorry for this post being kind of a mess but i barely know anything about VGA (atleast i think so) and i thought about posting my plans here so people could look at it and either go "yep this should be possible like you described it", or "nope this is 100% impossible to do", or maybe "yea it would be possible if you change this and that".

but just to be safe.

here is a TL;DR:

Microcontroller: ATmgea1284 @ 20 MHz Resolution and Framerate: 128x96 @ 60 Hz (Monochrome) Interface: 8 bit Parallel Interface for CPU and External VRAM Function: basically imgine a simplier version of the PPU from the NES

.

anyways i hope this was enough information, if anymore is required i can always post more. thanks in advanced for future help. (hopefully)

Did you already look at the Arduino TVout project?

I also wonder what you want to display, where shall images come from?

DrDiettrich: Did you already look at the Arduino TVout project?

I also wonder what you want to display, where shall images come from?

hmm, looking at it i cannot see any kind of processing it can do. only display set images inside the arduino, no interfacing, or anything.

but i did thought about using a TV as well. since SCART it still used and makes it easy to get RGB Information into a TV. but i liked the idea of VGA better. Also because I'm even less sure about TV timing. Since it uses a combination of H and V Sync called C Sync... where I have no idea how the TV is supposed to see the difference between H and V Sync.

about where the images come from, didn't i wrote that in the post?

the chip is supposed to get all it's data from external VRAM which is also accessable by a CPU (Z80 for example) it even says it in the flow chart i made.

.

Though one thing I forgot to mention, the idea was to have a watered down version of the PPU from the NES. So instead of the VRAM containing the image to be drawn it instead contains the tile set and tiles for the entire screen.

Since the screen is 128x96 it fits a total of 192 tiles, each tile uses 1 byte so a screen needs 192 bytes to be filled. The tile set is also supposed to be in VRAM (or a ROM inside the VRAM address range). Since 1 byte is used per tile this means there can be a total of 256 different tiles.

I have an idea how this is done in detail but I sont think it is that important right now.

VGA requires HSync and VSync, and that's what is generated in the TVout project.

All in all I think that an 8 bit Arduino can be made play Pong, but external video data seems out of reach. Why don't you use a (TFT...) display module with controller?

DrDiettrich:
VGA requires HSync and VSync, and that’s what is generated in the TVout project.

All in all I think that an 8 bit Arduino can be made play Pong, but external video data seems out of reach. Why don’t you use a (TFT…) display module with controller?

Well yeah but H and V sync don’t have their own pins on a SCART connector, if you use RGB on a TV you use C Sync.

Is TV timing easier/slower than VGA timing?

Also reason I don’t use a graphic module is that

  1. Good graphic modules are really expensive, 4:3 VGA monitors are really cheap.
  2. It doesn’t really teach me how to work with VGA If I use a completely different screen type

Also i tried with a 128x64 screen but had problems with it so that project died.

Be serious, please! A 128x96 BW display is somewhat different from a VGA monitor, and it costs less than 20$ including a controller and RGB VRAM. Have a look at e.g. Adafruit Arduino compatible offers. If you mean screen size bigger than 4", get a RasPi which includes a graphics controller that outperforms any Arduino solution.

Look at the SCART format and timing constraints. I doubt that 128x96 @ 60 Hz is supported by SCART or VGA.

Composite sync consists of both H and V sync. If you have both signals, combine them with a few resistors into a C Sync - see TVout.

IMO you should have a closer look at technical specifications before you try to connect your own logic to a VGA monitor or TV set. Cheap (CRT) VGA monitors tend to burn out when driven with signals of incompatible frequencies.

Is TV timing easier/slower than VGA timing?

Slightly slower but essential the same.

the chip is supposed to get all it's data from external VRAM which is also accessable by a CPU

You want to look a dual ported ram to do that, otherwise you have to surround your ram with data select chips on both the address and data lines. The latter needs to be bidirectional. Also the ram needs to operate twice as fast as it needs to in order to interleave the accesses, otherwise you have to restrict access to frame flyback times.

Yes you can do this sort of things and I have done something similar in the 80’s only instead of the Arduino I used a bunch of TTL logic to generate the sync pulses.

AFAIR the ZX-80 also did most video handling in TTL. At least it's more economic to generate fixed-frequency signals in dedicated hardware, unless such hardware is available within a controller.

Dual ported RAM is very expensive (cost+time) with most Arduinos, lacking a parallel memory interface.

But why dual port RAM? The C64, CPC, and other computers use normal S/DRAM for the exact same interface.

I just thought about hooking up the address lines of the CPU to some GALs I have lying around and decode it in such a way that if the address outputed is in the range of the VRAM it blocks the ATmega access (this could be done with a single input, as long as it's 0 it can access the VRAM, otherwise it will stop and display the previous frame again), which then causes it to display the same frame until it can access the VRAM again.

Though I know it doesn't have to be that complex from the start. That is just the end goal, just displaying stable 128x96 pixels onto a screen would already be sweet. I just don't want to stop there.

Look at the SCART format and timing constraints. I doubt that 128x96 @ 60 Hz is supported by SCART or VGA.

Why not? I saw people do less and more on a VGA monitor so why wouldn't this specific resolution work?

And again I cannot really learn anything if I just use a library or module to controller that takes away the entire fun and effort.

The display of the age when VGA began to be used was analog CRT. So, there are "Horizontal Blanking Interval" and "Vertical Blanking Interval".

VGA - the Rest of the Story http://www.xess.com/blog/vga-the-rest-of-the-story/ If you do not want to flicker the screen、It is necessary to execute something which is not processing of screen display within this blanking time. However, moving data from external RAM to internal is difficult in this short time. There is no DMA. So I decided to thin the screen. In the LCD I have, the screen appeared even if it was displayed once in three times. The other two times output the sync signal but the screen remains black.

It is displayed while reading out the video data placed on the SD card only with Arduino. Arduino controls $3.6 RGB LCD https://youtu.be/sQNRiu3Vkyc

The LCD of the link to the previous video is NTSC signal. VGA signal has a sync cycle half that of NTSC, so I reduced resolution. Connect Arduino to VGA input on TV (sorry too loud) https://youtu.be/eGhsN9GWh48

To make NTSC color signal is bother work. I think this is the limit in the ability of Arduino. Arduino TVoutColor NTSC https://youtu.be/ysMUZaUsUp0

Let's have fun with Arduino !

Nabe_RMC: The display of the age when VGA began to be used was analog CRT. So, there are "Horizontal Blanking Interval" and "Vertical Blanking Interval".

VGA - the Rest of the Story http://www.xess.com/blog/vga-the-rest-of-the-story/ If you do not want to flicker the screen、It is necessary to execute something which is not processing of screen display within this blanking time. However, moving data from external RAM to internal is difficult in this short time. There is no DMA. So I decided to thin the screen. In the LCD I have, the screen appeared even if it was displayed once in three times. The other two times output the sync signal but the screen remains black.

It is displayed while reading out the video data placed on the SD card only with Arduino. Arduino controls $3.6 RGB LCD https://youtu.be/sQNRiu3Vkyc

The LCD of the link to the previous video is NTSC signal. VGA signal has a sync cycle half that of NTSC, so I reduced resolution. Connect Arduino to VGA input on TV (sorry too loud) https://youtu.be/eGhsN9GWh48

To make NTSC color signal is bother work. I think this is the limit in the ability of Arduino. Arduino TVoutColor NTSC https://youtu.be/ysMUZaUsUp0

Let's have fun with Arduino !

well an FPGA would be a lot better suited for this. sadly the one i ordered is still in customs since around a month so i thought i try to use an ATmega to get something going in the mean time...

until then i can ateast try to get the timing correct to display something onto a screen for that i would need to know how fast the ATMega can change the output and how the Sync signals are supposed to be generated (my idea would be to use Interrupts at specific times)

also i just tried making a small test program and putting that onto my ATmega1284 and i cannot seem to find the right fuse bits to make it run at 20 MHz, no matter what i try it always is slower than expected. I use Atmel Studio because the delay function atleast works with 20 MHz and can output binary files

I know this is a dead thread but I still wanted to share something. After I bought myself an FPGA to test around with VGA, I noticed that it's perfectly possible to get a VGA signal by only using a 12.5 MHz pixel clock. All you have to do is half all of the horizontal timing signals.

This only gives you a 320x480 image with all pixels being twice as long, but to compensate you can draw the same line of pixels twice to have an effective resolution of 320x240.

This also makes memory access easier. Especially if you use a 40 byte buffer (which is enough for a single line)

Since before the first line is being drawn you can read 40 bytes from VRAM and put them inside of the buffer. Because every horizontal line is being drawn twice you have more than enough time to read the next 40 bytes for the next two lines to be drawn.

Though I know this would require at least 2 40 byte buffers to work.

I hope this helped or inspired someone to do their own VGA project in the future, though I'm not entirely sure there's even fully works like I'm saying here

If you are looking for a processor that can output VGA signal look at the Propeller Spin processor, I recently did a project for this in the Raspberry Pi magazine, TheMagPi, numbers 77 to 79 - the last one shows VGA capability.

These chips are quite cheap but a lot of the pre made boards are a bit obsolete and have gone out of stock. Video:- https://www.youtube.com/watch?v=MDiM-l-rLi4 The Magizine ( free PDF download ) https://www.raspberrypi.org/magpi/issues/77/

Grumpy_Mike: If you are looking for a processor that can output VGA signal look at the Propeller Spin processor, I recently did a project for this in the Raspberry Pi magazine, TheMagPi, numbers 77 to 79 - the last one shows VGA capability.

These chips are quite cheap but a lot of the pre made boards are a bit obsolete and have gone out of stock. Video:- https://www.youtube.com/watch?v=MDiM-l-rLi4 The Magizine ( free PDF download ) https://www.raspberrypi.org/magpi/issues/77/

not bad but i already have an FPGA, which is how i was able to even get some video output at all, to even write that.

and as said before i just meant that the arduino should be able to output pixels at any resolution that is some deivsion of 640x480. so 320x240, 160x120, 80x60, etc. the only thing that needs to be outputted at 12.5 MHz or 25 MHz aare the sync signals.

Has anyone tried this VGA Shield for ESP32? (https://www.ebay.com/itm/254293116822)

Apparently it can be used to connect a standard VGA display to ESP32 micro controller supporting 800x600 (or experimental 1024x768?)

No but it looks very expensive for what it does.

https://www.tindie.com/products/bitluni/esp32-vga-black-edition/ the black board a lot cheaper.

YouTube video ESP32 VGA Board & ESP32Lib FAQ (Level 2).

Arduino Output to VGA monitor with every step detailed and whys provided. http://gammon.com.au/forum/?id=11608

Mostly see the limitations.

BTW Budvar10 makes a board with 1284P at 24MHz. I have one, it runs fine.

You might also look into the TeensyLC, a 48MHz ARM M0 Arduino-compatible that costs $12.