NXT Functions Motors
From ROBOTC API Guide
NXT → Functions and Variables → Motors
| For more examples and explanations, head over to Motors and Servos Overview!
There are three motors on the NXT labeled A, B and C. Each motor is equipped with an integrated encoder that can be used to determine the current position of the motor. The encoders have 360 counts per single revolution of the motor. A count of 180 indicates that the motor has traveled half a rotation. |
|
| |||||||
bFloatDuringInactiveMotorPWM
| bool bFloatDuringInactiveMotorPWM | |
| (bool) Boolean variable. True "coasts" ("floats") the motor when power is not applied. False brakes the motor. False is best choice. | |
|
bMotorReflected
| bool bMotorReflected | |
| (bool) Boolean array. Used to indicate that the direction of a motor should be reflected 180 degrees. Useful when mechanical design results in a logical "reversed" condition of a motor. This can also be configured in the Motors and Sensor Setup menu in ROBOTC. | |
|
motor
| int motor[tMotor motor] | ||||||
| (int) Contains the motor power or speed level (-100 to +100). Negative values are reverse; positive formward. A power level of 0 (zero) stops the motors. | ||||||
| ||||||
|
nMaxRegulatedSpeedNXT
| int nMaxRegulatedSpeedNXT | |
| (int) Specifies the maximum speed, in encoder counts per second, that should be used for speed regulation on the NXT. (Default is 1000) | |
|
nMotorEncoder
| long nMotorEncoder | |
| (long) Current value of the motor encoder. Range is -32768 to 32767 so it will "wrap" after about ~90 revolutions. The user's program should reset the value of the encoder often to avoid the value "resetting" itself when the maximum distance is met. | |
|
nMotorEncoderTarget
| long nMotorEncoderTarget | ||
| (long) The nMotorEncoderTarget is used to set a target distance that a motor should move before system puts motor back in idle or stopped state. A target value of 0 (zero) means run forever. The first example only looks at one motor's encoder, keeping things simple in order to travel a specific distance. The second example monitors both motor's encoders to ensure that they both reach their target before moving on to the next segment of code. | ||
|
nMotorPIDSpeedCtrl
| TMotorRegulation nMotorPIDSpeedCtrl | |
| (TMotorRegulation) nMotorPIDSpeedCtrl is used to enable or disable the speed regulation that is used to ensure that motors travel at a consistent speed, regardless of the surface or resistance met. Speed Regulation can be set in the Motors and Sensor Setup menu in ROBOTC. To make things easier, by default PID is enabled for LEGO motors. | |
|
nMotorRunState
| TNxtRunState nMotorRunState | |
(TNxtRunState) Array containing the internal state of a NXT motor. Useful in checking when a motor movement "command" has finished. There are three different states:
| |
|
nPidUpdateInterval
| int nPidUpdateInterval | |
| (int) Interval (in milliseconds) to use for motor PID updates. Default is 25. Updating the PID algorithm too often could cause the PID algorithm to be very dynamic and cause a jerky motion. A value too high will not update fast enough and will cause the motors to seem as if they are not regulated. | |
|
nSyncedMotors
| TSynchedMotors nSyncedMotors | |
| (TSynchedMotors) Used to specify synchronization of two NXT motors so they operate in "lock step" at the same speed turn ratio. The command to sync motors is "synchXY", where X is the "master" motor letter, and Y is the "slave" motor letter. | |
|
nSyncedTurnRatio
| int nSyncedTurnRatio | |
| (int) Turn ratio to use for a motor that is "slaved" to another motor. +100 is same as primary motor. Zero is stopped. -100 is same movement as primary but in inverted directon. Values between 100 and 0 give porportional power levels from the primary motor to the slave motor. | |
|