Kexyn

Ok, I feel rather silly asking this question, but is there a guaranteed way to rotate a lego motor a certain amount of degrees I've tried spinning the motor for a certain fraction of a second, and using encoder readings. After the appropriate amount of time or ticks, I do

Code Snippet

_grabMotor.SetMotorPower(0.0);


But it seems like half the time that command is ignored completely, because the motor doesn't stop. I thought that maybe it was just drifting, but it actually keeps spinning. It's as if this line is being ignored, but I've debugged and made sure that the program is actually getting there, and it is.

My real question is, how can I guarantee that a lego motor stops I don't want it to drift. I looked around LegoNXTDrive.cs and found the following

Code Snippet

lego.LegoSetOutputState motors = new lego.LegoSetOutputState();
motors.Mode = lego.LegoOutputMode.Brake;


But I'm not sure what that does, or how to implement it. I've seen this question asked in this forum before, here and here, but i already have an encoder, and i already send a stop command that apparently doesn't work. I'm stumped! Any ideas


Re: Microsoft Robotics - Hardware Configuration and Troubleshooting Dumb Question (Braking Lego Motors)

Dave Lee

You might try the LegoSetOutputState command on the LEGO Brick service. This allows you to call the underlying LEGO motor API which allows you to brake or coast after a specified number of motor rotation degrees.

Unfortunately, the LEGO Mindstorms NXT Direct Commands documentation is a bit sparse. It shows the valid values, but does not describe the behavior of each option, so you'll need to experiment, or check out LEGO's NXT forums.

David






Re: Microsoft Robotics - Hardware Configuration and Troubleshooting Dumb Question (Braking Lego Motors)

Kexyn

It seems that my lego motors are braking, but it only stops on a certain value if the motor power is really low, .125 seems to be pretty reliable. If the speed is at 1, the brakes don't stop the motors until almost a full rotation after the command is issued. That makes sense, and I can deal with trading motor speed for accuracy. If anybody else has any ideas I'd love to hear them, but slowing the motors down seems to work fine.