Wheel IDE

Online demo »

Motor

This file contains procedures to control EV3 or Powered Up motors.

Constants

The motor module.
Source: lib/modules/motor.whl, line: 10
MODULE_MOTOR6

Module calls to control the motors.
Source: lib/modules/motor.whl, line: 13
MOTOR_SET_TYPE0
MOTOR_SET_SPEED1
MOTOR_SET_BRAKE2
MOTOR_GET_TYPE3
MOTOR_RESET4
MOTOR_REVERSE5
MOTOR_MOVE_TO6
MOTOR_MOVE_TO_BITS7
MOTOR_ON8
MOTOR_TIME_ON9
MOTOR_STOP10
MOTOR_READ11
MOTOR_READY12
MOTOR_READY_BITS13
MOTOR_THRESHOLD14

Motor types.
Source: lib/modules/motor.whl, line: 30
MOTOR_MEDIUM7
MOTOR_LARGE8

The motor outputs, OUTPUT_E and OUTPUT_F can only be used for Spike.
Source: lib/modules/motor.whl, line: 34
OUTPUT_A0
OUTPUT_B1
OUTPUT_C2
OUTPUT_D3
OUTPUT_E4
OUTPUT_F5

Bits to identify the motor combinations for ready or to move multiple motors to a given position.
Source: lib/modules/motor.whl, line: 42
MOTOR_BITS_A0b0001
MOTOR_BITS_B0b0010
MOTOR_BITS_AB0b0011
MOTOR_BITS_C0b0100
MOTOR_BITS_AC0b0101
MOTOR_BITS_BC0b0110
MOTOR_BITS_ABC0b0111
MOTOR_BITS_D0b1000
MOTOR_BITS_AD0b1001
MOTOR_BITS_BD0b1010
MOTOR_BITS_ABD0b1011
MOTOR_BITS_CD0b1100
MOTOR_BITS_ACD0b1101
MOTOR_BITS_BCD0b1110
MOTOR_BITS_ABCD0b1111

Brake or coast the motor.
Source: lib/modules/motor.whl, line: 59
MOTOR_COAST0
MOTOR_BRAKE1

Procedures

motorLayerSetType
Source: lib/modules/motor.whl, line: 63

Set the motor type.

proc motorLayerSetType(number layer, number id, number type)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
typenumberThe type of motor: MOTOR_MEDIUM or MOTOR_LARGE.

motorLayerSetSpeed
Source: lib/modules/motor.whl, line: 72

Set the motor speed.

proc motorLayerSetSpeed(number layer, number id, number speed)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
speednumberThe speed of the motor. The value must be between -100 and 100 where negative values mean a reverse direction.

motorLayerSetBrake
Source: lib/modules/motor.whl, line: 81

Set the motor brake or coast: 0 = coast, 1 = brake. The default value is 1 (brake).

proc motorLayerSetBrake(number layer, number id, number brake)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
brakenumber

motorLayerGetType
Source: lib/modules/motor.whl, line: 89

Get the connected motor type.

proc motorLayerGetType(number layer, number id)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorLayerReset
Source: lib/modules/motor.whl, line: 97

Reset the tacho count for the motor.

proc motorLayerReset(number layer, number id)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorLayerReverse
Source: lib/modules/motor.whl, line: 105

Reverse the motor move to direction.

proc motorLayerReverse(number layer, number id)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorLayerMoveTo
Source: lib/modules/motor.whl, line: 113

Move the motor to a given target angle.

proc motorLayerMoveTo(number layer, number id, number target)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
targetnumberThe target angle.

motorLayerMoveToBits
Source: lib/modules/motor.whl, line: 122

Move the motors to a given target angle. This procedure is not implemented in the EV3 VM.

proc motorLayerMoveToBits(number layer, number bits, number target)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
bitsnumberThe motor bits, the first bit is motor A, the second motor B, etc. Checking motor A and C: 0b0101
targetnumberThe target angle.

motorLayerOn
Source: lib/modules/motor.whl, line: 131

Turn the motor on.

proc motorLayerOn(number layer, number id)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorLayerTimeOn
Source: lib/modules/motor.whl, line: 139

Turn the motor on for a given time.

proc motorLayerTimeOn(number layer, number id, number time)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
timenumberTime in milliseconds.

motorLayerStop
Source: lib/modules/motor.whl, line: 148

Stop the motor.

proc motorLayerStop(number layer, number id)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorLayerRead
Source: lib/modules/motor.whl, line: 156

