Motor 393 (Motor Controller 29)#

The motor29 class is used to control a Motor Controller 29 connected to a 3-Wire Port. The Motor Controller 29 sends a PWM signal from the V5 Brain to operate a VEX Motor 393.

Class Constructors#

1 Creates a motor29 object on the specified 3-Wire Port.

motor29(
    triport::port &port );

2 Creates a motor29 object on the specified 3-Wire Port and changes the positive turning direction.

motor29(
    triport::port &port,
    bool           reverse );

Class Destructor#

Destroys the motor29 object and releases associated resources.

~motor29();

Parameters#

Parameter

Type

Description

port

triport::port&

The 3-Wire Port that the Motor Controller 29 is connected to, written as Brain.ThreeWirePort.X or ExpanderName.X, where X is the port letter (for example, Brain.ThreeWirePort.A or Expander1.A).

reverse

bool

Sets the positive direction of motor rotation:

  • false (default) — Clockwise rotation is treated as forward (positive direction).
  • true — Counterclockwise rotation is treated as forward (positive direction).

Example#

// Create a Motor Controller 29 instance in 3-Wire Port A
motor29 Motor393_A = motor29(
    Brain.ThreeWirePort.A );

Member Functions#

The motor29 class includes the following member functions:

  • spin — Spins the motor in a specified direction.

  • stop — Stops the motor.

  • setVelocity — Sets the default motor velocity used for subsequent movement commands.

  • setReversed — Sets whether the motor’s rotation direction is reversed.

Before calling any motor29 member functions, an instance must be created, as shown below:

/* This constructor is required when using VS Code.
Motor 393 configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create a Motor Controller 29 instance in 3-Wire Port A
motor29 Motor393_A = motor29(
    Brain.ThreeWirePort.A );

spin#

Spins the Motor 393 in the specified direction indefinitely.

Available Functions

1 Spins using the currently configured velocity.

void spin(
 directionType dir );

2 Spins at the specified velocity.

void spin(
 directionType dir,
 double        velocity,
 velocityUnits units );

Parameters

Parameter

Type

Description

dir

directionType

The direction in which the motor spins:

  • forward
  • reverse

velocity

double

The velocity value applied to the motor.

units

velocityUnits

The unit used to represent velocity:

  • percent / pct — percent
  • rpm — rotations per minute
  • dps — degrees per second

Return Values

This function does not return a value.

Notes

  • This function is non-waiting and the project will continue executing immediately after the call.

  • The Motor 393 will continue spinning until stop is called or another spin is used.

stop#

Stops the motor.

Available Functions

void stop();

Parameters

This function does not take any parameters.

Return Values

This function does not return a value.

setVelocity#

Sets the default velocity for a Motor 393. This velocity setting will be used for subsequent calls to spin if a specific velocity is not provided.

Available Functions

void setVelocity(
    double velocity,
    percentUnits units );

Parameters

Parameter

Type

Description

velocity

double

The velocity value to apply to the Motor 393.

units

percentUnits

The unit used to represent velocity:

  • percent / pct — percent

Return Values

This function does not return a value.

setReversed#

Sets whether the motor’s rotation direction is reversed.

Available Functions

void setReversed(
    bool value );

Parameters

Parameter

Type

Description

value

bool

Sets the motor’s direction behavior:

  • true — The Motor 393’s positive direction is reversed.
  • false — The Motor 393’s positive direction remains normal.

Return Values

This function does not return a value.

Notes

  • Calling setReversed is the same as changing the reverse parameter in the constructor.