This project has moved and is read-only. For the latest updates, please go here.

Using StartMotorAsync, StopMotorAsync, and SetMotorPolarity

Mar 28, 2014 at 10:32 PM
I have been working with the StartMotorAsync, StopMotorAsync, and SetMotorPolarity Direct Commands, and have notice several patterns that I am trying to figure out the reason for. First, if I call SetMotorPolarity right after connecting, the motor rotates that direction, just as if I had called StartMotorAsync. However, once I call StopMotorAsync calling SetMotorPolarity does not start the motor (although it does still set the polarity). If I then call StartMotorAsync, it starts the motor, and if I call SetMotorPolarity after calling StartMotorAsync it changes the polarity so that it turns the other direction (or does nothing if the motor is already turning that direction). Basically, if I call SetMotorPolarity right after connecting (when the motor is stopped) or while the motor is turning (after calling StartMotorAsync), it starts the motor turning in that direction. But if I call SetMotorPolarity after calling StopMotorAsync (while the motor is stopped) it does not start the motor turning. Why does SetMotorPolarity in some scenarios start and/or change the polarity of the motor, but in others just changes the polarity? Should I always call StopMotorAsync right after connecting even if I haven't done anything yet? Thanks.
Mar 28, 2014 at 10:55 PM
I have also noticed that, for reasons or in patterns I have not yet determined, when started using either SetMotorPolarity or StartMotorAsync, the motor sometimes stops for no apparent reason, and sometimes refuses to start again using a simple call to StartMotorAsync. What is the reason for this inconsistency? Thanks.
Mar 28, 2014 at 11:19 PM
Does SetMotorPolarity change the direction for all Direct Commands, or only for StartMotorAsync? I am asking this because I use calls to both StartMotorAsync and StepMotorAtPowerAsync in my code, and I need to know whether I need to keep track of what the current polarity is. Which brings up another question: Is there a property or other way to determine the current polarity? Thanks.
May 25, 2014 at 1:38 AM
very simple solution. I had same problem.

make sure bool brake - value is true not false.
May 26, 2014 at 6:28 AM
I have nothing more than coiledwire just added. The SetMotorPolairty command is sent to the brick as the brick expects it. I also see the brick start moving when calling this command. At that point, it's the brick starting the motor, not this API. Polarity is set on the output port and is valid on all commands until the polarity is set again. There is no way to read the current polarity of the output port that's in this API (or readable from the brick that I can see from the docs)...