Displaying a changing variable on LCD0821

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
Turnbull2112
LCD?
Posts: 9
Joined: Tue Jan 04, 2011 8:39 am
Location: Florida

Displaying a changing variable on LCD0821

Post by Turnbull2112 »

How would I get a variable displayed next to the following.

' {$STAMP BS2}
' {$PBASIC 2.5}

SEROUT 1, 33, [254] 'Command Prefix
SEROUT 1, 33, [88] 'Clear screen command
SEROUT 1, 33, ["TEMP = XXXX*F"]

I'm using a Basic Stamp BS2. The "XXXX" would be the variable and everything else would remain. I am pretty new to this so go easy on me!! Any help would be greatly appreciated.

Rob

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Rob,

We do have a number of Basic Stamp examples available in our AppNote Section, I would recommend checking them out to gather a little more info on the language and our display.

I spend my time in C++ or C# but the concepts should be similar. To send a variable to the display it should be either an ascii string or a number of ascii characters. It looks like you'll have to convert an integer to do so, which hopefully has a built in function as it does in C. And that should be it.

Try creating a string variable and sending it to the display first, then start on the conversion. Also, you might want to look into the cursor position command to refresh the variable and the custom character command to create a nice degree symbol.

Have a look through the appnotes and let us know if you have any further questions or concerns as you continue development.

Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital

Turnbull2112
LCD?
Posts: 9
Joined: Tue Jan 04, 2011 8:39 am
Location: Florida

Eh :-/ .. need some more help here...

Post by Turnbull2112 »

I'm still having trouble with this. This is one part I am under tremendous pressure to figure out right now. Do you have any quick sample code examples or anything? As soon as I see it work I can zip through the rest of my project. I am sorry to be this needy LOL

Rob

Turnbull2112
LCD?
Posts: 9
Joined: Tue Jan 04, 2011 8:39 am
Location: Florida

Post by Turnbull2112 »

What I'd like to try for testing purposes is to have and RCTIME variable displayed through the LCD0821. I want to use the code below to feed the LCD.

' {$STAMP BS2}
' {$PBASIC 2.5}

time VAR Byte

Get_Rc_Time:
DO
HIGH 4
PAUSE 3
RCTIME 4, 1, time

DEBUG DEC time, CR
LOOP
RETURN

If it's possible, how would I get the "time" to show up next to some fixed text?? Any help would be HUGELY appreciated. Thanks

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Rob,

In the appnote section I linked earlier you'll see code for sending text and commands to the display. Both are a couple lines long and should give you a quick idea of how to send info to the display.

To get the text to remain in one spot, you'll probably want to use the set cursor command each time you write the time to the display.

I believe the largest problem here will be converting your single byte time to a string to display on the screen. For example, if your time was 100ms, sending the single byte decimal value 100 to the screen would result in a 'd' appearing. You'd need to convert to the ascii characters '1', '0', '0' or decimal 49, 48, 48 before sending the time to the display.

That should get you started, but if you do have any further trouble please don't hesitate to ask.

Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital

Turnbull2112
LCD?
Posts: 9
Joined: Tue Jan 04, 2011 8:39 am
Location: Florida

Post by Turnbull2112 »

I'm still not sure how to convert the 100 into ASCII and then display it. I'm just now getting the hang of cursor placement. Can you provide an example of what the code may look like? I'm still pretty confused here. Do you provide phone support by chance? I need to get this ball rolling.
Thanks.

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Turnbull,

Conversion is a question more associated with code than display, but I do have a Basic Stamp manual here so I've taken a look. Again, keeping in mind I am no programmer, the following should do close to what you requested at the beginning of this post.

Temp VAR Byte
'Assign a value to Temp
SEROUT 1, 33, [254, 88] 'Clear screen command
'Move the cursor
SEROUT 1, 33, ["TEMP = ", DEC Temp, "*F"] 'Output Temperature

We are quickly approaching the limit of my knowledge with regard to code, so I'll have to say from this point you are largely on your own mate. If you do have questions regarding any other functions of the display, or get a nice algorithm running that you'd like to share, please don't hesitate to post.

Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital

Turnbull2112
LCD?
Posts: 9
Joined: Tue Jan 04, 2011 8:39 am
Location: Florida

Post by Turnbull2112 »

YOU. ARE. THE. MAN. That worked!!!! Here is what I was using to test the program.

Thanks for your help!! I will post my project up here when I'm finished!

' {$STAMP BS2}
' {$PBASIC 2.5}

freq VAR Byte

DO

Get_Rc_Time:
HIGH 2
PAUSE 3
RCTIME 2, 1, freq

DEBUG DEC freq, CR

SEROUT 1, 33, [254, 88]

SEROUT 1, 33, ["PWR ", DEC freq, " %"]

PAUSE 200

LOOP

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

No worries Turnbull, great to hear the code is up and running! If you can share some of the basic I/O used in Basic Stamp when you're done, I'm sure it'd be a great help to future developers.

Thanks again,
~Troy
Troy Clark
Design & Development
Matrix Orbital

Post Reply