NXC_ResetErrorCorrection

Sends reset error correction command to the NXC-program MotorControl on the NXT

Contents

Syntax

NXC_ResetErrorCorrection(port)

NXC_ResetErrorCorrection(port, handle)

Description

The NXC-program "MotorControl" must be running on the brick, otherwise this function will not work. It is used to sent advanced motor commands to the NXT that can perform better and more precise motor regulation than possible with only classic direct commands.

This function resets the "internal error correction memory" for the according motor. Usually, you cannot move the NXT motors by hand in between two commands that control the motors, since the modified motor position does not match the internal counters any more. This leads to unexpected motor behaviour (when the NXT firmware tries to correct the manual movements you just made). The problem described here does not occur when working with the NXTMotor class.

To work around this problem, it is possible to reset the error correction counter by hand using this function. It will clear the counter TachoCount, since this counter is internally attached to the error correction. The counter BlockTachoCount (see direct commands specification of the LEGO Mindstorms Bluetooth Developer Kit) will also be reset (since it is used to coordinate multiple motors during synchronous driving).

It is recommended to call this function before using classic direct commands (i.e. like NXT_SetOutputState), to get the intuitively expected results.

Input:

port has to be a port number between 0 and 2. It can also be an array of valid port-numbers, i.e. [0; 1], [0; 2], [1; 2] or [0; 1; 2]. The named constants MOTOR_A to MOTOR_C can be used for clarity (i.e. port = [MOTOR_A; MOTOR_B].

handle is optional and determines the NXT handle to be used, if specified. Otherwise the default handle will be used (set using COM_SetDefaultNXT).

Limitations

This function is intended for advanced users. It makes no sense to use it together with the NXTMotor class. It can however be useful in between certain DirectMotorCommand calls.

Example

 % This will reset the TachoCount counter for port A on the NXT, which
 % also resets the error correction
 NXC_ResetErrorCorrection(MOTOR_A);
 % Now MOTOR_A behaves as if the NXT was freshly booted up...
 % The "personal" position counter (field Position when calling
 % a motor object's method ReadFromNXT()) won't be affected through this
 % -- it will stay untouched until reset by a motor object's method
 % ResetPosition())

See also

NXTMotor, NXC_MotorControl, NXT_SetOutputState, NXT_GetOutputState, NXT_ResetMotorPosition, ReadFromNXT,

Signature