Author Topic: using VB to control a sabertooth motor driver  (Read 2154 times)

0 Members and 1 Guest are viewing this topic.

Offline digital_pantsTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
using VB to control a sabertooth motor driver
« on: July 10, 2010, 03:36:14 AM »
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 Sad

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(Cool = 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 Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: using VB to control a sabertooth motor driver
« Reply #1 on: July 12, 2010, 10:19:10 AM »
To debug your problem, do a loop back test.

On your TLL device, short the Rx and Tx together.

Then send out data, and see if what you receive is what you expected to receive.

 


Get Your Ad Here

data_list