How to set channel mode for Maestro?

I want to set a channel as an output with the micro Maestro. What would the c# main program look like to do this? I can’t seem to find routine in Usc to do this.

Thanks
Cliff1

Hello, Cliff1.

The function you are looking for is setUscSettings in Usc.cs. To change the channel mode on the Maestro using the Pololu USB SDK, you would need to create a UscSetting object, which is defined in UscSettings.cs, and then apply it to the Maestro using that function. Please note that the function converts the UscSettings object into a series of setRawParameter calls and each Set Raw Parameter request tells the Maestro to modify part of its EEPROM, which is only rated for 100,000 write cycles, so be careful to not call Set Raw Parameter thousands of times in a loop. It is fine if you write the same value every time because the Maestro is smart enough to do nothing if the EEPROM already has the correct value.

Alternatively, you might consider just configuring the channel to be an output ahead of time using the Maestro Control Center software.

If you have trouble writing the code, you can post what you have here, and I would be happy to take a look.

- Amanda

Hello AmandaS:
Thank you for your reply to my question about changing a channel from SERVO to OUTPUT type on the mini maestro:

Would you do it this way?

  1. call usc.getUscSettings() , creating the structure with the current configuration,
  2. then modify the one byte , PARAMETER_CHANNEL_MODES_0_3 ,
  3. then call usc.setUscSettings().

Is this correct?

Cliff

No, I see that I was mistaken. Will this work to change channel 1 to output?

        UscSettings S = getUscSettings();
        S.channelSettings[1].mode = ChannelMode.Output;
        setUscSettings(S, false);

Thanks Again,
Cliff

Hello, Cliff.

If you are not writing that code inside the Usc class, you will need to have a Usc object somewhere that you can access, and call the getUscSettings and setUscSettings methods on that object using the syntax you suggested in your first post (e.g. usc.getUscSettings()). That kind of issue should be caught at compile time, so if that code compiles then it should work.

–David