1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Problem interfaceing PIC18F2550 and KS0108 LCD

Discussion in 'Microcontrollers' started by hkBattousai, Nov 6, 2009.

  1. ChipBurner

    ChipBurner New Member

    Joined:
    Jul 1, 2010
    Messages:
    5
    Likes:
    1
    Hi 3v0, thanks by the answer but the lib, link, inc phats are well defined... well they are like you told me.. e:\microchip\MCC18\lib; e:\microchip\MCC18\LKR; e:\microchip\MCC18\h.
    maybe the student version have no features for this? I don't know... but I would like to know if some one tell me...
    Any one knows if exist a errors manual? I'm trying to find it in the manuals of the compiler but until now I didn't found any thing... If you know please post a link to it. Thanks
     
    Last edited: Jul 2, 2010
  2. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Yes but if you get this error they only work if you set them using the method I provided !
     
    Last edited: Jul 2, 2010
  3. ChipBurner

    ChipBurner New Member

    Joined:
    Jul 1, 2010
    Messages:
    5
    Likes:
    1
    YOU ARE THE MAN!! hehe, this error is solved!
    thanks!!!
     

    Attached Files:

    Last edited: Jul 2, 2010
    • Like Like x 1
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ChipBurner

    ChipBurner New Member

    Joined:
    Jul 1, 2010
    Messages:
    5
    Likes:
    1

    To contribute for who needs... I used the 3 codes in the first post of this threat, then because my pic and hardware are different (18f452) my chages was:
    GLCD.H

    #include <p18f452.h>
    //#define __18C452_H
    #define GLCD_Data PORTD
    #define b_GLCD_GCS1 LATBbits.LATB2
    #define b_GLCD_GCS2 LATBbits.LATB1
    #define b_GLCD_RS LATEbits.LATE1
    #define b_GLCD_RW LATEbits.LATE0
    #define b_GLCD_E LATEbits.LATE2
    #define b_GLCD_On LATBbits.LATB0
    #define b_GLCD_BL LATAbits.LATA0 // Not used in my project

    #define TRIS_Data TRISD
    #define b_TRIS_GCS1 TRISBbits.TRISB2 //GCS1
    #define b_TRIS_GCS2 TRISBbits.TRISB1 //GCS2
    #define b_TRIS_RS TRISEbits.TRISE1 //RS
    #define b_TRIS_RW TRISEbits.TRISE0 //RW
    #define b_TRIS_E TRISEbits.TRISE2 //E
    #define b_TRIS_On TRISBbits.TRISB0 //RST
    #define b_TRIS_BL TRISAbits.TRISA0 //backlight

    void Delay(void);
    extern unsigned char GLCD_Read(void);
    extern void Wait_Not_Busy(void);
    extern void GLCD_Write_Cmd(unsigned char data);
    extern void GLCD_Write_Data (unsigned char data);
    extern void ClearScreen(void);
    extern void Init_GLCD(void);
    extern void PutChar(unsigned char data);
    extern unsigned char GLCD_Read_Data(void);
    extern void SetPos(unsigned char x,unsigned char y);
    extern void WritePosition(void);
    extern void plot(unsigned char x,unsigned char y);
    extern void hline(unsigned char x,unsigned char y1,unsigned char y2);
    extern void vline(unsigned char x1,unsigned char x2,unsigned char y);
    extern void box(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2);
    extern void PutMessage(static char rom *Message);
    extern void PutLogo(static char rom *logo);


    Main.c
    #include <p18f452.h>
    #include "glcd.h"
    #pragma config WDT = OFF
    #pragma config BOR = OFF
    #pragma config STVR = ON
    #pragma config DEBUG = ON
    #pragma config LVP = OFF
    //#pragma config PLLDIV= 5 // need 5 for 20MHz xtal
    //#pragma config CPUDIV= OSC1_PLL2 // CPU Clock = 96 MHz/2 = 48 MHz
    //#pragma config USBDIV= 2 // 96MHz PLL/2 = 48 MHz for USB clock
    #pragma config OSC = RC //HSPLL_HS // High Speed Crystal / Resonator with PLL enabled
    #pragma config OSCS = OFF //OSC. SWITCH
    //#pragma CP0 = OFF
    //int li;
    //#pragma ADCON1=0x0f; // all digital
    //#pragma CMCON=7; // no comparators
    void main (void)

    Good Luck for the readers and thanks for who helped me!
     
  6. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    Hello

    I'm experiencing problems to get KS008 library working well with PIC 18 familly.

    In fact, all my code compile properly but when i run the program its hangs up during Init_GLCD(); function

    With debug mode, i found that GLCD_Read function gets an issue when it tryes to return LL, i don't know why :confused:

    Code (text):
    unsigned char GLCD_Read(void){
        b_GLCD_E=1;
        Delay();

            LL=GLCD_Data;
        b_GLCD_E=0;
        [COLOR="Red"]return LL; [/COLOR]
    }
    For test purposes, i tried to comment out " return LL; " line, then program goes through but it is not able to display anything on the GLCD.


    Here is attached m GLCD.c file ( modified to complement CS1 and CS2 with "1-" solution from Pommie's idea. :)

    For my GLCD, if i read well the datasheet i found :
    CSx ARE complemented,
    E is not complemented.
    R/W': R is not complemented, W is complemented,
    RS (D/I', D: Data, I: Instruction): D is not complemented, I is complemented
    RST pin is not available on my GLCD.


    Any help will be much appreciated, because i can't find why the programs hangs during Init function.

    Best Regards,
     

    Attached Files:

    Last edited: Nov 14, 2010
  7. hkBattousai

    hkBattousai Member

    Joined:
    Oct 30, 2009
    Messages:
    196
    Likes:
    0
    ^ Did you try the attached library in message #22?
    I suggest you do so.
     
  8. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    I've just tested your library and program freezes exactly at the same position :

    in your code , it stops at return glcdData;

    Code (text):
    unsigned char glcd_Read(void)
    {
        GLCD_EN = GLCD_EN_HIGH;
        glcd_Delay();
        glcdData = GLCD_DATA;
        GLCD_EN = GLCD_EN_LOW;
        [COLOR="Red"]return glcdData;[/COLOR]
    }

    If i comment out return glcdData;, then program runs properly.
    But it only lights the left hand side board, if i try to Put a Message that is located in the middle on the display it is not working properly !

    What should i do to have all display available ?
    If i put a text longer than pos (64,64) then the display returns to x = 0 position but keeps y postions ( see attached picture for message : "50/50" written at x=50 y=50

    Here are the instruction i used to display the attached picture:
    Code (text):

    glcd_SetPos(10,0);                      // Positionner le curseur (x,y)
    glcd_PutMessage("Graphic");             // Ecrire un message

    glcd_SetPos(50,50);                    
    glcd_PutMessage("50/50");               // Write "50/50" at position x=50 y=50

    glcd_SetPos(0,63);
    glcd_PutMessage("0,63");                // Write "0,63" at position x=0 y=63

    glcd_Plot(63,32);
    glcd_Box(12,35,25,45);

    glcd_HorizontalLine(10,40,50);
     

    By the way :
    Can someone tell me why glcd_Read returns glcdData , why this is usefull ?
    It looks that glcd_Data is never been changed during glcd_Read function ...
    if i understand well, gllcd_Read function sets some pins to proper state and do only glcdData = GLCD_DATA;


    Many thanks for your help,
     

    Attached Files:

    Last edited: Nov 14, 2010
  9. crocu

    crocu Member

    Joined:
    Feb 20, 2009
    Messages:
    118
    Likes:
    1
    Location:
    France
    Hello,

    I finally succeeded to get hkBattousai GLCD library working ...
    ( I've got a problem with CS2 pin )

    But this library looks getting outstanding results :

    - It looks that it is reverse displaying method : White on Black instead of Black on White
    Is there a way to change this ?

    - When i try to display a long text that uses the 2 controllers ( CS1 and CS2 ) :

    Text well displayed until x position is < 63,
    when x position is > 63 the rest of text 1 pixel shifted up.

    ( see my attached capture, "n is (10,32)" is centered with the beginning to the text.
    Also "o" letter is also a bit overwritten. ( 2 pixels are missing at the right hand side )

    - When i try to display only one pixel with Plot function, i do not get anything on the screen.


    I will appreciate your help and advices,
    Best Regards,
     

    Attached Files:

  10. captalex

    captalex New Member

    Joined:
    Apr 10, 2011
    Messages:
    2
    Likes:
    0
    wg12864b lcd problem

    hello hkbattousai,
    i have a similar graphical lcd like the one that you have, i got it from turkey, its a wg12864b and i'm using a pic 18f4550 micro controller.
    i have wired up the lcd to my pic using a breadboard and i will attach a potentiometer to adjust the contrast soon, but the problem is that my lcd does even come on! i burned the code successfully to the pic and everything looks wired properly, i hope you could help me . i shall attach the code and and my project schematic. to open the second file simply remove the .zip at the end of the extension and open using proteus simulator
     

    Attached Files:

  11. hkBattousai

    hkBattousai Member

    Joined:
    Oct 30, 2009
    Messages:
    196
    Likes:
    0
    ^ Your zip file is not opening, it is corrupt.
    The C file is a very big (+2000 lines) and messy (probably in Spanish), thus very hard to understand and I couldn't find any glcd commands in it.
    Can you briefly write here (between
    Code (text):
     tags) your relevant glcd code?
     
  12. captalex

    captalex New Member

    Joined:
    Apr 10, 2011
    Messages:
    2
    Likes:
    0
     

    Attached Files:

  13. sandip1181

    sandip1181 New Member

    Joined:
    Jun 21, 2011
    Messages:
    2
    Likes:
    0
    Glcd

    Dear hkBattousai,

    - Can you send me the code for the Graphics LCD WG12864B that work fine at your end.

    - I am facing the same problem that you had face during your development of GLCD.

    - Please help

    Thanks,

    Sandip Nandwana
     
  14. hkBattousai

    hkBattousai Member

    Joined:
    Oct 30, 2009
    Messages:
    196
    Likes:
    0
    ^ Hello, I'm out of city for a few days. I will message you when I'm back.
     
  15. Gobbledok

    Gobbledok Active Member

    Joined:
    Mar 9, 2008
    Messages:
    452
    Likes:
    34
    Location:
    Toowoomba, Australia
    Unless you have the contrast pot wired in, it is likely that you can't see anything anyway. You need the contrast pot.
     
  16. sandip1181

    sandip1181 New Member

    Joined:
    Jun 21, 2011
    Messages:
    2
    Likes:
    0
    bUT what should be the Vee voltage range? As per the datasheet we have to provide the negative voltage but , what is min and max range for this Vee?
     
  17. Gobbledok

    Gobbledok Active Member

    Joined:
    Mar 9, 2008
    Messages:
    452
    Likes:
    34
    Location:
    Toowoomba, Australia
    VEE is usually supplied by the LCD module (usually called the VEE pin ;)).

    One side of the pot goes to VEE, the other side of the pot to ground, and the wiper goes to the contrast pin. Use a 10K pot.
     
    Last edited: Jun 23, 2011
  18. ahm rakib

    ahm rakib New Member

    Joined:
    Aug 31, 2011
    Messages:
    1
    Likes:
    0
    Location:
    Dhaka,Bangladesh
    Dear hkBattousai,
    Have you tried with Flow code to connect and compile ?
    And then burn with USBurn v1.10a2.
     

Share This Page