Shop OBEX P1 Docs P2 Docs Learn Events
Visual basic communications with Stamp — Parallax Forums

Visual basic communications with Stamp

ChilesChiles Posts: 15
edited 2009-12-01 18:41 in BASIC Stamp
ok so originally I bought the Basic stamp homework board that connects to the 9-pin serial port and I wrote several programs with VB(visual basic 2008)·that talk to the basic stamp 2.·· Everything works fine.

Now I bought a new computer and a USB BOE with the basic stamp 2.· I am having trouble trying to get the programs to work now.· Just going into VB programs and changing the com1 to com4 has not fixed the problem - it has given a new error - incorrect programming of port com4?

Anyone know the fix?

·

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-04-18 00:53
    Hi Chiles, instead of modifying your code to suit a particular comm port it would be better if your program enumerated the ports everytime it loaded and then gave you a choice of ports to select from. The template at this link http://forums.parallax.com/showthread.php?p=671804 outlines how to enumerate the ports and give the user a drop down list to choose from.

    Jeff T.

    ·
  • Ted TuranskiTed Turanski Posts: 4
    edited 2009-04-19 23:34
    Excellent, Chiles, on writing visual basic programs that talk to the BASIC Stamp 2 homework board via 9 pin connector.

    I've never done that.· Would you list·your simplest VB code that does that so I can try it myself.· Sorry I don't have the

    answer to your question.

    Ted Turanski
    ·
  • ChilesChiles Posts: 15
    edited 2009-11-27 09:58
    Sorry I know this is like 8 mo later -time flys when your having fun...

    usb connection BOE:
    when you run parallax program it tells you the port no. Can be even higher than com10,
    rs232 is going to be com1-4

    VB than must be programmed to receive and send this port
    stamp programming is with SIN SOUT
  • ChilesChiles Posts: 15
    edited 2009-11-27 10:30
    VB has a com port tool, so it makes it easy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    pan33.gif

    this is the way I pan one of my cameras from the internet - RS232 from security program
  • sahnianasahniana Posts: 12
    edited 2009-11-29 19:12
    Ted Turanski said...

    Excellent, Chiles, on writing visual basic programs that talk to the BASIC Stamp 2 homework board via 9 pin connector.

    I've never done that.· Would you list·your simplest VB code that does that so I can try it myself.· Sorry I don't have the

    answer to your question.

    Ted Turanski

    communication between VB6 and BS2 is simple. In VB6, you use MSCOMM control, and in BS2 you use SERIN and SEROUT. If you want a sample, I can make you one.

    Post Edited (sahniana) : 11/29/2009 7:26:41 PM GMT
  • ChilesChiles Posts: 15
    edited 2009-12-01 17:43
    Here is a simple test program for between VB2005,8 to stamp its rough but works. if your using USB connect then it won't be com1 more like com10, set baud rate 2400 in this example

    this is the stamp program to receive data or a single char- if its a "A" or not

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

    sData VAR Byte

    Main:
    SERIN 16, 16780, [noparse][[/noparse]sData]


    IF (sData = 65) THEN GOTO Flack
    END

    Flack:
    HIGH 14
    PAUSE 900
    LOW 14
    PAUSE 900
    HIGH 12
    PAUSE 900
    LOW 12
    PAUSE 900
    END

    this program sends to VB program:

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

    SEROUT 16, 16780, [noparse][[/noparse]"Hello Worldy"]
    PAUSE 900
    END


    Now here is the VB2008 program to send and receive:

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    SerialPort1.Open()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    TextBox1.Text = SerialPort1.ReadExisting()
    End Sub

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

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    SerialPort1.WriteLine(TextBox1.Text)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If CheckBox1.Checked Then
    TextBox1.Text = SerialPort1.ReadExisting()
    End If
    End Sub
    End Class


    I realize some stuff in the vb2008 program is set in the programing windows of VB2008, like baud rate - just use all defaults -good luck!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    pan33.gif

    this is the way I pan one of my cameras from the internet - RS232 from security program
  • allanlane5allanlane5 Posts: 3,815
    edited 2009-12-01 18:26
    Note you must install the USB driver program BEFORE you plug in the USB port. Otherwise a 'default' windows USB driver will be used by Windows, which won't properly run the USB port for the board.
  • ChilesChiles Posts: 15
    edited 2009-12-01 18:41
    how would I know if I installed this usb driver? Will the parallax programming software run without it?
    thanks in advance, Chiles

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    pan33.gif

    this is the way I pan one of my cameras from the internet - RS232 from security program
Sign In or Register to comment.