Go Down

Topic: VGA library for Arduino UNO and ATMega328 (Read 553 times) previous topic - next topic

smaffer



Hello everyone,
i've created a VGA library for Arduino UNO.
Here you can download it.
The library implement a 120x60px framebuffer where each pixel is stored as 2 bits (4 colors). The framebuffer is stored inside SRAM.
The 4 colors generated from the library are not predefined.
You can connect two of the VGA connector pins in different ways, selecting the color combination that you prefer.
To use this library you need only 4 resistors and one DSUB15 connector.



Based on the VGA color video generation by Nick Gammon.
Inspired from the game Toorums Quest by Peten Paja.
AVR interrupt dejitter from Charles CNLOHR.

Happy Hacking!!

mcnobby

#1
May 03, 2015, 07:29 am Last Edit: May 03, 2015, 07:29 am by mcnobby
Excellent !!
I also tried colour but I had a tiny jitter problem which I couldnt find a way to solve

One of the 8 colour drivers I did was for the ATTiny13A (amongst others)
Forum Post
youTube Video
you can see the jitter problem near the end of the video

Cheers :)
while (z--) { snoreEvenLouder(); }
www.smartshow.lighting - www.dmx512.lighting

smaffer

Hi Mcnobby,
your ATTINY project is great!

I've seen the video and your sourcecode.
The problem can be a little jitter in the execution of your interrupt function (1clock or more of delay that depends on the instruction that is in execution when the interrupt happens)  . I have got a similar problem but in my case the signal was more disaligned (1pixel or more).
I've saw this video by Charles CNLOHR before i realized the problem.

Otherwise can be a clock problem.. Have you looked the signal with an oscilloscope? It's ok?

mcnobby

#3
May 03, 2015, 10:38 am Last Edit: May 03, 2015, 10:38 am by mcnobby
Thanks very much, I just like trying to squeeze every ounce out of little chips !!

It is a timer interrupt clock cycle issue, one day I will fix it and hopefully keep it under 1k !!

Do you have any videos/youTube smaffer ?
while (z--) { snoreEvenLouder(); }
www.smartshow.lighting - www.dmx512.lighting


mcnobby

Very good smaffer !! :)

I dont have twitter, but I subscribed to your youTube :)
while (z--) { snoreEvenLouder(); }
www.smartshow.lighting - www.dmx512.lighting

rob_cai

Dear Smaffer,

I want to thank you again in this post for your VGA library.
I have created a new post for the Arduino color game I have done using it, here it is the link.

You can find the code as well.


smaffer


mcnobby

I had a close look at your code today, just trying to see the difference between VGA and composite (PAL)

I believe the VGA line is 32us, whereas the composite line is 64us, so basically it is much harder to squeeze pixels into a VGA signal !

I have just written a new PAL driver for ATMega1284, its 352*280px, it reads BMPs off an SDcard and displays on the TV.. I still havent implemented that jitter fixer.. I havent got my head round it yet !!

I am using timer1 running flat out at 24MHz, I really wanted 32MHz but the '1284 couldnt handle it !! ha ha

Be really good to get the screen flicker free

ANYWAY.. your project looks awesome, I must try it when I get a chance !!
while (z--) { snoreEvenLouder(); }
www.smartshow.lighting - www.dmx512.lighting

mcnobby

Hello Smaffer, if you are using a  CLS() in your library then perhaps consider THIS post.. I was asking for a way to clear a large array really fast, this was the video array in TVout

Some of the answers are quite interesting, in the end I decided to treat chunks of the array as uint64_t's and clearing them with one line

Also I considered writing an ASM routine that sits in the interrupt somewhere that will clear the display between writing frames to remove any flicker

I am now writing a simplified version of your code for an ATMega8

:)
while (z--) { snoreEvenLouder(); }
www.smartshow.lighting - www.dmx512.lighting

Nick Gammon

you can see the jitter problem near the end of the video

Cheers :)
I haven't looked at your code but I found jitter unless I put the processor to sleep (idle mode). It wakes up instantly and always on the same clock cycle so-to-speak.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Here, in particular:

Code: [Select]

  while(1) { // this is the main loop
    if (timer == 2) {
      // timed code here....
      shiftFwd(&H_GREEN_data[0]);
      shiftFwd(&H_BLUE_data[0]);
      timer=0;
    }


You are waiting for the ISR to fire anyway, and when it does you will have a few clocks before you notice if timer == 2. So add a sleep:

Code: [Select]

  while(1) { // this is the main loop
    sleep_mode ();   // wake in a predictable way
    if (timer == 2) {
      // timed code here....
      shiftFwd(&H_GREEN_data[0]);
      shiftFwd(&H_BLUE_data[0]);
      timer=0;
    }


In initialization, make sure sleep mode is idle:

Code: [Select]

  set_sleep_mode (SLEEP_MODE_IDLE); 
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up