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

need help in glcd

Discussion in 'General Electronics Chat' started by darsin, Jul 16, 2008.

  1. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
  2. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    168
    Location:
    Toronto, Canada
    What do you need?
     
  3. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
    well actually i had found the sample code from pommie. I tried his code in my glcd but the only thing different is the size. His glcd is 128x64 whereas mine is 128x128. I straight use his code to try in my glcd is it correct?

    my glcd have 4 chip select and his glcd has 2 chip select. so it will just only on my cs1 and cs2 in my gcd right?

    but then my glcd can not display even a pixel. some times it will display some but could not get exactly the same result like pommie's graphic.
     
  4. dave

    Dave New Member

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


     
  5. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia

    Unfortunately, when I wrote that demo code I was a little lazy and referred to some of the ports in code and so this required additional changes to be made throughout the code. I've attached a newer version of that code that should only require the #defines in GLCD.h to require modifying in order to work on different hardware. As for controlling the other two CS lines, I think the code I posted in your other thread should work.

    Mike.
    Edit, please see further down the thread for a corrected version of the code.
     
    Last edited: Jul 21, 2008
  6. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
    dear pommie,
    are you using C18 C Compiler?
    which version of the mplab are you using?
     
  7. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    Yes, I am using C18 on version 8.02 of MPLAB.

    Mike.
     
  8. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
    i changed the chip select code.
    but still nothing display in my glcd
    code:
    void WritePosition(void){
    b_GLCD_GCS1=0;
    b_GLCD_GCS2=0;
    b_GLCD_GCS3=0;
    b_GLCD_GCS4=0;
    if (YPos>63){
    if(XPos>63){
    b_GLCD_GCS4=1;
    b_GLCD_GCS3=1;
    }
    else{
    b_GLCD_GCS2=1;
    b_GLCD_GCS1=1;
    }
    }
    GLCD_Write_Cmd(0x40+(XPos&0x3f)); //column=0
    GLCD_Write_Cmd(0xb8+((YPos&0x3f)>>3)); //row=0
    }

    and please check this for me
    code:
    void Wait_Not_Busy(void){
    TRIS_Data=0xff;
    b_GLCD_RS=0;
    b_GLCD_RW=1;
    if (b_GLCD_GCS1==1 && b_GLCD_GCS2==1){
    b_GLCD_GCS1=0;
    while (GLCD_Read()&0x80);
    b_GLCD_GCS1=1;
    b_GLCD_GCS2=0;
    while (GLCD_Read()&0x80);
    b_GLCD_GCS2=1;
    }

    if (b_GLCD_GCS3==1 && b_GLCD_GCS4==1){
    b_GLCD_GCS3=0;
    while (GLCD_Read()&0x80);
    b_GLCD_GCS3=1;
    b_GLCD_GCS4=0;
    while (GLCD_Read()&0x80);
    b_GLCD_GCS4=1;
    }
    else{

    while (GLCD_Read()&0x80);
    }
    TRIS_Data=0x00;
    }

    please help me~:eek:
     
  9. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    Forget about getting it to work with the 4 CS pins and just concentrate on getting it to work with 2. Make sure the unused CS pins are held low at all times.

    Have you changed the #defines in the GLCD.h file?

    Mike.
     
  10. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
    yes but i just added:
    #define b_GLCD_GCS3 LATAbits.LATA0
    #define b_GLCD_GCS4 LATAbits.LATA1
    and
    #define b_TRIS_GCS3 TRISAbits.TRISA0 //GCS3
    #define b_TRIS_GCS4 TRISAbits.TRISA1 //GCS4

    is it any other #defines need to change too??
    my backlight of anod and katod already connected to the Vdd and Gnd respectively
    so i don't need to connect to the port right?
     
    Last edited: Jul 16, 2008
  11. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    I just checked the code I posted earlier and it was the wrong version. Could a mod please delete it.

    Here is the original code with the required mods so you should just have to change GLCD.h Sorry about the earlier confusion.

    Mike.
    PS, What happened to the edit period becoming 1 week?
     

    Attached Files:

    • GLCD.zip
      File size:
      31.6 KB
      Views:
      463
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,181
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Mike,
    Electromaster confirmed its now 1 hour, for a longish trial period.
     
  13. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    Hi Eric,

    See the last post of this thread. I hope it is changed as it stops silly mistakes (as above) from cluttering up the forum.

    Mike.
     
  14. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
    pommie my glcd is still not working
    it display nothing!:(
    i checked all the connection and i'd grounded my cs3 n cs4...

    p/s:i wanna cry~~~
     
  15. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    Can you post a circuit diagram?

    Are you using an ICD2 or a Pickit2, if so can you pause it and see where it is stopping?

    Mike.
     
  16. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,181
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Mike,
    Following that thread link you posted, gave me the above as at the 13th July.

    I am sure its 60 mins.
     
  17. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
    this is my schematic, others i a bit lazy to draw it out.
    i'm using ICD2 to program...
    is it the problem is on my potentiometer part?
    i'm using 10k...
     

    Attached Files:

    Last edited: Jul 17, 2008
  18. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    I can't find a data sheet for that display so I'm not sure but I would think that Vout should go to the top of the potentiometer. Have you changed the 16 #defines in GLCD.h to match your circuit?

    If you setup your ICD2 as debugger and hit pause after it has run, which line does it stop on?

    Mike.
     
  19. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    BTW, where is your crystal?

    If you don't have one then that is the problem.

    It can be changed to the internal oscillator if needed.

    Mike.
    edit, if this is your problem then you need to change the following bits in main.c
    Code (text):

    #include <p18f4550.h>
    #include <GLCD.h>

    #pragma config WDT = OFF, LVP = OFF, [COLOR="Blue"]FOSC = INTOSCIO_EC[/COLOR]

    const rom unsigned char Logo[];

    void main (void){
    unsigned char i;
    [COLOR="blue"]    OSCCON=0x70;[/COLOR]               //added
        ADCON1=0x0f;               // all digital
        CMCON=7;                   // no comparators
        Init_GLCD();
     
     
    Last edited: Jul 17, 2008
  20. darsin

    darsin New Member

    Joined:
    May 4, 2008
    Messages:
    45
    Likes:
    0
    Location:
    malaysia
    yes! i changed it. the data sheet i had posted in the 1st post.
    I connected 20MHz crystal on my circuit board already.
    i just using the ICD2 programmer but not the debugger.
     
  21. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,015
    Likes:
    317
    Location:
    Brisbane Australia
    Try changing it to the internal oscillator anyway. Your crystal may not be starting up correctly. You don't need to change your circuit, just the code.

    Mike.
     

Share This Page