Hello everyone, 

Going forward on my study about VGA signal, now I could generate the sync signals (horizontal and vertical), and also play with the RGB ones. Now I can generate vertical color bars and rectangles. :)

I am still facing some problems, like to fill the entire screen area (it still shows an empty bar on the right), but I think I can solve this with a better adjust on horizontal timing.

Besides, not all kind of monitors can recognize my signal, some LCDs are not ok (no problem for CRT). I believe the solution is a better adjust on timing and/or impedance coupling.

Take a look what I got so far:

This was the first step: generate a solid stable rectangle on screen. It is white because I put all the RGB bits to HIGH, but the important was the sync signals worked very well (I think). 

The ugly/terrible picture above (the camera and my photographic skills didn't help), shows the colored vertical bars I could get from my Arduino UNO, changing the RGB bits. Actually, it would be possible to generate many more colors using some tricks or simply changing the analog levels of the RGB bits (0 to 0.7V), but I think Arduino wouldn't have speed enough on DAC. Well, for me, there is A LOT to learn yet.  

Below you can check the code, which I am not very proud of, but i works!!! :)). I think it can be useful for somebody: 

#define NOP asm("nop")
#define BLACK PORTB = B00000000;
#define BLUE PORTB = B00000001;
#define GREEN PORTB = B00000010;
#define CYAN PORTB = B00000011;
#define RED PORTB = B00000100;
#define MAGENTA PORTB = B00000101;
#define YELLOW PORTB = B00000110;
#define WHITE PORTB = B00000111;

unsigned int linecount = 1;

void setup()
{
//Set pins 5, 6 e 7 as output
// 7 - HSYNC
// 6 - VSYNC
// 10 - R
// 9 - G
// 8 - B

DDRD |= B11100000;

DDRB |= B11100111;
PORTD |= B11000000;

//set timer
TCCR2A = 0x02; // WGM22=0 + WGM21=1 + WGM20=0 = Mode2 (CTC)
TCCR2B |= (1 CS20); //
TCCR2B |= (1 CS21); // Set prescaler
TCCR2B &= ~(1 CS22); //

TCNT2 = 0; // clear counter
OCR2A = 0x0f; // set counter for comparison

TIMSK2 |= (1OCIE2A); // set interrupt by comparison
}

 

void loop()
{
do{
}while(1);

}

 

ISR(TIMER2_COMPA_vect){
PORTD &= ~(1 7);
if (++linecount == 525){ //525 lines
linecount = 1;
}
PORTD |= (1 7);

NOP;NOP;NOP;NOP;NOP;NOP;
if (linecount == 492){
PORTD &= ~(1 6);
} else {
PORTD |= (1 6);


if ((linecount >= 2) && (linecount <= 480)){

//Print a vertical rainbow on screen 
for (int j=0; j<6; j++){
BLACK;NOP;
BLUE;
BLACK;NOP;
GREEN;
BLACK;NOP;
CYAN;
BLACK;NOP;
RED;
BLACK;NOP;
MAGENTA;
BLACK;NOP;
YELLOW;
BLACK;NOP;
WHITE;
BLACK;NOP;
}
}

}

NOP; //small time adjust, it may or may not be necessary depending on your board

}

 

That's it! This was the first step for understand the basics about VGA, specially the SYNC signals. Now it's time for a better understanding about sizes and times. Also, the impedance coupling must be adjusted between the Arduino and the monitor (it could be the reason for some LCDs not understand my signal).

And more precision on timing is still possible.

Then, I will try to create some time windows for data acquiring, allowing the Arduino to get info to plot.

If, everything goes fine, maybe we can create a library for everyone use with any Arduino and any monitor, including TFTs. Too much maybe?? :)) 

Let's see what we gonna get! 

I will post every step, maybe they can help our friends here in GarageLab...

Thanks for reading this post! :)

Views: 1952

Tags: arduino, generator, signal, vga

Comment by Ryadh on April 2, 2012 at 4:10pm

Great hope that will work on my board i will try it tomorrow thanks a lot !!

Comment

You need to be a member of GarageLab (arduino, electronics, robotics, hacking) to add comments!

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

Profile IconElectric and Adderall, Ishmael Muhammad, Yuval kob and 3 more joined GarageLab (arduino, electronics, robotics, hacking)
Wednesday
Jesse Howards updated their profile
Jan 29
Profile Iconsuneet, Augustin Aziankou and Ayinde Adetunji joined GarageLab (arduino, electronics, robotics, hacking)
Jan 29
Augustin Aziankou updated their profile
Jan 28
Profile IconTom Evans, said, Ghenam houssam and 15 more joined GarageLab (arduino, electronics, robotics, hacking)
Jan 25
Kenny Sims is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 11
Paulo Trindade is now a member of GarageLab (arduino, electronics, robotics, hacking)
Jan 7
Profile Iconyashwita suvarna, António Gonçalves, Thurman Gillespy and 6 more joined GarageLab (arduino, electronics, robotics, hacking)
Jan 4
Profile IconMehmet Emin Örs, Andrew Myers, Ruban Venkatesh and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Dec 28, 2015
stephen smith is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 22, 2015
Profile Iconlantoniaina bruce, Manoel Pereira, Ben and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Dec 21, 2015
GarageLab replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Hello guys, New facts to the CircuitCo case. But until now, the didn't refund us or send the…"
Dec 21, 2015
michae coley left a comment for RITIU TRAIAN
"what project have you done?"
Dec 15, 2015
Profile Iconshalini amarnani, Philipp Schmid, Jesse Howards and 4 more joined GarageLab (arduino, electronics, robotics, hacking)
Dec 14, 2015
Profile IconAbador and Dara joined GarageLab (arduino, electronics, robotics, hacking)
Dec 9, 2015
GarageLab posted a blog post

Sodium Ions Rechargeable Battery Prototype

A joint of French science institutions just publish an article that claim they produced a…See More
Dec 7, 2015
Jay Rocket is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 7, 2015
GarageLab posted a blog post

Eye Controlled wheelchair

Patrick Joyce has a disease called Amyotrophic Lateral Sclerosis (ALS), the same disease from…See More
Dec 4, 2015
Nathan Ronald O'Connell is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 4, 2015
GarageLab posted a discussion

Claims against BeagleBone's manufacturer CircuitCo

Dear Members,We would like to inform you that, unfortunately, the manufacturer of BeagleBone…See More
Dec 4, 2015

© 2016   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service