Shop OBEX P1 Docs P2 Docs Learn Events
why does it show junk? — Parallax Forums

why does it show junk?

basicstampedebasicstampede Posts: 214
edited 2008-10-03 10:40 in General Discussion
Hello.

I have a program that reads temperature.· Then I want to display it on a serial LCD, but I get junk.

SUB Get_Temperature
· HIGH resetpetp
· SHIFTOUT DQ, Clock, LSBFIRST, RdTmp
· SHIFTIN DQ, Clock, LSBPRE, tempIn
· SHIFTIN DQ, Clock, LSBPRE, tempInS\1
· LOW resetpetp
· RETURN

The temp I want to show is in tempIn which is Byte.

Then I convert the tempIn to two numbers and send to LCD as follows.·
· temp10 = tempIn / 10
· temp1 = tempIn // 10
··
· LCDdata = ClearLCD
· SER_OUT
· LCDdata = temp10
· SER_OUT
··LCDdata = temp1
· SER_OUT

Subprogram to show on LCD is tested and working when sending characters.

Do I need to convert it to·ASCII character before sending it to serial LCD?· How do you do that in SX/B?

Thanks.·

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-10-03 02:48
    Yes, you have to convert the number to the ASCII character.· A "0" is $30, a "1" is $31,... a "9" is $39.
  • JonnyMacJonnyMac Posts: 9,214
    edited 2008-10-03 02:50
    The LCD wants ASCII characters and you're sending their decimal values. You need to do something like this:

    temp10 = tempIn / 10
    temp01 = __REMAINDER ' this saves a lot of code versus using //

    LCDdata = temp10 + "0" ' convert to ASCII
    SER_OUT
    LCDdata = temp01 + "0"
    SER_OUT
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2008-10-03 03:51
    You should also make sure you have a stable clock source (resonator, crystal oscillator, etc) to ensure the serial data is transmitted correctly. Some people have tried to use the internal clock source and it isn't accurate enough for reliable serial data. That would also produce garbage. Just something to keep in mind.

    Robert
  • BeanBean Posts: 8,129
    edited 2008-10-03 10:40
    basicstampede,
    It is much easier to troubleshoot if you post the entire program. Otherwise we are just guessing...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson

    "It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter

    www.iElectronicDesigns.com

    ·
Sign In or Register to comment.