StopMotor
Stops / brakes specified motor. (Synchronisation will be lost after this)
Contents
Syntax
StopMotor(port, mode)
StopMotor(port, mode, handle)
Description
StopMotor(port, mode) stops the motor connected to the given port. The value port can be addressed by the symbolic constants MOTOR_A, MOTOR_B, MOTOR_C and 'all' (all motor at at the same time) analog to the labeling on the NXT Brick. The argument mode can be equal to 'off' (or 'nobrake' or false) which cuts off the electrical power to the specific motor, so called "COAST" mode. The option 'brake' (or 'on' or true) will actively halt the motor at the current position (until the next command).
The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).
Note:
The value port equal to 'all' can be used to stopp all motors at the same time using only one single Bluetooth packet. After a StopMotor command the motor snychronization will be lost.
With mode equal to 'off', the motor will slowly stop spinning, but using 'brake' applies real force to the motor to stand still at the current position, just like a real brake.
Using the active brake (e.g. StopMotor(MOTOR_A, 'brake')) can be very power consuming, so watch your battery level when using this functionality for long periods of time.
Limitations:
When working with a motor object that contains multiple motors (e.g. created by NXTMotor('BC')), stopping only one motor (in this case with e.g. StopMotor(MOTOR_B, 'off')) can lead to unexpected behavior. When working with synchronized motors, always stop those motors together. It's generally recommended to use the motor object's method Stop if possible.
Example
% regular stop StopMotor(MOTOR_B, 'brake');
% imagine we have all motors moving at once: m1 = NXTMotor('A', 'Power', 80); m2 = NXTMotor('BC', 'Power', 50); m1.SendToNXT(); m2.SendToNXT(); % a great way to stop all motors at once at the same time now: StopMotor('all', 'off'); % the other possibility would not stop movement at precisely % the same moment: m1.Stop(); m2.Stop();
See also
NXTMotor, Stop, NXT_SetOutputState, MOTOR_A, MOTOR_B, MOTOR_C,
Signature
- Author: Linus Atorf, Alexander Behrens (see AUTHORS)
- Date: 2009/08/24
- Copyright: 2007-2010, RWTH Aachen University