2:1 Vga

12 Nov 2012

Hi

I am working on a project and am looking to switch VGA inputs (2) to one VGA output. I have only managed to find one suitable chip MAX4885, but this isn't really in a suitable package for prototyping on a breadboard.

Does anyone have any ideas of chips that are suitable ? If not can anyone recommend a good multiplexor for the job ?

13 Nov 2012

Hi Chris -

If you can't find a breadboard friendly part you could use a smt to DIP adapter pcb and use the MAX4885. For example:

http://www.proto-advantage.com/store/product_info.php?products_id=2200071

I'm not sure that is exactly the right one, but you get the idea.

Good luck,

Mike

17 Nov 2012

i want to connect mbed with a Vga cable. please help me to it for displaying color images on monitor.

17 Nov 2012

Use a Gameduino. I have a library for doing this.

See:

Import libraryGameduino

Library for communicating with a Gameduino shield. Provides colour VGA display, hardware sprites with collision detection and stero sound. See http://excamera.com/sphinx/gameduino/ for more details.

19 Nov 2012

Richard Ellingworth wrote:

Use a Gameduino. I have a library for doing this.

See:

Import libraryGameduino

Library for communicating with a Gameduino shield. Provides colour VGA display, hardware sprites with collision detection and stero sound. See http://excamera.com/sphinx/gameduino/ for more details.

is there any oyther way to attach mbed with vga?? anything which i can do at home? i want to avoid adopters.

19 Nov 2012

Yes. It can be done, but it's a lot of work and bare in mind that most of the time your program is going to be whizzing around spending a fair slice of the time just keeping the picture up-to-date. The advantage of something like the Gameduino is that for the price of an SPI communications link (4 wires plus power) it will do all this work for you leaving your program to get on with what it really wants to do. However, other people have done this. For example the following link shows you how to do it with an Atmel ATmega168, but the principles are the same when using an mbed :

http://www.mikekohn.net/micro/atmel_vga.php

It's interesting that he first solved the problem with an FPGA which is exactly how the Gameduino does it.

You may be too young to remember, but the Sinclair ZX80 home computer tried to do everything with the CPU and did not use any support chips to help in updating the screen. This meant that when it had to think really hard the screen went blank!

20 Nov 2012

The mbed does not have enough memory to display a full color VGA display so you need to add an external memory chip which will complicate things. Monochrome upto 640x480 is doable and can be run without much CPU load (using the I2S to do the 25 MHz pixel pushing with DMA) There is a library for that including some demo programs:

Import programvga640x480graphic

Demo program to show 640x480 monochrome fullgraphic

20 Nov 2012

how can i display a binary image with this configuration of vga with mbed having size of 40 kb.

20 Nov 2012

sanwal muneer wrote:

how can i display a binary image with this configuration of vga with mbed having size of 40 kb.

Simple.. You can't :-) You can calculate how much memory would be needed to display your image:

width * height * bytes_per_pixel = amount of memory needed.. Since the VGA 640x480 library uses a simple 1-bit-per-pixel scheme it can only display black or white (monochrome).

If you want to display 8, 16 or 32 bit images you need a dedicated framebuffer device (like some of the serial or SPI coupled LCD screens) or attach a USB to VGA/HDMI converter (which has its own framebuffer)

The mbed is not really suited for this. If you want to display high res graphics use a Raspberry Pi or such.

Maybe NXP can also bring out a new mbed like device with HDMI output, preferably with a dual or quad core CPU (would be nice, I really like the online programming environment)

20 Nov 2012

ok how can i read images from pc through mbed?

21 Nov 2012

sanwal muneer wrote:

ok how can i read images from pc through mbed?

Since you also asked this question in another thread: what do you want to do with those images (what format are they?) on the mbed?

21 Nov 2012

i want to transmit these images through xbee. these images are in jpeg format.

25 Nov 2012

Sorry for the late reply,

I still do not understand what you are trying to do. What direction are the jpeg images going ?

Are they coming from the mbed and need to go to the PC (via Xbee) or coming from the PC (via Xbee) and going to the mbed.

