View Single Post
  #12   Spotlight this post!  
Unread 07-04-2007, 15:21
John Gutmann John Gutmann is offline
I'm right here
AKA: sparksandtabs
FRC #0340 (GRR)
Team Role: Mechanical
 
Join Date: Feb 2005
Rookie Year: 2004
Location: rochester
Posts: 804
John Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant futureJohn Gutmann has a brilliant future
Send a message via AIM to John Gutmann Send a message via MSN to John Gutmann Send a message via Yahoo to John Gutmann
Re: VB or any other GUI programmers

Hahaha Yea, well I though you don't know vB I will post the code here anyways, would you be willing to help me out if we can't get it to work in vB because I know you got the one program working before, or could you email me the program is you still have it? I can't seem to find it this way I can play with 3 servos for the time being.

Code:
Public Class Form1

    Dim i As Integer
    Dim Run As Boolean = False
    Dim Mode As String
    Dim Initialized As Boolean = False
    Dim value0 As Integer
    Dim value1 As Integer
    Dim value2 As Integer
    Dim value3 As Integer
    Dim value4 As Integer
    Dim value5 As Integer
    Dim value6 As Integer
    Dim value7 As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LED.Hide()
    End Sub

    Private Sub RunBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunBut.Click
        If Run = False Then
            COMPort.PortName = PortName.Text
            COMPort.Open()
            RunBut.Text = "Stop"
            Timer.Enabled = True
            Run = True
            Initialized = True
            Exit Sub
        End If

        If Run = True Then
            COMPort.Close()
            RunBut.Text = "Run"
            Timer.Enabled = False
            Run = False
            Initialized = False
        End If
    End Sub

    Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
        If Initialized = True Then
            If Mode = "Auto" Then
                'We are in auto-send mode so send Data
                'TO DO: Parse Data and send over COM Port
                SendPacket(0, value0)
                SendPacket(1, value1)
                SendPacket(2, value2)
                SendPacket(3, value3)
                SendPacket(4, value4)
                SendPacket(5, value5)
                SendPacket(6, value6)
                SendPacket(7, value7)
            End If
        End If
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        Mode = "Auto"
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        Mode = "Man"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Mode = "Man" Then
            If Initialized Then
                'We are in Manual send mode, send the data
                'TO DO: Parse data and send
                SendPacket(0, value0)
                SendPacket(1, value1)
                SendPacket(2, value2)
                SendPacket(3, value3)
                SendPacket(4, value4)
                SendPacket(5, value5)
                SendPacket(6, value6)
                SendPacket(7, value7)
            End If
        End If
    End Sub

    Private Sub Serv1bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv1bar.Scroll
        Serv1box.Text = Serv1bar.Value
        value0 = Serv1bar.Value
    End Sub

    Private Sub Serv2bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv2bar.Scroll
        Serv2box.Text = Serv2bar.Value
        value1 = Serv2bar.Value
    End Sub

    Private Sub Serv3bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv3bar.Scroll
        Serv3box.Text = Serv3bar.Value
        value2 = Serv3bar.Value
    End Sub

    Private Sub Serv4bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv4bar.Scroll
        Serv4box.Text = Serv4bar.Value
        value3 = Serv4bar.Value
    End Sub

    Private Sub Serv5bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv5bar.Scroll
        Serv5box.Text = Serv5bar.Value
        value4 = Serv5bar.Value
    End Sub
    Private Sub Serv6bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv6bar.Scroll
        Serv6box.Text = Serv6bar.Value
        value5 = Serv6bar.Value
    End Sub
    Private Sub Serv7bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv7bar.Scroll
        Serv7box.Text = Serv7bar.Value
        value6 = Serv7bar.Value
    End Sub
    Private Sub Serv8bar_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv8bar.Scroll
        Serv8box.Text = Serv8bar.Value
        value7 = Serv8bar.Value
    End Sub

    Private Sub Serv1box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv1box.TextChanged
        Serv1bar.Value = Serv1box.Text
        value0 = Serv1box.Text
    End Sub
    Private Sub Serv2box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv2box.TextChanged
        Serv2bar.Value = Serv2box.Text
        value1 = Serv2box.Text
    End Sub
    Private Sub Serv3box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv3box.TextChanged
        Serv3bar.Value = Serv3box.Text
        value2 = Serv3box.Text
    End Sub
    Private Sub Serv4box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv4box.TextChanged
        Serv4bar.Value = Serv4box.Text
        value3 = Serv4box.Text
    End Sub
    Private Sub Serv5box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv5box.TextChanged
        Serv5bar.Value = Serv5box.Text
        value4 = Serv5box.Text
    End Sub
    Private Sub Serv6box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv6box.TextChanged
        Serv6bar.Value = Serv6box.Text
        value5 = Serv6box.Text
    End Sub
    Private Sub Serv7box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv7box.TextChanged
        Serv7bar.Value = Serv7box.Text
        value6 = Serv7box.Text
    End Sub
    Private Sub Serv8box_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Serv8box.TextChanged
        Serv8bar.Value = Serv8box.Text
        value7 = Serv8box.Text
    End Sub
    Private Sub SendPacket(ByVal servo As Integer, ByVal value As Integer)
        COMPort.Write(255)
        COMPort.Write(servo)
        COMPort.Write(value)
        For i = 1 To 300
            LED.Show()
        Next
        LED.Hide()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        COMPort.Write(255)
        COMPort.Write(0)
        COMPort.Write(127)
    End Sub
End Class
The main problem we are having is that my servo controller isn't receiving correct data. I am unsure fi that is how you send one byte in vB but it doesn't seem to be working. The transmission error light on the controller flashes after every transmission indicating an error.

thanks,
John