Microcontroller based Graphical lcd game

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

User avatar
captalex
decided to stick around...
decided to stick around...
Posts: 28
Joined: Mon Mar 21, 2011 3:00 am
Contact:

Microcontroller based Graphical lcd game

Post by captalex » Sun May 08, 2011 5:45 am

hello guys,
finally got the parts for my project,
a (wg12864b)from winstar lcd screen, that uses the ks0108 driver.
a pic 18f4550 micro controller
a few push buttons
a potentiometer for the lcd contrast.
i intend to build a mini game console and write a few games(tetris, pong, adventures of captalex..) for it using the C programming language. i have encountered alot of libraries out there like the penguin game system that uses a similar lcd(and has some cool functions). but i cant get my lcd working ,less to start writing the games for the lcd, any experience using grahical lcds in C ,would be appreciated.! i cant seem to be able to upload the .pdf datasheet

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Microcontroller based Graphical lcd game

Post by bitfogav » Tue May 10, 2011 4:13 am

Hi captalex,

sorry for a late reply, sounds like a good idea making a game using 128x64 LCD. Ill try to help all I can, but I have not used a 128x64 before (but I do have one in the post with a ks0108 chip) :).

Can you give some more info about your problem with the LCD when you say you cant get it working?

*to upload the PDF file your need to ZIP the PDF file and then upload the ZIP file.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Microcontroller based Graphical lcd game

Post by brad » Tue May 10, 2011 10:19 pm

I'm also sorry for the late post here. We've been super busy. We have just sold our house and are in the process of building a new one. i am also spending loads of hours selling my video game colelction on ebay. Literally thousands of items to list!

anywho, Unfortunately I have not had experience in programming pic's with C language. I am guessing that bitfogav will be writing his code with swordfish basic. If you were interested in giving swordfish basic a go I am sure that the two of you could help each other along with various aspects of using the graphic LCD display.

As for me, I am working with my 32x32 RGB LED display, but one day I certainly plan on using LCD's (i'm just not sure when)

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Microcontroller based Graphical lcd game

Post by bitfogav » Fri May 13, 2011 5:16 am

Heres my Demo using a GLCD :)

viewtopic.php?f=17&t=441

User avatar
captalex
decided to stick around...
decided to stick around...
Posts: 28
Joined: Mon Mar 21, 2011 3:00 am
Contact:

Re: Microcontroller based Graphical lcd game

Post by captalex » Sun May 22, 2011 10:46 pm

thanks guys.
yes bitfogav ,
i've taken a look at your attempt. mine is similar, i have written a sample display code in mikro c to draw lines, text and display an images on the lcd . i tried simulating it on proteus simulator but i keep getting so many errors. also in the real world, the back light of the lcd came on awhile back when i was working on it, but now even with connecting a 10k between pins 3 and 18 (on my glcd) nothing seems to show on screen. i have attached my code and the digital schematic. thanks.
Attachments
GLCD_Test.rar
my mikro c display code
(1.02 KiB) Downloaded 679 times
pong new.rar
my schematic on proteus
(13.77 KiB) Downloaded 678 times

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Microcontroller based Graphical lcd game

Post by bitfogav » Mon May 23, 2011 12:08 am

captalex wrote:


finally man!!, bitfogav this is what i have been looking for /trying to do using the mikro C glcd libraries , but i didnt know how. i hope you could help me with porting your code to mikro C using a pic18f4550 and a wg12864b ks0108 based lcd display. and also adding an additional paddle and scoring! hence(pong).

Hi captalex, Im not familiar with mikroC, but looking at your test code, aren't you missing the GLCD librarys Or Headers? and dont you have to include the header file for which microchip you are using?, also I cant test your schematics as I dont have proteus :(

And as for your display backlight not working, all Ive done on mine is connect it up as this, im using a 10k potentiometer going to my 5volt supply and then the other two connections connect directly to the GLCD pin 3 and 18, this is to control the contrast of the display, you also need to connect pins 19 to 5+ and pin 20 to ground to operate the backlight.
GLCD Pot connections.jpg
GLCD Pot connections.jpg (27.54 KiB) Viewed 21218 times

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Microcontroller based Graphical lcd game

Post by brad » Mon May 23, 2011 6:12 am

Perhaps you could open up your schematic in proteus and take a screenshot for us?

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Microcontroller based Graphical lcd game

Post by odessa » Mon May 23, 2011 7:09 am

schematic.jpg
schematic.jpg (121.63 KiB) Viewed 21212 times
Thats the schematic Brad


If you upload the Hex file I can test it for you in Isis Captalex
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

User avatar
captalex
decided to stick around...
decided to stick around...
Posts: 28
Joined: Mon Mar 21, 2011 3:00 am
Contact:

Re: Microcontroller based Graphical lcd game

Post by captalex » Mon May 23, 2011 10:19 am

odessa wrote:
If you upload the Hex file I can test it for you in Isis Captalex

ok odessa, knock your self out!
Attachments
GLCD_Test original.rar
hex file for glcd
(6.47 KiB) Downloaded 669 times

