Firstly, I apologize for asking a question before trying this myself, but I did read/search the forums here and didn’t find a clear answer. Since “experimenting” with my very limited knowledge can be a) expensive, and b) frustrating, I hope you don’t mind my asking:
Is it possible to use the Maestro (I have the 6 servo variety) with a FEZ Domino?
The Domino has a USB Host port, and will recognize devices identifying themselves as “serial port profile” using certain chipsets (keep in mind I have limited knowledge of what that actually means.) And, looking at the way Maestro behaves when connected to my PC and the C# sample code, it appears it does indeed have the serial interface over USB implemented.
What do I need to be careful of when experimenting with this idea?
I don’t know. I don’t think anyone has tried it yet.
Where is the documentation for the FEZ library for USB/serial? You should find out if it supports composite devices like the Maestro (i.e. devices that have different interfaces inside them; the Maestro has two serial ports and one native USB interface).
If the FEZ library for USB/serial doesn’t support composite devices, then you probably can’t use it. Is there a more basic USB Host library you could use that lets you perform arbitrary USB control transfers on the device? That would be a great way to control the Maestro.
I don’t think there’s anything you particularly need to be careful of. The FEZ and the Maestro should not break if you’re just connecting them via USB.
Thanks, David. I check-in at the forum on tinyclr.com about the FEZ and they indicate composite USB devices should be no problem at all. In addition to serial support, there is indeed a lower-level integration point called USBH_RawDevice:
My guess is this isn’t trivial to implement, but I’m game. Is the Usc class in the SDK the place to start understanding how it should work?
If the people you asked are correct, and the USB host serial library on the FEZ Domino works for composite devices, then I think that might be easier than using USBH_RawDevice.
But using USBH_RawDevice would be cooler, and you are correct that you should look in the Usc class in the Pololu USB SDK to learn how to communicate with the Maestro. For example, if you looked in the setTarget function you’d learn that to set the target of a channel on the Maestro, you should initiate a control transfer with this data:
bmRequestType = 0x40
bRequest = 0x85 (REQUEST_SET_TARGET)
wValue = target value (in quarter microseconds)
wIndex = channel number (0-23)
wLength = 0 (no data phase)
So I recommend you figure out how to send a Set Target control transfer. Once you know how to do that, adding support for the other control transfers should be easy, assuming USBH_RawDevice is designed well.
Let us know how it goes! I’m sure there are others who would appreciate having your code.
I finally tried this out (needed to get a second USB cable to connect the Maestro to the FEZ Domino, as well as the FEZ to my PC for debugging). It works like a charm. The simple proof of concept code, with servos connected to channels 1 and 2 was:
public class Program
public static void Main()
USBH_RawDevice p = null;
USBHostController.DeviceConnectedEvent += (device) =>
p = new USBH_RawDevice(device);
// Blink board LED
bool ledState = false;
OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
ushort low = 8000, high = 1200;
// Sleep for 500 milliseconds
// toggle LED state
ledState = !ledState;
if (p != null)
p.SendSetupTransfer((byte)0x40, (byte)0x85, ledState ? high : low, (ushort)1);
p.SendSetupTransfer((byte)0x40, (byte)0x85, ledState ? low : high, (ushort)2);
I’m working on porting as much of the the Usc code as makes sense. That will mean (probably) none of the configuration and setting code, at least not as it sits, since it assumes a file system and/or uses generics (generics aren’t implemented in .Net Micro Framework). I’ll post it here once it’s ready and tested.
Thanks for helping this Newbie get started!
I’m glad you got it working. Thanks for the code you have posted so far. That’s cool that you are porting over code from the Usc class. The way I would do it is I would make a class called Maestro (or Usc) which is a subclass of USBH_Device (or contains a USBH_Device as a member), and has a few high-level methods like setTarget, setSpeed, setAcceleration, getPosition. Whatever you come up with will surely be useful to other people so feel free to post it here.