Read a motor position.

proc motorLayerRead(number layer, number id)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
Return: The current motor position in degrees.


motorLayerReady
Source: lib/modules/motor.whl, line: 165

Check if a motor reached its target.

proc motorLayerReady(number layer, number id)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorLayerReadyBits
Source: lib/modules/motor.whl, line: 173

Check if one or more motors reached their target.

proc motorLayerReadyBits(number layer, number bits)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
bitsnumberThe motor bits, the first bit is motor A, the second motor B, etc. Checking motor A and C: 0b0101

motorLayerThreshold
Source: lib/modules/motor.whl, line: 181

Set the threshold for the motor to reach the given angle, this proc only applies to Powered Up.

proc motorLayerThreshold(number layer, number id, number threshold)
Parameters:
NameTypeDescription
layernumberThe layer, the daisy chained device. 0 is the primary brick.
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
thresholdnumberThe threshold, if the difference in degrees between the motor target and position is less than this value then the motor ready status returns TRUE.

motorSetType
Source: lib/modules/motor.whl, line: 191

Set the motor type for the main device.

proc motorSetType(number id, number type)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
typenumberThe type of motor: MOTOR_MEDIUM or MOTOR_LARGE.

motorSetSpeed
Source: lib/modules/motor.whl, line: 198

Set the motor speed for the main device.

proc motorSetSpeed(number id, number speed)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
speednumberThe speed of the motor. The value must be between -100 and 100 where negative values mean a reverse direction.

motorSetBrake
Source: lib/modules/motor.whl, line: 205

Set the motor brake or coast for the main device: 0 = coast, 1 = brake. The default value is 1 (brake).

proc motorSetBrake(number id, number brake)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
brakenumber

motorGetType
Source: lib/modules/motor.whl, line: 211

Get the connected motor type.

proc motorGetType(number id)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
Return: The type of motor connected to the primary device.


motorReset
Source: lib/modules/motor.whl, line: 218

Reset the tacho count for the motor for the main device.

proc motorReset(number id)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorReverse
Source: lib/modules/motor.whl, line: 224

Reverse the motor move to direction.

proc motorReverse(number layer, number id)
Parameters:
NameTypeDescription
layernumber
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorMoveTo
Source: lib/modules/motor.whl, line: 230

Move the motor to a given target angle for the main device.

proc motorMoveTo(number id, number target)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
targetnumberThe target angle.

motorMoveToBits
Source: lib/modules/motor.whl, line: 237

Move the motor to a given target angle. This procedure is not implemented in the EV3 VM.

proc motorMoveToBits(number bits, number target)
Parameters:
NameTypeDescription
bitsnumberThe motor bits, the first bit is motor A, the second motor B, etc. Checking motor A and C: 0b0101
targetnumberThe target angle.

motorTimeOn
Source: lib/modules/motor.whl, line: 244

Turn the motor of the main device on for a given time.

proc motorTimeOn(number id, number time)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
timenumberTime in milliseconds.

motorStop
Source: lib/modules/motor.whl, line: 251

Stop the motor on the main device.

proc motorStop(number id)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorRead
Source: lib/modules/motor.whl, line: 257

Read a motor position on the main device.

proc motorRead(number id)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
Return: The current motor position in degrees.


motorReady
Source: lib/modules/motor.whl, line: 264

Check if a motor on the main device reached its target.

proc motorReady(number id)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.

motorReadyBits
Source: lib/modules/motor.whl, line: 270

Check if one or more motors reached their target.

proc motorReadyBits(number bits)
Parameters:
NameTypeDescription
bitsnumberThe motor bits, the first bit is motor A, the second motor B, etc. Checking motor A and C: 0b0101

motorThreshold
Source: lib/modules/motor.whl, line: 277

Set the threshold for the motor to reach the given angle, this proc only applies to Powered Up.

proc motorThreshold(number id, number threshold)
Parameters:
NameTypeDescription
idnumberThe output, the first output is 0. Constants: OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D.
thresholdnumberThe threshold, if the difference in degrees between the motor target and position is less than this value then the motor ready status returns TRUE.

waitForMotors
Source: lib/modules/motor.whl, line: 285

Wait until the given motors have reached their targets.

proc waitForMotors(number bits)
Parameters:
NameTypeDescription
bitsnumberThe motor bits, the first bit is motor A, the second motor B, etc. Checking motor A and C: 0b0101