User avatar
captalex
decided to stick around...
decided to stick around...
Posts: 28
Joined: Mon Mar 21, 2011 3:00 am
Contact:

Re: Microcontroller based Graphical lcd game

Post by captalex » Mon May 23, 2011 10:21 am

bitfogav wrote:
Hi captalex, Im not familiar with mikroC, but looking at your test code, aren't you missing the GLCD librarys Or Headers? and dont you have to include the header file for which microchip you are using?, also I cant test your schematics as I dont have proteus :(

And as for your display backlight not working, all Ive done on mine is connect it up as this, im using a 10k potentiometer going to my 5volt supply and then the other two connections connect directly to the GLCD pin 3 and 18, this is to control the contrast of the display, you also need to connect pins 19 to 5+ and pin 20 to ground to operate the backlight.


thanks bitfogav, i got it to light up again!, but now it just flickers constantly but doesnt display pixels yet.

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Microcontroller based Graphical lcd game

Post by odessa » Mon May 23, 2011 5:03 pm

Hi,

The errors I get on Isis running that code suggest you haven't defined the processor properly

Have you selected it project settings ?

Also when using using GLCD's in mikroC, the lower the clock speed the better, its glitchy.
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

User avatar
captalex
decided to stick around...
decided to stick around...
Posts: 28
Joined: Mon Mar 21, 2011 3:00 am
Contact:

Re: Microcontroller based Graphical lcd game

Post by captalex » Mon May 23, 2011 6:11 pm

odessa wrote:Hi,

The errors I get on Isis running that code suggest you haven't defined the processor properly

Have you selected it project settings ?

Also when using using GLCD's in mikroC, the lower the clock speed the better, its glitchy.

yes odessa, i have selected the p18f4550 device in the project setup and also set the clock speed to 4mhz, i use mikroC
v 8.2 and so some of the glcd routineslike "Glcd_Init()" are different from the ones on mikro c pro v4.6. what do you suggest i do ?

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Microcontroller based Graphical lcd game

Post by odessa » Mon May 23, 2011 6:34 pm

Hi,

My version of Isis doesn't have the 18f4550, where did you get yours from ? I ask as when I use your design nothing will run at all.

If I delete your 18f4550 and use the 18f4520 in Isis everything runs fine.

I dont use Mikro C, I'm borrowing someone elses to test your code which lists 1000's of error as it runs lol.

If it helps here is a sample GLCD written in Mikro C pro for an 18F4520

Code: Select all

/*
 * Project name:
     GLCD_Test (Demonstration of the GLCD library routines)
 * Copyright:
     (c) Mikroelektronika, 2005-2010.
 * Revision History:
     20081218:
       - initial release;
 * Description:
     This is a simple demonstration of the GLCD library routines:
     - Init and Clear (pattern fill)
     - Image display
     - Basic geometry - lines, circles, boxes and rectangles
     - Text display and handling
 * Test configuration:
     MCU:             P18F4520
                      http://ww1.microchip.com/downloads/en/DeviceDoc/39609b.pdf
     Dev.Board:       BIGPIC6 - ac:GLCD
                      http://www.mikroe.com/eng/products/view/300/bigpic6-development-system/
     Oscillator:      HS, 4.0 MHz
     Ext. Modules:    GLCD 128x64, KS108/107 controller
                      http://www.mikroe.com/eng/categories/view/43/components/
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/
 * Notes:
     - Turn on GLCD backlight switch SW13.8 (board specific).
*/

//Declarations------------------------------------------------------------------
const code char truck_bmp[1024];
//--------------------------------------------------------------end-declarations

// Glcd module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at LATB0_bit;  // for writing to output pin always use latch (PIC18 family)
sbit GLCD_CS2 at LATB1_bit;  // for writing to output pin always use latch (PIC18 family)
sbit GLCD_RS  at LATB2_bit;  // for writing to output pin always use latch (PIC18 family)
sbit GLCD_RW  at LATB3_bit;  // for writing to output pin always use latch (PIC18 family)
sbit GLCD_EN  at LATB4_bit;  // for writing to output pin always use latch (PIC18 family)
sbit GLCD_RST at LATB5_bit;  // for writing to output pin always use latch (PIC18 family)

sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction  at TRISB2_bit;
sbit GLCD_RW_Direction  at TRISB3_bit;
sbit GLCD_EN_Direction  at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// End Glcd module connections

void delay2S(){                             // 2 seconds delay function
  Delay_ms(2000);
}

void main() {                       

  #define DRAWING_DEMO
  //#define TEXT_DEMO

  unsigned short counter;
  char *someText;

  ADCON1 |= 0x0F;                           // Configure AN pins as digital
  CMCON  |= 7;                              // Disable comparators

  Glcd_Init();                              // Initialize GLCD
  Glcd_Fill(0x00);                          // Clear GLCD

  while(1) {
    Glcd_Image(truck_bmp);                         // Draw image
    Delay2s(); Delay2s();
    Glcd_fill(0x00);                                  // Clear GLCD
    Glcd_PartialImage(0,0,68,30,128,64,truck_bmp);    // Partial image
    Delay_ms(500);
    Glcd_PartialImage(24,16,68,30,128,64,truck_bmp);
    Delay_ms(500);
    Glcd_PartialImage(56,34,68,30,128,64,truck_bmp);
    Delay2s(); Delay2s();
    Glcd_Fill(0x00);                               // Clear GLCD

    #ifdef DRAWING_DEMO
      Glcd_Box(62,40,124,56,1);                    // Draw box
      Glcd_Rectangle(5,5,84,35,1);                 // Draw rectangle
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges(2,2,87,38,7,1);
      Delay_ms(1000);
      Glcd_Rectangle_Round_Edges_Fill(8,8,81,32,12,1);
      Delay_ms(1000);
      Glcd_Line(0, 0, 127, 63, 1);                 // Draw line
      Delay2s();

      for(counter = 5; counter < 60; counter+=5 ){ // Draw horizontal and vertical lines
        Delay_ms(250);
        Glcd_V_Line(2, 54, counter, 1);
        Glcd_H_Line(2, 120, counter, 1);
      }
      Delay2s();

      Glcd_Fill(0x00);                             // Clear Glcd

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle(63,32, 3*counter, 1);
      Delay2s();

      for (counter = 1; counter <= 10; counter++)  // Draw circles
        Glcd_Circle_Fill(63,32, 3*counter, 1);
      Delay2s();

      Glcd_Box(12,20, 70,57, 2);                   // Draw box
      Delay2s();

      Glcd_Fill(0xFF);                             // Fill Glcd
    #endif

    #ifdef TEXT_DEMO
      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Choose font, see __Lib_GLCDFonts.c in Uses folder
      Glcd_Write_Text("TEXT DEMO", 24, 3, 2);      // Write string
      Delay2s();
      Glcd_Fill(0x00);                             // Clear Glcd

      Glcd_Set_Font(Character8x7, 8, 7, 32);       // Change font
      someText = "8x7 Font";
      Glcd_Write_Text(someText, 5, 0, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(System3x5, 3, 5, 32);          // Change font
      someText = "3X5 CAPITALS ONLY";
      Glcd_Write_Text(someText, 60, 2, 2);         // Write string
      Delay2s();

      Glcd_Set_Font(font5x7, 5, 7, 32);            // Change font
      someText = "5x7 Font";
      Glcd_Write_Text(someText, 5, 4, 2);          // Write string
      Delay2s();

      Glcd_Set_Font(FontSystem5x7_v2, 5, 7, 32);   // Change font
      someText = "5x7 Font (v2)";
      Glcd_Write_Text(someText, 50, 6, 2);         // Write string
      Delay2s();
    #endif
  }
}
I have tested that using an identical schematic to yours but with the 18f4520 in Isis and it runs perfectly

I think your problem is with the processor model and your C code

Also in Isis you dont need to connect anything to Vo or -Vout on the GLCD for it to work
Bitmap.rar
(934 Bytes) Downloaded 626 times
Thats the bitmap test file you'll need to add to the project
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

User avatar
captalex
decided to stick around...
decided to stick around...
Posts: 28
Joined: Mon Mar 21, 2011 3:00 am
Contact:

Re: Microcontroller based Graphical lcd game

Post by captalex » Tue May 24, 2011 5:46 am

odessa wrote:Hi,

My version of Isis doesn't have the 18f4550, where did you get yours from ? I ask as when I use your design nothing will run at all.

If I delete your 18f4550 and use the 18f4520 in Isis everything runs fine.

I dont use Mikro C, I'm borrowing someone elses to test your code which lists 1000's of error as it runs lol.

If it helps here is a sample GLCD written in Mikro C pro for an 18F4520


I have tested that using an identical schematic to yours but with the 18f4520 in Isis and it runs perfectly

I think your problem is with the processor model and your C code

Also in Isis you dont need to connect anything to Vo or -Vout on the GLCD for it to work

thanks alot odessa, i got mine from a friend too.
about the 1000 errors :
i fixed them, i rewrote the code again and now my glcd can display both text and some cool 8bit graphics!
but for the image i converted my image to an array stored it in a .c file , added it to my c source files in the project setup and called it in my program but it doesnt seem to be able to access the image.
Attachments
eva.rar
image source file
(606 Bytes) Downloaded 639 times
glcd_rect.rar
my c source file
(3.26 KiB) Downloaded 634 times
cool_image.rar
image header file
(144 Bytes) Downloaded 619 times
glcd_rect.rar
my hex file pic 18f 4550
(2.78 KiB) Downloaded 637 times

User avatar
odessa
I practically live here!
I practically live here!
Posts: 102
Joined: Thu Sep 09, 2010 6:06 am
Location: London
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Microcontroller based Graphical lcd game

Post by odessa » Tue May 24, 2011 4:54 pm

Hi,

It works fine in the test code using your Bitmap instead of the truck

There isn't anything in the code you posted there to draw the bitmap

Jay
(\_/)
(='.')
(")-(")
This is a bunny, copy bunny into your signature to help him achieve world domination.

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 19 guests