module Motor:Output ports.sig
..end
type
port
let motor_right = Mindstorm.Motor.a
.val a : port
val b : port
val c : port
val all : port
typeregulation =
[ `Idle | `Motor_speed | `Motor_sync ]
`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. .typerun_state =
[ `Idle | `Ramp_down | `Ramp_up | `Running ]
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 : |
(* | 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 : |
(* | if true , turns the motor on: enables
pulse-width modulation (PWM) power according
to speed. | *) |
|
brake : |
(* | 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 : |
(* | Turns on the chosen regulation. | *) |
|
turn_ratio : |
(* | Range: -100 .. 100.
See Mindstorm.Motor.regulation . | *) |
|
run_state : |
(* | See Mindstorm.Motor.run_state . | *) |
|
tach_limit : |
(* | Number of degrees to rotate; 0 : run forever.
Range: 0 .. 4294967295 (unsigned 32 bits).
See also Mindstorm.Motor.run_state . | *) |
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.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
.tach_limit
: set the number of degrees to rotate.
The movement is unfortunately not fully accurate.
Default 0
which means "no limit".brake
: turns on brake. Default true
.sync
: turn on `Motor_sync
. Default false
.turn_ratio
: set a turn-ratio. Default 0
.val set : ?check_status:bool ->
'a Mindstorm.conn -> port -> state -> unit
set conn p st
sets the state of the motor connected to the
port p
to st
.check_status
: whether to check the status returned by
the brick. Default: see Mindstorm.connect_bluetooth
.val get : 'a Mindstorm.conn ->
port -> state * int * int * int
get conn p
returns (state, tach_count, block_tach_count,
rotation_count)
wherestate
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
.val reset_pos : ?check_status:bool ->
'a Mindstorm.conn -> ?relative:bool -> port -> unit
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
.check_status
: whether to check the status returned by
the brick. Default: see Mindstorm.connect_bluetooth
.relative
: if true
, relative to the last movement,
otherwise absolute position. Default: false
.