Mini SSC II Visual Basic.NET Control Problems
I recently bought a Mini SSC II to control some Futaba S3003 servos, and I had the intent on using Visual Basic.NET to control the board but it has so far eluded me. I used a tutorial that was ment for Visual Basic 5 or 6 to make the program as·I am new to Visual Basic. Below is the code, and im using the 7 & 8 spots on the SSC and·I know the COM port is 1. Also,·I know everything is connected right because·I tried the finished program from the tutorial and it works, but the program that I made will not.·This is the tutorial·I used to make the program -> http://www.rentron.com/Mini-ssc.htm
[color=#0000ff]Public[/color] [color=#0000ff]Class[/color][color=#000000] Form1[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Form1_Load([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] [color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] [color=#0000ff]Me[/color].Load MsComm1.BaudRate = 9600 MsComm1.Parity = IO.Ports.Parity.None MsComm1.StopBits = IO.Ports.StopBits.One MsComm1.DataBits = 8 MsComm1.PortName = [color=#800000]"COM1"[/color] MsComm1.Open() [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Com19600N81ToolStripMenuItem_Click([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] [color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] Com19600N81ToolStripMenuItem.Click [color=#0000ff]Dim[/color] moRS232 [color=#0000ff]As[/color] [color=#0000ff]New[/color] ComClassAttribute() [color=#0000ff]If[/color] MsComm1.IsOpen [color=#0000ff]Then[/color] MsComm1.Close() [color=#0000ff]End[/color] [color=#0000ff]If[/color] MsComm1.BaudRate = 9600 MsComm1.StopBits = IO.Ports.StopBits.One MsComm1.Parity = IO.Ports.Parity.None MsComm1.DataBits = 8 MsComm1.PortName = [color=#800000]"COM1"[/color] MsComm1.Open() [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Com29600N81ToolStripMenuItem_Click([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] [color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] Com29600N81ToolStripMenuItem.Click [color=#0000ff]Dim[/color] moRS232 [color=#0000ff]As[/color] [color=#0000ff]New[/color] ComClassAttribute() [color=#0000ff]If[/color] MsComm1.IsOpen() [color=#0000ff]Then[/color] MsComm1.Close() [color=#0000ff]End[/color] [color=#0000ff]If[/color] MsComm1.BaudRate = 9600 MsComm1.Parity = IO.Ports.Parity.None MsComm1.StopBits = IO.Ports.StopBits.One MsComm1.DataBits = 8 MsComm1.PortName = [color=#800000]"COM2"[/color] MsComm1.Open() [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] VScroll1_ValueChanged([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] [color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] VScroll1.ValueChanged TextBox1.Text = Str(VScroll1.Value) MsComm1.Write(Chr(255)) MsComm1.Write(Chr(6)) MsComm1.Write(Chr(TextBox1.Text)) [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] VScroll1_Scroll() TextBox1.Text = VScroll1.Value.ToString() [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] VScroll2_ValueChanged([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] [color=#0000ff]Object[/color], [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] VScroll2.ValueChanged TextBox2.Text = Str(VScroll2.Value) MsComm1.Write(Chr(255)) MsComm1.Write(Chr(7)) MsComm1.Write(Chr(TextBox1.Text)) [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] VScrollBar2_Scroll() TextBox2.Text = VScroll2.Value.ToString() [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] cmdCenter1_Click() MsComm1.Write(Chr(255)) MsComm1.Write(Chr(6)) MsComm1.Write(Chr(127)) TextBox1.Text = Str(127) VScroll1.Value = TextBox1.Text [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] cmdCenter2_Click() MsComm1.Write(Chr(255)) MsComm1.Write(Chr(7)) MsComm1.Write(Chr(127)) TextBox2.Text = Str(127) VScroll2.Value = TextBox2.Text [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] cmdExit_Click() MsComm1.Close() [color=#0000ff]End[/color] [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] [color=#0000ff]Private[/color] [color=#0000ff]Sub[/color] Button1_Click([color=#0000ff]ByVal[/color] sender [color=#0000ff]As[/color] System.Object, [color=#0000ff]ByVal[/color] e [color=#0000ff]As[/color] System.EventArgs) [color=#0000ff]Handles[/color] Button1.Click MsComm1.Write(255) MsComm1.Write(6) MsComm1.Write(127) [color=#0000ff]End[/color] [color=#0000ff]Sub[/color] End [color=#0000ff]Class[/color]
Comments
the tutorial your using is for vb5 or 6, what version of .net are you using? 2005 makes it simple to run the serial stuff. the following is from 2005, will not work in 2003
start off by putting the following in the main declaration
Dim WithEvents serialPort As New IO.Ports.SerialPort
you'll then make a button for connect, and put this code in it
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()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
you will probably need to modifty the .stopbits and .databits and such to agree with your board
to send something to the board you'll use
serialPort.Write("111")
make sure you close the serial port before you exit the program, else funky things happen. use the code
serialPort.Close()
once i have my app put together right i should have a nice simple file you can work from. give me a pm in a week or so if you still want it.
~Rob