Reading sensor input from Maestro with c#

I’m wondering how to write a C# app that can read analog sensor input from maestro ports and write data to a text file?
Thanks guys


The easiest way for you would probably be to run “UscCmd --status”, parse the output from UscCmd, and save it to a file.

UscCmd is written in C# and it uses the native USB interface of the Maestro. The source code is available in the Pololu USB SDK, so alternatively you could modify UscCmd to do what you want.

Another option is to set the Maestro’s Serial Mode to “USB Dual Port” and use the .NET SerialPort class to send “Get Position” commands to the Maestro. This might be harder because you will have to learn how to send and arbitrary bytes (binary data) on a serial port, and you will have to read and understand the parts of the Maestro user’s guide that describe the serial protocol.

For more information, please read the section entitled “Writing PC Software to Control the Maestro” in the Maestro user’s guide:


How would I go about setting it to USB Dual Mode?

It’s an option in the Maestro Control Center. Installation instructions are here:

Be sure to click “Apply Settings to Device” after changing the setting.


another question: I modified the usccmd file and ran debug but it didn’t change/update the .exe in the bin? running usccmd --status in command prompt after changing the file doesnt exhibit the behavior I indicated it to (i.e. i told it to print something to the console, but it did not print).

Also, I saw the diagram on attaching potentiometers on port 0, but how would I go about attaching multiple pots on the same maestro? and how do i attach an additional power supply if i want to support multiple sensors?

You can tell if a file has been changed/updated by looking at its modification time. Make sure that you are running the usccmd.exe produced by Visual Studio and NOT running the one that was installed on your path by the installer for the Maestro Windows software and drivers.

I think you are referring to this diagram for connecting a potentiometer to a Maestro:

All of the channels on the Micro Maestro 6 work the same way, and are capable of analog input, so the instructions for connecting a potentiometer to them would be the same. Please read the words in the user’s guide to the left of that diagram. These words are general: they apply to any port on the Micro Maestro, and they can be found here:

You should be aware that there are multiple places where you can access GND on the Maestro, so please see this diagram which is from the Micro Maestro Pinout and Components section of the user’s guide:

To connect an additional power supply, first make sure that all the grounds in your system are connected. Then connect the positive power output from your power supply to the appropriate power inputs on the devices you want to power. You can run the power through the Maestro’s servo power rail (VSRV) if that makes it easier for you. (You haven’t told me enough about your system to convince me that you actually need an additional power supply so I don’t know if this is a good idea.)


I"m plugging in 6 sonar sensors to a 6 channel maesetro. Since they have an sonar ping output, would an external power supply be necessary then? This is the product I’m using

The datasheet of the product you linked to says “2.5V to 5.5V supply with 2mA typical current draw”. Since the Maestro’s regulator produces 5V and can provide up to 20 mA (and more if the Maestro is powered from USB with VIN disconnected), you should be able to power several of these sensors from the Maestro’s 5V line.

The need for an external power supply is determined by the current and voltage requirements of the devices you are powering, not the details of their data interfaces.

Thank you for providing a link to the product you are using, it really helps me figure out whether your project is going to work. I think it will. The Maestro can measure voltages but not PWM signals, so you should use the 10mV/inch analog output that the sensor provides.


Thanks so much!