Shop OBEX P1 Docs P2 Docs Learn Events
BS2 to vb.net — Parallax Forums

BS2 to vb.net

offlandersofflanders Posts: 9
edited 2008-05-30 16:39 in BASIC Stamp
Hi all

I'm working on a class project and need to work with a BS2 and interface with it in Visual Basic.net. I have looked through the resources currently in the archive and haven't found much about passing strings between the two.

In short the project involves getting a BS2 to read information from a sonic range finder and then transmit the information back to a VB.net program and display it in nice big numbers for all to see. I'm able to get the range finder to operate but getting VB.net to see the BS2 is giving me great ammounts of trouble thus far. The following is a example code that I can't seem to get to work.

If serialPort.IsOpen Then
serialPort.Close()
End If

Try
With serialPort
.PortName = "COM4"
.BaudRate = 9600
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
End With
serialPort.Open()

Thanks
Bryan

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-05-29 17:46
    One thing, every time you open the serial port you will reset the stamp. What is it you are getting from the stamp or is your problem you don't know how to open the port in vb?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-05-29 19:27
    Hello,

    There are plenty of resources for VB and BASIC Stamps lately. There has been much discussion on the forums in general, but there have also been several projects posted in the Completed Projects forum, most with source code. There’s a VB.net application for the Parallax Servo Controller and another for the RFID Reader that immediately come to mind. Also, Jan Axelson, author of several books has an article in the April 2008 Nuts & Volts magazine on this very subject. You can get some information from her website at www.lvr.com· I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-05-29 20:45
    Hi Bryan, this link has some info for setting up a VB serialport interface and a couple of pointers on how to pass simple data between a BS2 and the PC.

    http://forums.parallax.com/showthread.php?p=671804

    Jeff T.
  • offlandersofflanders Posts: 9
    edited 2008-05-30 16:04
    Thanks for the input, I discovered that the most simple way to accomplish vb to bs2 communication is to use Visual Basic Express. It has built-in Serial support where as other versions of vb tend to be a bit more tricky.

    I do have question about getting the BS2 to receive a string (I.E a word) at the the moment I can only get it to send one character, so if I was to send a word, say, "Parallax", all I receive on the other end is "P". Dose the SERIN command only receive one letter at a time?

    Thanks for the help
  • LarryLarry Posts: 212
    edited 2008-05-30 16:39
    read up on using the string modifier to SERIN for receiving serial input. you need to specify the maximum number of characters to expect.

    Statements might look something like:

    serString   VAR   BYTE(8)
    
    SERIN 1, 16468, [noparse][[/noparse]serString\8]
    
    DEBUG STR serString
    
    



    When you input "parallax" now, that's what you'll get out.
Sign In or Register to comment.