C# to C++ in SMC 18v7


I have recently purchased the SMC 18v7 along with a motor and battery. The motor runs fine when I connected it with USB to my PC and I am able to control its speed via the graphical user interface.

I have also chanced upon that there are 2 programming examples (SmcExample1 and SmcExample2) in the SDK that I have downloaded. I understand that these two examples are in C#, so, I would like to ask if and how is it possible to convert (in any way) to a C++ language in Linux?

The reason why I want to change it to C++ is because I want to use the C++ code as my subprogram in a project that I am doing, which can only be used in C++.


Hello, Addy.

For Linux, you might consider using libusb to send appropriate commands to your Simple Motor Controller (SMC). You can read the code in the Pololu USB SDK as a guide to help you understand the USB protocol of the Simple Motor Controller, and then implement the same thing in C++ with libusb.

- Amanda

Hi Amanda

From the Pololu SDK, I’ve ran the SmcExample2 successfully. However, can I just check with you, in the mainwindow.cs file:

void SetSpeed() { if (device != null) { try { Int16 scrolledSpeed = ComputeScrolledSpeed(); // speed is from -3200 to 3200 <font color="#40FF00"> device.setSpeed(scrolledSpeed);</font> } catch (Exception exception) { DisplayException(exception); } } }

May I know where is the function “device”? I could not find it in all the files/directories in the SDK.


Hi, Addy.

The Smc class object device is defined in MainWindow.cs (line 157):

Smc device = null;

If you want to know what methods you can call on device, the Smc class is defined in Smc.cs.

- Amanda