NQC Overview Outputs Contents | Master Index
 CyberMaster   RCX   RCX2   Scout 

FUNCTIONS / COMMANDS
 
          SetOutput()  Set the outputs to the specified mode.
          SetDirection()  Set the outputs to the specified direction.
          SetPower()  Sets the power level of the specified outputs.
          On()  Turn specified outputs on.
          Off()  Turn specified outputs off.
          Float()  Make outputs float.
          Fwd()  Set outputs to forward direction.
          Rev()  Set outputs to reverse direction.
          Toggle()  Flip the direction of the outputs.
          OnFwd()  Set outputs to forward direction and turn them on.
          OnRev()  Set outputs to reverse direction and turn them on.
          OnFor()  Turn outputs on for a specified amount of time.
          SetGlobalOutput()  Disable or re-enable outputs depending on the mode parameter.
          SetGlobalDirection()  Reverses or restores the directions of outputs.
          SetMaxPower()  Sets the maximum power level allowed for the outputs.

VALUES / QUERIES
 
          OutputStatus()  Returns the current output setting for motor n.
          GlobalOutputStatus()  Returns the current global output setting for motor n.

OVERVIEW
 
          All of the functions dealing with outputs take a set of outputs as their first argument. This set must be a constant. The names OUT_A, OUT_B, and OUT_C are used to identify the three outputs. Multiple outputs can be combined by adding individual outputs together. For example, use OUT_A+OUT_B to specify outputs A and B together. The set of outputs must always be a compile time constant (it cannot be a variable).
 
          Each output has three different attributes: mode, direction, and power level. The mode can be set by calling SetOutput(outputs, mode). The mode parameter should be one of the following constants:
 
Output ModeMeaning
OUT_OFF output is off (motor is prevented from turning)
OUT_ON output is on (motor will be powered)
OUT_FLOAT motor can "coast"

 
          The other two attributes, direction and power level, may be set at any time, but only have an effect when the output is on. The direction is set with the SetDirection(outputs, direction) command. The direction parameter should be one of the following constants:
 
Direction Meaning
OUT_FWD Set to forward direction
OUT_REV Set to reverse direction
OUT_TOGGLE Switch direction to the opposite of what it is presently

 
          The power level can range 0 (lowest) to 7 (highest). The names OUT_LOW, OUT_HALF, and OUT_FULL are defined for use in setting power level. The level is set using the SetPower(outputs, power) function.
 
          By default, all three motors are set to full power and the forward direction (but still turned off) when a program starts.
 
          Since control of outputs is such a common feature of programs, a number of convenience functions are provided that make it easier to work with the outputs. It should be noted that these commands do not provide any new functionality above the SetOutput and SetDirection commands. They are merely convenient ways to make programs more concise.

 
FUNCTIONS / COMMANDS
 CyberMaster   RCX   RCX2   Scout 

         SetOutput(outputs, mode) Overview | Top
         
Set the outputs to the specified mode. Outputs is one or more of OUT_A, OUT_B, and OUT_C. Mode must be OUT_ON, OUT_OFF, or OUT_FLOAT.
SetOutput(OUT_A + OUT_B, OUT_ON); // turn A and B on


         SetDirection(outputs, direction) Overview | Top
         
Set the outputs to the specified direction. Outputs is one or more of OUT_A, OUT_B, and OUT_C. Direction must be OUT_FWD, OUT_REV, or OUT_TOGGLE.
SetDirection(OUT_A, OUT_REV); // make A turn backwards


         SetPower(outputs, power) Overview | Top
         
Sets the power level of the specified outputs. Power may be an expression, but should result in a value between 0 and 7. The constants OUT_LOW, OUT_HALF, and OUT_FULL may also be used.
SetPower(OUT_A, OUT_FULL); // A full power

SetPower(OUT_B, x);

         On(outputs) Overview | Top
         
Turn specified outputs on. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
On(OUT_A + OUT_C); // turn on outputs A and C


         Off(outputs) Overview | Top
         
Turn specified outputs off. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
Off(OUT_A); // turn off output A


         Float(outputs) Overview | Top
         
Make outputs float. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
Float(OUT_A); // float output A


         Fwd(outputs) Overview | Top
         
Set outputs to forward direction. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
Fwd(OUT_A);


         Rev(outputs) Overview | Top
         
Set outputs to reverse direction. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
Rev(OUT_A);


         Toggle(outputs) Overview | Top
         
Flip the direction of the outputs. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
Toggle(OUT_A);


         OnFwd(outputs) Overview | Top
         
Set outputs to forward direction and turn them on. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
OnFwd(OUT_A);


         OnRev(outputs) Overview | Top
         
Set outputs to reverse direction and turn them on. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together.
OnRev(OUT_A);


         OnFor(outputs, time) Overview | Top
         
Turn outputs on for a specified amount of time, then turn them off. Outputs is one or more of OUT_A, OUT_B, and OUT_C added together. Time is measures in 10ms increments (one second = 100) and may be any expression.
OnFor(OUT_A, x);


         SetGlobalOutput(outputs, mode) Overview | Top
         
Disable or re-enable outputs depending on the mode parameter. If mode is OUT_OFF, then the outputs will be turned off and disabled. While disabled any subsequent calls to SetOutput() (including convenience functions such as On()) will be ignored. Using a mode of OUT_FLOAT will put the outputs in float mode before disabling them. Outputs can be re-enabled by calling SetGlobalOutput() with a mode of OUT_ON. Note that enabling an output doesn't immediately turn it on - it just allows future calls to SetOutput() to take effect.
SetGlobalOutput(OUT_A, OUT_OFF);  // disable output A

SetGlobalOutput(OUT_A, OUT_ON); // enable output A

         SetGlobalDirection(outputs, direction) Overview | Top
         
Reverses or restores the directions of outputs. The direction parameter should be OUT_FWD, OUT_REV, or OUT_TOGGLE. Normal behavior is a global direction of OUT_FWD. When the global direction is OUT_REV, then the actual output direction will be the opposite of whatever the regular output calls request. Calling SetGlobalDirection() with OUT_TOGGLE will switch between normal and opposite behavior.
SetGlobalDirection(OUT_A, OUT_REV); // opposite direction

SetGlobalDirection(OUT_A, OUT_FWD); // normal direction

         SetMaxPower(outputs, power) Overview | Top
         
Sets the maximum power level allowed for the outputs. The power level may be a variable, but should have a value between OUT_LOW and OUT_FULL.
SetMaxPower(OUT_A, OUT_HALF);



 
VALUES / QUERIES
 CyberMaster   RCX   RCX2   Scout 

         OutputStatus(n) Overview | Top
         
Returns the current output setting for motor n. Note that n must be 0, 1, or 2 - not OUT_A, OUT_B, or OUT_C.
x = OutputStatus(0); // status of OUT_A


         GlobalOutputStatus(n) Overview | Top
         
Returns the current global output setting for motor n. Note that n must be 0, 1, or 2 - not OUT_A, OUT_B, or OUT_C.
x = GlobalOutputStatus(0); // global status of OUT_A


Comments