Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: SSC-32 communication

  1. SSC-32 communication

    I have a usb/serial adaptor that emulates a serial port with a usb port. I have connected this to my SSC-32 controller and I am trying to feed an ascii command to it using WinCC scripts. If no one knows how to do that, does anyone know how to send an ascii command using visual basic?

    The connection is COM 4 and I want to send the ascii command #1 P750 just as a test.

  2. #2
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    177

    Re: SSC-32 communication

    You don't mention baud rate...


    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;
     
    namespace ConsoleCenterServo
    {
        class Program
        {
     
            static void Main(string[] args)
            {
                System.IO.Ports.SerialPort serialPort = new System.IO.Ports.SerialPort();
     
                // Close the serial port if it is already open
                if (serialPort.IsOpen)
                {
                    serialPort.Close();
                }
                try
                {
                    // Configure our serial port *** You'll likely need to change these for your config! ***
                    serialPort.PortName = "COM4";
                    serialPort.BaudRate = 38400;
                    serialPort.Parity = System.IO.Ports.Parity.None;
                    serialPort.DataBits = 8;
                    serialPort.StopBits = System.IO.Ports.StopBits.One;
     
                    //Now open the serial port
                    serialPort.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Couldn't open the Serial Port!");
                    Console.WriteLine(ex.ToString());//Report the actual error
                }
                try
                {
                    //Now we'll send some data. Specifically we want to send "#Channel Number P1500<cr>" to center the servo
                    serialPort.Write("#1 P750\r");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Couldn't send the command for some reason... I give up. Sorry!");
                    Console.WriteLine(ex.ToString()); //Report the actual error
                }
    
                //Report our apparent success
                Console.WriteLine("Go little servo, Go!" + Environment.NewLine);
                Console.WriteLine("Sent: #1 P750<cr>" + Environment.NewLine);
     
                //Now let's close our serial port.
                try
                {
                    serialPort.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Couldn't close the darned serial port. Here's what it said: " + Environment.NewLine);
                    Console.WriteLine(ex.ToString());
                }
                //Wait for [Enter] before we close
                Console.ReadLine();
     
            }
        }
    }

    Now - I'm not a VB programmer, so I doubt this'll work the first time, but if you write VB it should get you easily on the right track. If not, go learn VB, and then this will get you on the right track. This should be trivial to debug. I read a VB app once or twice... years ago. Should be pretty close. It's kinda like swimmin' laps in a kiddie-pool .

    Code:
    Imports System
    Imports System.Collections.Generic
    Imports System.Text
    Imports System.IO
    
    Module Module1
        Sub Main()
            If serialPort.IsOpen Then
                serialPort.Close()
            End If
            
            Try 
            With serialPort
                .PortName = "COM4"
                .BaudRate = 38400
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                
            End With
            
            '--- Now open the port
            serialPort.Open()
            
            Catch ex As Exception
                MsgBox(ex.ToString)  '--- Do a little error handling
            End Try
        
            Try
                '--- Write the data
                serialPort.Write("#1 P750" & vbCr) '--- data + <CR> as required
            Catch ex As Exception
                MsgBox(ex.ToString)  '--- Do a little error handling
            End Try
            
            Try '--- Close the serial port and clean up
                serialPort.Close()
            Catch ex As Exception
                MsgBox(ex.ToString)  '--- Do a little error handling
            End Try
            Console.ReadLine()  '--- Don't let the console close before we tag a key
        End Sub            
    End Module
    Last edited by Adrenalynn; 07-11-2009 at 05:09 PM.
    I Void Warranties�

  3. Question Serial Port Communication to the SSC-32 using VBScript

    I am trying to communicate to my SSC-32 using VBScript. I tried using a function mentioned in another thread but I cannot get it to work. I am trying to get VBScript to tell a motor to move #2 P750. First I tried this:

    Sub ssc32test()
    Set MSComm1=CreateObject("MSCOMMLib.MSComm")
    MSComm1.Settings = "115200,n,8,4"
    MSComm1.CommPort = 4
    MSComm1.InBufferCount = 0
    MSComm1.PortOpen = True
    If Err Then
    MsgBox "COM" & MSComm1.CommPort & ": not opened, Sorry!"
    Exit Sub
    End If
    MSComm1.Output="#2 P750" & CHR(13)
    WScript.Sleep(1000)
    MSComm1.PortOpen = False
    Set MSComm1 = Nothing
    End Sub

    But it gave me errors for MSComm1 saying that it was undefined so I added this in the Sub:

    Dim MSComm1

    Then it gave me errors saying that WScript wasnt valid so I deleted that line. After deleting several other things to get it to work without errors I wound up with this:

    Dim MSComm1
    Set MSComm1=CreateObject("MSCOMMLib.MSComm")
    MSComm1.Settings = "115200,n,8,4"
    MSComm1.CommPort = 4
    MSComm1.InBufferCount = 0
    MSComm1.PortOpen = True
    MSComm1.Output="#2 P750" & CHR(13)

    However, when I test this, the motor doesnt move at all. #2 P750 definitely is the desired command because I tested it on the Lynmotion ssc32 program. Does anyone have any ideas?

  4. #4
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    177

    Re: SSC-32 communication

    Please don't start new threads for the same question. I've merged it into here.
    I Void Warranties�

  5. Re: SSC-32 communication

    Sorry. Do you have any ideas?

  6. #6
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    177

    Re: SSC-32 communication

    >> After deleting several other things to get it to work without errors I wound up with this:

    In programming, "deleting stuff that doesn't compile" doesn't mean "it's now working". My suggestion would be to learn vbscript if you want to learn vbscript.
    Last edited by Adrenalynn; 07-12-2009 at 08:11 PM.
    I Void Warranties�

  7. #7

    Re: SSC-32 communication

    Consider downloading one of the .NET express editors and using the SerialPort object of the System.IO.Ports namespace. MSCOMM is a legacy API and has always been a bit buggy.
    Last edited by MikeG; 07-12-2009 at 03:50 PM.

  8. #8
    Join Date
    May 2008
    Location
    TN
    Posts
    853
    Images
    99
    Rep Power
    74

    Re: SSC-32 communication

    Have you considered python? There are quit a few people around here (myself included) that use python over a serial port to great success. As a matter of fact I have code for an SSC32 in python.

    The other option is using C# in .net. Adrenalynn wrote a great tutorial on how to get that working.

    In general most people that work on "real" robots and computers shy away from any flavor of basic.

    You also need to understand that for any programming language you probably need to start at "Hello World". You are begging for trouble if you grab someone else's code and modify it and you don't understand how it works.
    Last edited by jes1510; 07-12-2009 at 06:52 PM.
    "If A is a success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut."
    -
    Einstein

    Don't be a HelpVampire

  9. #9
    Join Date
    Apr 2008
    Location
    Sacramento, CA, USA Area
    Posts
    5,341
    Rep Power
    177

    Re: SSC-32 communication

    Quote Originally Posted by MikeG View Post
    Consider downloading one of the .NET express editors and using the SerialPort object of the System.IO.Ports namespace. MSCOMM is a legacy API and has always been a bit buggy.
    I actually tried the VB I posted in the first response - believe it or not it actually worked with a couple typo fixes...
    I Void Warranties�

  10. #10
    Join Date
    Sep 2006
    Location
    Carol Stream, Illinois
    Posts
    1,695
    Images
    118
    Rep Power
    109

    Re: SSC-32 communication

    I'll second (or is it third) what Adrenalynn and MikeG are saying, go with .NET if you're going to use Visual Basic. I'd stay FAR away from Visual Basic 6 or VBScript ( BTW, (VBScript | VBA) != Visual Basic 6 although all the syntax is nearly identical). I'm with Adrenalynn, you can't pay me enough to program in Visual Basic 6. It's a very clunky language.

    Visual Basic 2008 Express Edition can be downloaded for free and has a ton of excellent tutorials:

    http://www.microsoft.com/express/vb/Default.aspx

    �In the long history of humankind (and animal kind, too) those who learned to collaborate and improvise most effectively have prevailed�
    - Charles Darwin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question(s) Axon to SSC 32
    By WGhost9 in forum Robot Computers
    Replies: 8
    Last Post: 06-25-2009, 08:52 PM
  2. Question(s) RoboRealm and Axon serial communication issues
    By Resilient in forum Software and Programming
    Replies: 2
    Last Post: 05-15-2009, 04:06 AM
  3. Problem with ZIG100 communication
    By Hthien in forum Sensors
    Replies: 2
    Last Post: 02-22-2009, 08:31 PM
  4. C++ Serial Communication
    By Resilient in forum Software and Programming
    Replies: 14
    Last Post: 02-03-2009, 03:23 PM
  5. Kyosho 32 Port Sensor Board for RCB3
    By Droid Works in forum Arbotix, Microcontrollers, Arduino
    Replies: 4
    Last Post: 05-02-2008, 08:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •