Toolbox.NETMF.Hardware.MicroSerialServoController


Toolbox.NETMF.Hardware.MicroSerialServoController(Port, Mode)
  • Port The COM-port the controller is connected to
  • Mode The mode we should communicate in (when jumper is placed: MiniSSC2, otherwise: Pololu)

Supported methods

  • SetParameters(MotorId, On, Reversed, Range) Sets specific parameters for a servo (Pololu-mode only)
  • SetSpeed(MotorId, Speed) Sets the speed at which the servo moves (Pololu-mode only)
  • SetPosition(MotorId, Position) Changes the position of a motor (works in both modes)
  • SendCommand(Command, MotorId, Data1) Sends a customized command (Pololu-mode only, see manual for commands)
  • SendCommand(Command, MotorId, Data1, Data2) Sends a customized command (Pololu-mode only, see manual for commands)
  • Dispose() Closes the connection and releases the serial port

How to connect

Toolbox.NETMF.Hardware.MicroSerialServoController.png

Sample code in C#

MicroSerialServoController Servos = new MicroSerialServoController("COM1", MicroSerialServoController.Modes.Pololu);

// (Re)sets the speed of the first two servos to 0, see the pololu-manual for details about this
Servos.SetSpeed(0, 0);
Servos.SetSpeed(1, 0);

// Wait for 4 seconds
Thread.Sleep(4000);

while (true)
{
    // Set the position of the first two servos
    Servos.SetPosition(0, 0);
    Servos.SetPosition(1, 254);

    // Wait for 2 seconds
    Thread.Sleep(2000);

    // Set the position of the first two servos again to something else
    Servos.SetPosition(0, 254);
    Servos.SetPosition(1, 0);

    // Wait for 2 seconds
    Thread.Sleep(2000);
}

Sample code in VB

Dim Servos As MicroSerialServoController = New MicroSerialServoController("COM1", MicroSerialServoController.Modes.Pololu)

' (Re)sets the speed of the first two servos to 0, see the pololu-manual for details about this
Servos.SetSpeed(0, 0)
Servos.SetSpeed(1, 0)

' Wait for 4 seconds
Thread.Sleep(4000)

Do
    ' Set the position of the first two servos
    Servos.SetPosition(0, 0)
    Servos.SetPosition(1, 254)

    ' Wait for 2 seconds
    Thread.Sleep(2000)

    ' Set the position of the first two servos again to something else
    Servos.SetPosition(0, 254)
    Servos.SetPosition(1, 0)

    ' Wait for 2 seconds
    Thread.Sleep(2000)
Loop

Related documents

Last edited Jan 1, 2013 at 9:14 PM by Garrcomm, version 2