If the images need to be displayed by the mbed you need an external display device as there is no colour VGA output available on the mbed (just black and white with the VGA library) You can use a SPI driven LCD panel like this:

http://mbed.org/cookbook/SPI-driven-QVGA-TFT

26 Nov 2012

the images are saved in pc, i want to get them through mbed and transmit them through xbee to other mbed which is attached with a projector.

(images) (images) Pc->mbed->Xbee............xbee->mbed->projector

26 Nov 2012

what are the pins of R,G,B, hsync and vsync to be connected with vga port in the libraray 640 * 480 quoted above?

26 Nov 2012

Hi Sanwal,

The pins are as follows:

DIP5 is the video output and this pin connects with three resistors in series to R,G and B of the VGA monitor. The resistors should be larger than 270 ohm. (all color inputs of the monitor need a seperate resistor but connect to the same output pin DIP5 of the mbed: as I said it is monochrome only..)

DIP25 is the horizontal sync output and can be connected directly to the VGA monitor hsync input

DIP8 is the vertical sync output and can also be connected directly to the VGA monitor vsync input

Do not forget to connect some of the ground pins of the VGA connector (like 6,7 and 8) to a GND pin of the mbed.

/media/uploads/gertk/mbed_vga_pinout.jpg

02 Dec 2012

i have a matrix of a binay image in a text file. i am reading the values (1 & 0 )out of it to display each pixel. but its not working. here is my code.

/*
 * 640x480 60Hz fullgraphic monochrome VGA Driver demo program
 *
 * Copyright (C) 2011 by Ivo van Poorten <ivop(at)euronet.nl>
 * and Gert van der Knokke <gertk(at)xs4all.nl>
 * This file is licensed under the terms of the GNU Lesser
 * General Public License, version 3.
 *
 * Inspired by Simon's (not Ford) Cookbook entry and Cliff Biffle's
 * assembly code.
 */
 
#include "mbed.h"
#include "vga640x480g.h"
LocalFileSystem local("local");
unsigned char data[8000];
void pixel(int x,int y,int d)
{
if( d==0)
{
vga_plot(x,y,WHITE);
}
else if( d==1)
{
vga_plot(x,y,BLACK);

}
}

// visual feedback
DigitalOut myled(LED1);

// define serial port for debug
Serial linktopc(USBTX,USBRX);

int main() {
FILE *fo,*fp=NULL;
    fp = fopen("/local/yo.txt", "r");
    fo = fopen("/local/out.txt", "w");
    
    // init the VGA subsystem (always do this first!)
    init_vga();

    int s,t;

    // serial port on at 115200 baud
    linktopc.baud(115200);
    setbuf(stdout, NULL); // no buffering for this filehandle
    
    
    // clear the screen
    vga_cls();
    
    int i=0;
    int k=0;
    int l=0;
    //q:
     while(!feof(fp))
     {
     //q:
            data[i] = fgetc(fp);
            if(i==8000)
            {
            i=0;
            }
       fprintf(fo, "%c",data[i]);
        
        //for (int k=0;k<=400;k++)
        //{
        
       //for(int l=0;l<600;l++)
       //{
       pixel(l,k,data[i]);
       if (l==599)
       {
       k++;
       l=0;
      // goto q;
       
        }
        }
        fclose(fo);
        fclose(fp);
    // draw some circles
   // for (t=10; t<200; t+=5)
    //vga_circle(20+t,399-t,t,WHITE);

    // draw some boxes
   // for (t=10; t<100; t+=5)
    //vga_box(400+t,100+t,400+t*2,100+t*2,WHITE);
  
    // circumfence the screen
    vga_box(0,0,639,479,WHITE);
    
    // show the complete character set
   // for (s=0; s<4; s++) {
      //  for (t=0; t<64; t++) {
          //  vga_putchar(20+t*8,20+16*s,t+s*64,WHITE);
        //}
   // }

    // put a string on screen
    vga_putstring(600,400,"Hello World",WHITE);

    // draw some lines
   // vga_line(400,390,500,390,WHITE);
    //vga_line(500,475,600,375,WHITE);

    // draw a filled box
  //  vga_filledbox(0,0,50,50,1);
    //vga_filledbox(150,0,50,50,1);
   // vga_filledbox(550,430,300,300,1);
   // vga_plot(500,50,WHITE);
    //vga_plot(500,51,WHITE);
    //vga_plot(500,52,WHITE);
    
   pixel(500,53,1);
   pixel(500,54,0);
   pixel(500,55,1);
   pixel(500,56,1);
   pixel(500,57,0);
   pixel(500,58,0);

    // draw some more boxes
   // for (t=10; t<320; t+=5)
   // vga_box(100+t,440-t/16,110+t,440+t/16,WHITE);
    
    
    // all done
    while (1){
        wait(0.5);
       myled=1;
       wait(0.5);
       myled=0;
    }
 }
