Author Topic: sabertooth motor driver Simplified Serial programming in VB  (Read 1546 times)

0 Members and 1 Guest are viewing this topic.

Offline digital_pantsTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
hello i seem to have run into a problem. i have bought a sabertooth 2X5 motor driver and i intened to control it using simplified serial in visual basic beacuse it is the language i know the best. i am using a usb to TTL converter to interface the driver with my computer and i have set the dip switches to the correct positions. in VB i have opened the com port for the converter and set the settings for the port. i write the character 127 for full forward and i dont get the desired result........... can anyone help me.

if what i am attempting in my code is completly wrong forgive me, im new :(

to help understand what i am talking about heres some of my code.
Option Explicit On
Imports System.IO.Ports


Public Class Form1

    Dim myComPort As New SerialPort

 
    Private Sub btnOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOn.Click
        Dim gogo As Char = "127"
        myComPort.Write(gogo)
    End Sub


  Sub InitializeForm()

        Dim bitRates(9) As Integer
        Dim nameArray() As String

        ' Find the COM ports on the system.

        nameArray = SerialPort.GetPortNames
        Array.Sort(nameArray)

        ' Fill a combo box with the port names.

        cmbPorts.DataSource = nameArray
        cmbPorts.DropDownStyle = ComboBoxStyle.DropDownList

        ' Select a default port.

        cmbPorts.SelectedIndex = 1

        'Bit rates to select from.

        bitRates(0) = 300
        bitRates(1) = 600
        bitRates(2) = 1200
        bitRates(3) = 2400
        bitRates(4) = 9600
        bitRates(5) = 14400
        bitRates(6) = 19200
        bitRates(7) = 38400
        bitRates(8) = 57600
        bitRates(9) = 115200

        'Place the bit rates in a combo box.

        cmbBitRate.DataSource = bitRates
        cmbBitRate.DropDownStyle = ComboBoxStyle.DropDownList

        ' Select a default bit rate.

        cmbBitRate.SelectedItem = 9600

    End Sub

 
    Sub OpenComPort()

        Try


            If Not ComPort.IsOpen Then
                ComPort.PortName = cmbPorts.SelectedItem.ToString

                ' Get the selected bit rate from the combo box.

                If cmbBitRate.SelectedIndex > 0 Then
                    ComPort.BaudRate = CInt(cmbBitRate.SelectedItem)
                End If

                ' Set other port parameters.
                ComPort.RtsEnable = True
                ComPort.DtrEnable = True
                ComPort.Parity = Parity.None
                ComPort.DataBits = 8
                ComPort.StopBits = StopBits.One
                ComPort.Handshake = Handshake.None
                ComPort.ReadTimeout = 3000
                ComPort.WriteTimeout = 5000

                ' Open the port.

                ComPort.Open()

            End If

        Catch ex As InvalidOperationException
            MessageBox.Show(ex.Message)

        Catch ex As UnauthorizedAccessException
            MessageBox.Show(ex.Message)

        Catch ex As System.IO.IOException
            MessageBox.Show(ex.Message)

        End Try
    End Sub

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: sabertooth motor driver Simplified Serial programming in VB
« Reply #1 on: July 05, 2010, 12:21:06 PM »
Hi,

This post belongs in Software, NOT Electronics.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline digital_pantsTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: sabertooth motor driver Simplified Serial programming in VB
« Reply #2 on: July 05, 2010, 01:36:04 PM »
my bad. anyway any ideas on my problem.

 


Get Your Ad Here