Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Output ports.
The three motor ports (immutable). For more readability of your program, it is recommended you give appropriate aliases to the ports of interest at the beginning of your program, e.g. let motor_right = Mindstorm.Motor.a
.
val a : port
The three motor ports (immutable). For more readability of your program, it is recommended you give appropriate aliases to the ports of interest at the beginning of your program, e.g. let motor_right = Mindstorm.Motor.a
.
The motor port A.
val b : port
The motor port A.
The motor port B.
val c : port
The motor port B.
The motor port C.
val all : port
The motor port C.
Special value representing all 3 ports.
Regulation mode.
`Idle
: No regulation will be enabled.`Motor_speed
: enable power control: auto adjust PWM duty cycle if motor is affected by physical load.`Motor_sync
: enable synchronization: attempt to keep rotation in sync with another motor. You typically use this mode is to maintain a straight path for a vehicle robot automatically. You also can use this mode with the Mindstorm.Motor.state
turn_ratio
property to provide proportional turning. You must set `Motor_sync
on at least two motor ports to have the desired affect. If it is set on all three motor ports, only the first two (A and B) are synchronized. .Regulation mode.
`Idle
: No regulation will be enabled.`Motor_speed
: enable power control: auto adjust PWM duty cycle if motor is affected by physical load.`Motor_sync
: enable synchronization: attempt to keep rotation in sync with another motor. You typically use this mode is to maintain a straight path for a vehicle robot automatically. You also can use this mode with the Mindstorm.Motor.state
turn_ratio
property to provide proportional turning. You must set `Motor_sync
on at least two motor ports to have the desired affect. If it is set on all three motor ports, only the first two (A and B) are synchronized. .Specifies how to perform the transition to the new speed
given in Mindstorm.Motor.state
.
`Idle
: The motor is not run.`Running
enables power to any output device connected to the specified port(s).`Ramp_up
enables automatic ramping to a new speed set-point that is greater than the current speed set-point. When you use `Ramp_up
in conjunction with appropriate tach_limit
and speed
values, the NXT firmware attempts to increase the actual power smoothly to the speed
set-point over the number of degrees specified by tach_limit
.`Ramp_down
enables automatic ramping to a new speed set-point that is less than the current speed set-point. When you use `Ramp_down
in conjunction with appropriate tach_limit
and speed
values, the NXT firmware attempts to smoothly decrease the actual power to the speed
set-point over the number of degrees specified by tach_limit
.type state = {
speed : int;
Power set-point. Range: -100 .. 100. Values larger than 100 will be taken as 100 and values less than -100 will be takes as -100.
*)motor_on : bool;
if true
, turns the motor on: enables pulse-width modulation (PWM) power according to speed.
brake : bool;
Use run/brake instead of run/float. "Braking" in this sense means that the output voltage is not allowed to float between active PWM pulses. Electronic braking improves the accuracy (and is necessary to see a rotation at small speeds) of motor output, but uses slightly more battery power.
*)regulation : regulation;
Turns on the chosen regulation.
*)turn_ratio : int;
run_state : run_state;
tach_limit : int;
Number of degrees to rotate; 0
: run forever. Range: 0 .. 4294967295 (unsigned 32 bits). See also Mindstorm.Motor.run_state
.
}
The absolute value of speed
is used as a percentage of the full power capabilities of the motor. The sign of speed
specifies rotation direction. You must set some other properties appropriately for the speed
set-point to have the desired effect:
motor_on
must be true
.run_state
must be set to a non-`Idle
value.If not motor_on && not brake
, motors are in COAST mode: motors connected to the specified port(s) will rotate freely.
val speed :
?tach_limit:int ->
?brake:bool ->
?sync:bool ->
?turn_ratio:int ->
int ->
state
speed s
returns a state where speed
is s
, motor_on
is true if and only if s <> 0
, and run_state
= `Running
.
set conn p st
sets the state of the motor connected to the port p
to st
.
get conn p
returns (state, tach_count, block_tach_count,
rotation_count)
where
state
is the current state of the motors;tach_count
is the number of counts since the last reset of the motor counter (the reset occurs when Mindstorm.Motor.set
is issued);block_tach_count
is the current position relative to the last programmed movement.rotation_count
is the program-relative position counter relative to the last reset of the rotation sensor for motor p
.reset_pos conn p
resets the rotation count (given by the rotation_count
field of Mindstorm.Motor.get
) of the motor connected to port p
.