Shop OBEX P1 Docs P2 Docs Learn Events
Sending Text to LCD(A Data Variable) — Parallax Forums

Sending Text to LCD(A Data Variable)

DiablodeMorteDiablodeMorte Posts: 238
edited 2005-07-06 20:14 in BASIC Stamp
Ok.. First I want to say that I did search the forum for an answer and that I'm not completly new to Basic Stamp's but I am new.


Anyway... Back to my problem.

I have a LCD hooked up to my basic stamp. Now that works fine. I can turn it off. Clear it, Turn it back on, ouput strings manually, and output numbers but What i can't seem to figure out is how to output a DATA variable. I looked at the scrolling text tutorial but it doesn't work for my special LCD. Everthing else does. Anyhow. When i try to send a data variable to the LCD i only get the first Letter and when i try to declare something like:
teststring var word
teststring = "foo" 



The stamp editor gets mad and says that i can only have 1 char in the ("")
Oh, and the idea behind the project is taht the basic stamp reads a string from the serial port(figured that out) and then outputs the string it gets to the lcd screen(like a text message)


Thanks in advance,
DiablodeMorte

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-06 05:19
    Hello,

    ·· The easiest way to handle this is to read the data one character at a time from the serial port, and send each character to the LCD as it comes in.· 1 variable used, and simpler code.· Now, the other way is to use an array, but I don't know how long the string is you need to handle, so it's hard to say what the best approach is.· Just out of curiosity, which model BASIC Stamp do you have?


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • DiablodeMorteDiablodeMorte Posts: 238
    edited 2005-07-06 11:37
    I am using the Basic Stamp 2. And as far as the way you sugguested to handel this.. Could you give me a sample so i know what to go by? That would be helpful



    Regards,
    DiablodeMorte
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-06 12:47
    Death-Devil:

    You can't assign strings to variables -- as you've seen you can only hold a single character.· What you can do is point to a string stored in a DATA statement and go from there.· I tend to use z-strings so that I can embed carriage returns; like this:

    Msg1···· ·DATA···"BASIC Stamp", 0

    Now I need a pointer to the string and a variable to hold the character being "printed" on the LCD:

    eePntr··· VAR··· Word
    char····· VAR··· Byte

    When I want to "print" to the LCD I assign the point to the string I want printed, and then call the subroutine:

    Main:
    · eePntr = Msg1
    · GOSUB Print_To_LCD

    ... and here's the subroutine:

    Print_To_LCD:
    · DO
    ··· READ eePntr, char
    ··· IF (char = 0) THEN EXIT
    ··· GOSUB LCD_Write·············· ' <-- adjust for your Stamp model
    ··· eePntr = eePntr + 1
    · LOOP
    · RETURN

    You should be able to adapt this strategy to your program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-06 14:30
    DiablodeMorte said...
    I am using the Basic Stamp 2. And as far as the way you sugguested to handel this.. Could you give me a sample so i know what to go by? That would be helpful
    Regards,
    DiablodeMorte
    Okay,

    ·· Well, you specified that you wanted to take characters received from the serial port and send them to the LCD.· Do you have code for receiving characters from the serial port?· Do you have code for writing to the LCD?· The best thing for you to do at this point is work on each individual task, then merge them.· An example of writing to the LCD is listed above.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Tom-Matrix OrbitalTom-Matrix Orbital Posts: 38
    edited 2005-07-06 15:11
    What brand is your LCD?
  • DiablodeMorteDiablodeMorte Posts: 238
    edited 2005-07-06 19:38
    [noparse][[/noparse]EDIT]
    Ok.. Now i need some more help. Your code works fine but I need help. I need to get the variable(msg_data) from:
    SERIN 16,16780,[noparse][[/noparse]WAIT(255),MSG_Data]
    


    and Put it INTO the contents of the
    Msg1 DATA variable. How would I do this?


    Chris Savage (Parallax) said...
    DiablodeMorte said...

    I am using the Basic Stamp 2. And as far as the way you sugguested to handel this.. Could you give me a sample so i know what to go by? That would be helpful
    Regards,
    DiablodeMorte
    Okay,


    Well, you specified that you wanted to take characters received from the serial port and send them to the LCD. Do you have code for receiving characters from the serial port? Do you have code for writing to the LCD? The best thing for you to do at this point is work on each individual task, then merge them. An example of writing to the LCD is listed above.

    Woops.. Perhaps I didn't make my self clear. I do have the code to recieve the data and the code to output to the LCD screen..


    Oh, and the code that you gave me Jon Williams worked. Thank you very much.


    As for My brand: I have no idea :P (It's annoying how lcd's don't have labels)

    Post Edited (DiablodeMorte) : 7/6/2005 7:47:59 PM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-07-06 20:05
    You can use the 'WRITE' keyword, to write data into the on-module EEPROM.

    You should do this with care and reluctance, though. The on-module EEPROM has about a million write cycles -- after that, locations stop working. While a million sounds like a lot, if you write to the same location every 10 mSec, you can wear it out in a few hours (10,000 seconds, I believe)

    Now, most useage of the EEPROM is for writing your program to it. If you update your program once a minute, it will take 114 years to wear it out.

    Just be aware, and only write to the EEPROM on a seldom basis. Now if you NEED to write to the EEPROM more often than that, you CAN get an external SPI interfaced EEPROM (like the 24L640 (?)) and use that. If you use it up, plug in a new one.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-06 20:14
    ·· If you already have both codes, merging them shouldn't be too hard.· Your routine inputs data into a variable called, MSG_Data.· Just use that same variable in your LCD Output routine for what you want to send to the LCD, and you'll be all set.· Perhaps post both codes?· As attachments please.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.