03 Dec 2012

Did the original functions work OK ? (the boxes and lines ?)

I also see you use the local filesystem... The local filesystem interrupts/corrupts the VGA subsystem.. I use a SD card (SPI mode) for storage in several projects using the VGA library.

04 Dec 2012

i am reading the pixel values of an image (1 & 0) from a stored file. but i am unable to display the image.

04 Dec 2012

Do you get any image at all? Does the monitor recognize the signal ? The line 'Hello world' should be visible. Try first without opening your data file and see if you can get a stable image first.

The demo program should display this:

http://mbed.org/forum/mbed/topic/2459/?page=2#comment-13116

08 Dec 2012

the image is stable. but when i read the pixel value from a stored file then it does not work.

08 Dec 2012

and how can i change the screen like next image in real time??

08 Dec 2012

sanwal muneer wrote:

the image is stable. but when i read the pixel value from a stored file then it does not work.

You might try and simplify your pixel routine:

void pixel(int x,int y,int d)
{
     if(d)   // any value other than zero
     {
          vga_plot(x,y,WHITE);
     }
     else
     {
          vga_plot(x,y,BLACK);
     }
}
08 Dec 2012

sanwal muneer wrote:

and how can i change the screen like next image in real time??

There is no memory for an extra screen buffer so you can not switch framebuffers, you just need to redraw.

08 Dec 2012

Once you get it working you might try and use this:

http://www.visgraf.impa.br/Courses/ip00/proj/Dithering1/floyd_steinberg_dithering.html

That way you can display images with only black and white pixels.

08 Dec 2012

can you tell me how can i redraw after one frame?

Gert van der Knokke wrote:

sanwal muneer wrote:

and how can i change the screen like next image in real time??

There is no memory for an extra screen buffer so you can not switch framebuffers, you just need to redraw.

12 Dec 2012

You could create a loop around the 'opening file, draw image, close the file' part of your code. By storing the image data with a number in the filename you can use a counter to generate the filename with sprintf like this:

char filenamebuffer[128];
int counter=1;

// repeat endless
while (1)
{
// generate filename from counter
sprintf(filenamebuffer,"/local/image%01d.txt",counter);

.......
fp=fopen(filenamebuffer,"r");
.........
// draw image

// close the file
fclose(fp);

// perhaps wait a bit
sleep(1);

// increment the counter
counter++;
...........

}

This wil generate a filename in filenamebuffer like:

image01.txt image02.txt image03.txt etc.

13 Dec 2012

i am able to redraw after one frame. and i am also able to read characters from local file system and display them on vga. can you tell me some function that would read the pixel values from the text file and will display the whole image??

13 Dec 2012

sanwal muneer wrote:

i am able to redraw after one frame. and i am also able to read characters from local file system and display them on vga. can you tell me some function that would read the pixel values from the text file and will display the whole image??

Hi Sanwal, Well, that depends on how the textfile represents the pixel values: is it simply an Ascii '1' for an 'on' pixel and a '0' for an 'off' pixel ? If you are using Ascii values then the test could be something like this:

int d;

d=fgetc(fp); 

if (d != '0') // if not Ascii '0' (48 dec)
{
     {
          vga_plot(x,y,WHITE);
     }
     else
     {
          vga_plot(x,y,BLACK);
     }
}

15 Dec 2012

would it work for reading files frm local file system?