RCX: Motors

Processes and constants to work with motors and the RCX's three output ports.

Index

Declarations

Data type MOTOR.MODE

DATA TYPE MOTOR.MODE

Motor commands.

Group MOTOR

Commands to set the motor mode for direction

Constant MOTOR.FORWARD

VAL MOTOR.MODE MOTOR.FORWARD

Forward

Constant MOTOR.BACKWARD

VAL MOTOR.MODE MOTOR.BACKWARD

Backward

Constant MOTOR.STOP

VAL MOTOR.MODE MOTOR.STOP

Stop (actively stops the motor, brake)

Constant MOTOR.FLOAT

VAL MOTOR.MODE MOTOR.FLOAT

Float (stops the motor, but allows the motor to continue turning).

Group MOTOR

Constants to refer to motors connected to each of the three output ports on the RCX, labeled A through C.

Constant MOTOR.A

VAL INT MOTOR.A

Port A

Constant MOTOR.B

VAL INT MOTOR.B

Port B

Constant MOTOR.C

VAL INT MOTOR.C

Port C

Protocol MOTOR.CMD

PROTOCOL MOTOR.CMD

Commands to the motors

Tag forward

forward; INT

Go forward.

Parameters:

INT Speed for the motor, 0-7

Tag backward

backward; INT

Go backward.

Parameters:

INT Speed for the motor, 0-7

Tag stop

stop

Stop the motor (braked)

Tag float

float

Stop the motor (float)

Constant motor.addr

VAL [3]INT motor.addr

Motor addresses.

Process motor.control

PROC motor.control (VAL INT port, VAL MOTOR.MODE mode, VAL INT power)

Motor control process, makes the neccessary calls and displays indicators matching motor activity.

Parameters:

VAL INT port The motor port to control.
VAL MOTOR.MODE mode The mode to set the motor to.
VAL INT power The speed of the action. (not relevant for stop, float)

Process motor

PROC motor (VAL INT port, CHAN MOTOR.CMD cmd?)

Motor process, reads commands from a channel.

Parameters:

VAL INT port The port (MOTOR.A-C, or 0-2) to control.
CHAN MOTOR.CMD cmd The channel the process accepts commands on.