VB Express Help Needed
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!
··· 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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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!
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.
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!