Returns the name of the port that this motor is connected to.
Sends a command to the motor controller. See commands
for a list of
possible values.
Returns a list of commands that are supported by the motor
controller. Possible values are run-forever
, run-to-abs-pos
, run-to-rel-pos
,
run-timed
, run-direct
, stop
and reset
. Not all commands may be supported.
run-forever
will cause the motor to run until another command is sent.run-to-abs-pos
will run to an absolute position specified by position_sp
and then stop using the action specified in stop_action
.run-to-rel-pos
will run to a position relative to the current position
value.
The new position will be current position
+ position_sp
. When the new
position is reached, the motor will stop using the action specified by stop_action
.run-timed
will run the motor for the amount of time specified in time_sp
and then stop the motor using the action specified by stop_action
.run-direct
will run the motor at the duty cycle specified by duty_cycle_sp
.
Unlike other run commands, changing duty_cycle_sp
while running will
take effect immediately.stop
will stop any of the run commands before they are complete using the
action specified by stop_action
.reset
will reset all of the motor parameter attributes to their default value.
This will also have the effect of stopping the motor.Returns the number of tacho counts in one meter of travel of the motor. Tacho counts are used by the position and speed attributes, so you can use this value to convert from distance to tacho counts. (linear motors only)
Returns the number of tacho counts in one rotation of the motor. Tacho counts are used by the position and speed attributes, so you can use this value to convert rotations or degrees to tacho counts. (rotation motors only)
Returns the name of the driver that provides this tacho motor device.
Returns the current duty cycle of the motor. Units are percent. Values are -100 to 100.
Writing sets the duty cycle setpoint. Reading returns the current value. Units are in percent. Valid values are -100 to 100. A negative value causes the motor to rotate in reverse.
Writing sets the duty cycle setpoint. Reading returns the current value. Units are in percent. Valid values are -100 to 100. A negative value causes the motor to rotate in reverse.
Returns the number of tacho counts in the full travel of the motor. When
combined with the count_per_m
atribute, you can use this value to
calculate the maximum travel distance of the motor. (linear motors only)
Returns the maximum value that is accepted by the speed_sp
attribute. This
may be slightly different than the maximum speed that a particular motor can
reach - it's the maximum theoretical speed.
Sets the polarity of the motor. With normal
polarity, a positive duty
cycle will cause the motor to rotate clockwise. With inversed
polarity,
a positive duty cycle will cause the motor to rotate counter-clockwise.
Valid values are normal
and inversed
.
Sets the polarity of the motor. With normal
polarity, a positive duty
cycle will cause the motor to rotate clockwise. With inversed
polarity,
a positive duty cycle will cause the motor to rotate counter-clockwise.
Valid values are normal
and inversed
.
Returns the current position of the motor in pulses of the rotary encoder. When the motor rotates clockwise, the position will increase. Likewise, rotating counter-clockwise causes the position to decrease. Writing will set the position to that value.
Returns the current position of the motor in pulses of the rotary encoder. When the motor rotates clockwise, the position will increase. Likewise, rotating counter-clockwise causes the position to decrease. Writing will set the position to that value.
The derivative constant for the position PID.
The derivative constant for the position PID.
The integral constant for the position PID.
The integral constant for the position PID.
The proportional constant for the position PID.
The proportional constant for the position PID.
Writing specifies the target position for the run-to-abs-pos
and run-to-rel-pos
commands. Reading returns the current value. Units are in tacho counts. You
can use the value returned by counts_per_rot
to convert tacho counts to/from
rotations or degrees.
Writing specifies the target position for the run-to-abs-pos
and run-to-rel-pos
commands. Reading returns the current value. Units are in tacho counts. You
can use the value returned by counts_per_rot
to convert tacho counts to/from
rotations or degrees.
Writing sets the ramp down setpoint. Reading returns the current value. Units
are in milliseconds and must be positive. When set to a non-zero value, the
motor speed will decrease from 0 to 100% of max_speed
over the span of this
setpoint. The actual ramp time is the ratio of the difference between the
speed_sp
and the current speed
and max_speed multiplied by ramp_down_sp
.
Writing sets the ramp down setpoint. Reading returns the current value. Units
are in milliseconds and must be positive. When set to a non-zero value, the
motor speed will decrease from 0 to 100% of max_speed
over the span of this
setpoint. The actual ramp time is the ratio of the difference between the
speed_sp
and the current speed
and max_speed multiplied by ramp_down_sp
.
Writing sets the ramp up setpoint. Reading returns the current value. Units
are in milliseconds and must be positive. When set to a non-zero value, the
motor speed will increase from 0 to 100% of max_speed
over the span of this
setpoint. The actual ramp time is the ratio of the difference between the
speed_sp
and the current speed
and max_speed multiplied by ramp_up_sp
.
Writing sets the ramp up setpoint. Reading returns the current value. Units
are in milliseconds and must be positive. When set to a non-zero value, the
motor speed will increase from 0 to 100% of max_speed
over the span of this
setpoint. The actual ramp time is the ratio of the difference between the
speed_sp
and the current speed
and max_speed multiplied by ramp_up_sp
.
Returns the current motor speed in tacho counts per second. Note, this is
not necessarily degrees (although it is for LEGO motors). Use the count_per_rot
attribute to convert this value to RPM or deg/sec.
The derivative constant for the speed regulation PID.
The derivative constant for the speed regulation PID.
The integral constant for the speed regulation PID.
The integral constant for the speed regulation PID.
The proportional constant for the speed regulation PID.
The proportional constant for the speed regulation PID.
Writing sets the target speed in tacho counts per second used for all run-*
commands except run-direct
. Reading returns the current value. A negative
value causes the motor to rotate in reverse with the exception of run-to-*-pos
commands where the sign is ignored. Use the count_per_rot
attribute to convert
RPM or deg/sec to tacho counts per second. Use the count_per_m
attribute to
convert m/s to tacho counts per second.
Writing sets the target speed in tacho counts per second used for all run-*
commands except run-direct
. Reading returns the current value. A negative
value causes the motor to rotate in reverse with the exception of run-to-*-pos
commands where the sign is ignored. Use the count_per_rot
attribute to convert
RPM or deg/sec to tacho counts per second. Use the count_per_m
attribute to
convert m/s to tacho counts per second.
Reading returns a list of state flags. Possible flags are
running
, ramping
, holding
, overloaded
and stalled
.
Reading returns the current stop action. Writing sets the stop action.
The value determines the motors behavior when command
is set to stop
.
Also, it determines the motors behavior when a run command completes. See
stop_actions
for a list of possible values.
Reading returns the current stop action. Writing sets the stop action.
The value determines the motors behavior when command
is set to stop
.
Also, it determines the motors behavior when a run command completes. See
stop_actions
for a list of possible values.
Returns a list of stop actions supported by the motor controller.
Possible values are coast
, brake
and hold
. coast
means that power will
be removed from the motor and it will freely coast to a stop. brake
means
that power will be removed from the motor and a passive electrical load will
be placed on the motor. This is usually done by shorting the motor terminals
together. This load will absorb the energy from the rotation of the motors and
cause the motor to stop more quickly than coasting. hold
does not remove
power from the motor. Instead it actively tries to hold the motor at the current
position. If an external force tries to turn the motor, the motor will 'push
back' to maintain its position.
Writing specifies the amount of time the motor will run when using the
run-timed
command. Reading returns the current value. Units are in
milliseconds.
Writing specifies the amount of time the motor will run when using the
run-timed
command. Reading returns the current value. Units are in
milliseconds.
Generated using TypeDoc
The motor class provides a uniform interface for using motors with positional and directional feedback such as the EV3 and NXT motors. This feedback allows for precise control of the motors. This is the most common type of motor, so we just call it
motor
.The way to configure a motor is to set the '_sp' attributes when calling a command or before. Only in 'run_direct' mode attribute changes are processed immediately, in the other modes they only take place when a new command is issued.