Shop OBEX P1 Docs P2 Docs Learn Events
Sending Text to STAMP from VB.NET — Parallax Forums

Sending Text to STAMP from VB.NET

DownsDowns Posts: 30
edited 2008-10-30 23:34 in BASIC Stamp
Hello all,

Connecting to my STAMP via VB.NET 2008 and sending commands to turn on, off and other LCD commands seems to be easy, but how do I send text from my VB app to the LCD screen? When I try to send say "Hello" to the STAMP, all that gets delivered to the LCD screen is "H". STAMP code and VB code is as follows:

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

Input_Pin····· CON··· 0
BAUDMODE··· CON·· 32

Command···· VAR·· Word
LcdOn········ CON·· $16
LcdBLOn······CON·· $11
LcdBLOff····· CON·· $12
LcdClear····· CON·· $0C

Setup:
HIGH Input_Pin
PAUSE 100

Main:
· DO
·· GOSUB GetInput
·· LOOP
·· END

GetInput:
SERIN 16,16780,[noparse][[/noparse]Command]

'Send Input to LCD Screen
SEROUT Input_Pin,BAUDMODE,[noparse][[/noparse]LcdBLOn]··'Turn LCD Backlight On
PAUSE 100
SEROUT Input_Pin,BAUDMODE,[noparse][[/noparse]Command] 'Actual Input from VB.NET
PAUSE 3000
SEROUT Input_Pin,BAUDMODE,[noparse][[/noparse]LcdClear]· 'Clear LCD Screen
PAUSE 5
SEROUT Input_Pin,BAUDMODE,[noparse][[/noparse]LcdBLOff]· 'Turn LCD Backlight Off
PAUSE 5
RETURN
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visual Studio 2008 VB Side

Public
Class Form1

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim MSG As String = TextBox1.Text

If SPort.IsOpen Then

····· SPort.WriteLine(MSG)

Else

····· MsgBox("No connection")

End If

End Sub

End Class



Any help would be greatly appreciated. Thank you!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-10-29 14:30
    To be honest, I don’t even see how you’re getting the H. Each time your code calls the subroutine it is clearing the screen erasing any data. You should be dropping strings into an array and have a routine which prints the array to the LCD.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • DownsDowns Posts: 30
    edited 2008-10-29 15:03
    What I'm trying to do is send the Text to the screen for a few seconds then clear the screen. It works but I don't get all of the text string that's sent from VB.
  • DownsDowns Posts: 30
    edited 2008-10-29 15:17
    Basically I'm just messing around trying to learn how to send text (data) to the stamp then to a LCD screen via VB.NET. I wrote a weather program in VB.NET and it checks the Weather.com's weather and updates my app every 1 minute. Eventually what I'm trying to accomplish is have my app send the current temp and other data over to the STAMP every minute when my app updates itself and have that current temp sent to the LCD screen. Long term goal...... Having two STAMPS, one outside with different sensors to record data (temp, humidtiy.....ect), have the data sent to the second STAMP inside that will be hooked to my TV. I'll be able to pull up AUX channel on my TV and see the data. May be a dumb project to some people but it's just something I want to do. I've got the weather software basically finished, now I need to learn how to send the complete data over to the stamp.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-10-29 18:49
    Hi try this alteration to the variable "Command" and try and send the word Hello.

    Command VAR Byte(10)

    SERIN RX,baud,[noparse][[/noparse]STR Command\5]

    SEROUT Input_Pin,BAUDMODE,[noparse][[/noparse]STR Command\5] 'Actual Input from VB.NET

    it has to be close

    Jeff T.
  • DownsDowns Posts: 30
    edited 2008-10-29 19:22
    Unsoundcode,

    Thanks but nope. That didn't work either. Whatever I type into the text box on the VB side, only the first character get's transmitted to the LCD screen on the stamp. I guess I need to figure out how to do the "Array" thing on the VB side or STAMP side or both.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-10-29 20:35
    Hi, the VB side looks perfect, there must be an error in what I suggested about the Stamp side of things maybe, I'll check it out.

    Jeff T.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-10-29 20:59
    Okay, first of all you have command declared as a word variable, but you’re only sending bytes of data. In your original code you’re only receiving one byte and that is why only the first letter is being received. You need to adjust your code to receive a string. Jeff provided some code to do that, but everything needs to be in the right place for it to work. Can you post the modified code?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • DownsDowns Posts: 30
    edited 2008-10-29 21:13
    Oooops! Ok, I got it to work via what Jeff told me to try. SORRY! Now, that does work for a single 5 letter word but what if the words "Hello, this is your STAMP" was typed into the textbox in the VB app. How do you collect all of that and send it to the LCD?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-10-29 21:18
    Take a look at what he has done…he is basically creating a 5 element array to store your string in. You can make it larger however the BASIC Stamp only has a total of 26 bytes of variable space to start with. If you’re going to be working with longer strings of data like that I would suggest getting a BS2p module and using the Scratchpad RAM to store incoming data like this. You have 126 bytes available and it’s easy to buffer the incoming string directly into this RAM without using any variable space. If you’re clever with how you’re sending data from the VB app and write the BASIC Stamp code to take advantage of this, you could deal with string data pretty easily.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • DownsDowns Posts: 30
    edited 2008-10-29 21:22
    Oh ok. I got it. 26 bytes should be fine for what I'm trying to accomplish in the long run. Much thanks to you and Jeff!! I do appreciate it.
  • DownsDowns Posts: 30
    edited 2008-10-30 23:34
    Screen shots of my little project I was working on see attached. The weather software was something I was working on prior, but just wanted to see if I could send data from it to the STAMP. Now I'll start working on wireless data communication and then from there, build my weather box with sensors that will sit outside and transmit the data to another STAMP that's sitting inside connected to my TV. Pull up PIP on my TV and see the transmitted weather data sent from the outside (STAMP) weather box. Many thanks to those that helped with this tiny little STAMP project!!
Sign In or Register to comment.