Shop OBEX P1 Docs P2 Docs Learn Events
VB Express Help Needed — Parallax Forums

VB Express Help Needed

kenwtnkenwtn Posts: 250
edited 2008-06-28 19:36 in BASIC Stamp
Hi All,

··· I m trying to send commands to the homework board using Visual Basic Express. This is a example of code that works.


SerialPort1.Write("++^++")

SerialPort1.Write(Cmd)

··· But if I try to send a second Variable I can't get it to work. Examples of what I tried.

SerialPort1.Write("++^++")

SerialPort1.Write(Cmd)

SerialPort1.Write(Parm2)



And tried

SerialPort1.Write("++^++")

SerialPort1.Write(Cmd)

SerialPort1.Write(" ")

SerialPort1.Write(Parm2)

··· If anyone has done this please help me out.

Thanks in advance



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Keep buying replacement parts and sooner or later you will get it RIGHT!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-06-28 02:16
    Attach your code you are using on the stamp to receive this and what it is you get instead of what you were expecting.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • kenwtnkenwtn Posts: 250
    edited 2008-06-28 11:46
    Ok here is the last code I tried.

    VB Code

    Dim vel As Int16

    Dim x As Integer

    Dim Cmd As Int16

    Cmd = 2

    vel = PanRL.Value

    For x = 1 To 10

    SerialPort1.Write("++^++")

    SerialPort1.Write(Str(Cmd))

    SerialPort1.Write(" ")

    SerialPort1.Write(Str(vel))

    Next



    And Attached is the Basic Stamp Code. I know the CMD is being passed since it transmits it to my robot and the robot see that. I can't tell what the Stamp is seeing in the Variable CmdParm since I am using the serial port to send the commands and cannot use DEBUG.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Keep buying replacement parts and sooner or later you will get it RIGHT!
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-06-28 15:45
    Hi kenwtn, you could try the following write command at the VB end

    SerialPort1.ReadExisting()

    SerialPort1.WriteLine("++^++" & VbCr & Cmd & VbCr & Param2)

    and at the Stamp

    SERIN 16,16780, [noparse][[/noparse]WAIT("++^++"), DEC3 Command ,DEC3 CmdParm]

    A couple of things about this, you will need to reduce the baud rate for the WAIT formatter.

    Using WriteLine with the carriage returns in the VB code will separate the transmitted data, so basically you are placing·each data within a bracket

    Using DEC3 the Stamp will wait for three digits or a carriage return (whichever comes first ) before reading the next paramater.

    As is the VB data will have to be a figure between 0 and 255

    There should be no need for a DO-LOOP in either code

    Did you check this link out yet······ http://forums.parallax.com/showthread.php?p=671804

    Jeff T.
  • kenwtnkenwtn Posts: 250
    edited 2008-06-28 19:36
    Jeff,
    Thanks that did the trick. Thanks so much for the help.

    Ken

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Keep buying replacement parts and sooner or later you will get it RIGHT!
Sign In or Register to comment.