7. Writing PC Software to Control the Simple Motor Controller

There are two ways to write PC software to control a Simple Motor Controller: the native USB interface and the virtual serial port. The native USB interface provides more features than the serial port, such as the ability to change configuration parameters and select the Simple Motor Controller by its serial number. Also, the USB interface allows you to recover more easily from temporary disconnections. The virtual serial port interface is easier to use if you are not familiar with programming, and it can work with existing software programs that use serial ports, such as LabView.

The Pololu USB SDK contains example code for the Simple Motor Controller in C#, Visual C++, and Visual Basic .NET.

Native USB Interface

The Pololu USB Software Development Kit supports Windows and Linux, and includes the source code for:

  • SmcExample1: a simple example application that uses native USB and has three buttons for setting the motor speed. Versions of this example are available in C#, Visual Basic .NET, and Visual C++.
  • SmcExample2: an example graphical application that has a scrollbar for setting the motor speed over native USB (written in C#).
  • SmcCmd: a command-line utility for configuring and controlling the Simple Motor Controller (written in C#).
  • Smc: A .NET class library that enables native USB communication with the Simple Motor Controller (written in C#).

You can modify the applications in the SDK to suit your needs or you can use the class library to integrate the Simple Motor Controller in to your own applications.

Virtual Serial Port

Almost any programming language is capable of accessing the Simple Motor Controller’s virtual COM port. We recommend the Microsoft .NET framework, which is free to use and contains a SerialPort class that makes it easy to read and write bytes from a serial port. You can download Visual Studio Express (for either C#, C++, or Visual Basic) and write programs that use the SerialPort class to communicate with the Simple Motor Controller. You will need to set the Simple Motor Controller’s serial mode to be either “Binary” or “ASCII” depending on which command set you want to use. See Section 6.7 for example code that uses the virtual COM port.