Shop OBEX P1 Docs P2 Docs Learn Events
serial LCD needs delay? — Parallax Forums

serial LCD needs delay?

kdoggfunkstahkdoggfunkstah Posts: 3
edited 2006-03-24 17:48 in General Discussion
I purchased the serial lcd from parallax and I've been testing it out interfacing it with a pic microcontroller.
I wrote code in order to send characters via the uart in the pic. When I first tried to run this, it shot out garbage, except for the first few characters. I played around and tried to put in a delay between each character and it fixed the problem. However, the specs do not mention this and I would like to not have this delay due to the large amount of time it takes to update a whole screen.
Can anyone help me out with this one? Thanks!

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-24 16:20
    There are some commands, like clearing the LCD, that do in fact require a bit of a delay -- this is a function of the LCD, not the controller. That said, remember that there is another host processor that has to take your commands and then deal with the LCD, so adding a bit of pacing won't anything.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • kdoggfunkstahkdoggfunkstah Posts: 3
    edited 2006-03-24 16:39
    I'm still a little confused... Is there a time required for the serial to parallel circuitry that comes with the module? I would imagine there would be a fixed time needed in order to convert the incoming serial data to parallel? Is there any specifications on this?
    In my host controller code I have it so the uart does not send another data until the data is fully sent. Should there be a feedback from the lcd module that should tell my controller that it is safe to send another character?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-24 16:52
    Can you post your source code? I think that would help us help you. And no, there is no feedback from the LCD. I'm sure that you just need to insert proper timing into a few key spots. I've written code for our serial LCD that runs on the SX micro; this is very similar to the PIC. If it works on an SX, we can help you get it working on your PIC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • kdoggfunkstahkdoggfunkstah Posts: 3
    edited 2006-03-24 17:10
    Here is my LCD initialization code:
    void init_LCD()
    {
    PORTCbits.RC6=1;
    Delay10KTCYx(51); // 100ms delay
    putcUSART(0x0C); // Clear LCD Screen
    while(BusyUSART());
    Delay100TCYx(40);
    }

    and here is the current lcd output function:

    void out_lcd(void)
    {

    // x position
    // convert to ascii numbers
    // send one by one
    for(i=0;i<5;i++)
    {
    putcUSART(x_ascii); // put in array
    while(BusyUSART());
    Delay100TCYx(40);
    }

    // send to position 6 0x86

    // y position
    for(i=0;i<5;i++)
    {
    putcUSART(y_ascii); // put in array
    while(BusyUSART());
    Delay100TCYx(40);
    }


    // send to position 12: 0x8C


    // z position
    for(i=0;i<5;i++)
    {
    putcUSART(z_ascii); // put in array
    while(BusyUSART());
    Delay100TCYx(40);
    }


    // pitch
    for(i=0;i<5;i++)
    {
    putcUSART(pitch_ascii); // put in array
    while(BusyUSART());
    Delay100TCYx(40);
    }

    // send to position 6, line2 0x9A

    // roll
    for(i=0;i<5;i++)
    {
    putcUSART(roll_ascii); // put in array
    while(BusyUSART());
    Delay100TCYx(40);
    }

    // send to position 12, line2 0xA0;

    // yaw
    for(i=0;i<5;i++)
    {
    putcUSART(yaw_ascii); // put in array
    while(BusyUSART());
    Delay100TCYx(40);
    }
    }



    Thanks!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-24 17:48
    Our serial LCD docs suggest a 5 ms delay after sending the clear screen (0x0C) instruction -- you don't have this in init_LCD.

    And I'm not much of a C programmer, but your numeric conversion routines don't seem to use the loop index to point to an individual character within the array.· For example:

    void out_lcd(void) {
    · // x position
    · // convert to ascii numbers
    · // send one by one

    · for(i=0;i<5;i++) {
    ·· ·putcUSART(x_ascii); // put in array
    ·· ·while(BusyUSART());
    ·· ·Delay100TCYx(40);
    · }

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.