– title: Motor 393 (Motor Controller 29) | VEX EXP - C++ API description: Reference documentation for the motor29 class in VEX EXP C++. Includes constructors, functions, parameters, notes, and usage examples.#
电机 393(电机控制器 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 EXP Brain to operate a VEX Motor 393.

类构造函数#
1 — Creates a
motor29object on the specified 3-Wire Port.motor29( triport::port &port );
2 — Creates a
motor29object on the specified 3-Wire Port and changes the positive turning direction.motor29( triport::port &port, bool reverse );
类析构函数#
Destroys the motor29 object and releases associated resources.
~motor29();
参数#
范围 |
类型 |
描述 |
|---|---|---|
|
|
The 3-Wire Port that the Motor Controller 29 is connected to, written as |
|
|
Sets whether the motor’s spin direction is reversed:
|
例子#
// Create a Motor Controller 29 instance in 3-Wire Port A
motor29 Motor393_A = motor29(
Brain.ThreeWirePort.A );
成员功能#
The motor29 class includes the following member functions:
旋转 — 使电机沿指定方向旋转。
停止 — 停止电机。
setVelocity — Tells the Motor 393 how fast to spin.
setReversed — 设置电机的旋转方向是否反转。
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 forever.
可用功能
1 — 使用 当前配置的速度 旋转。
void spin( directionType dir );
2 — 以指定速度旋转。
void spin( directionType dir, double velocity, velocityUnits units );
参数
范围 |
类型 |
描述 |
|---|---|---|
|
|
The direction in which the motor spins: |
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The velocity unit:
|
返回值
此函数不返回值。
条笔记
该函数不等待,调用后项目将立即继续执行。
The Motor 393 will continue spinning until
stopis called or anotherspinis used.
stop#
停止电机运转。
可用功能
void stop();
参数
此函数不接受任何参数。
返回值
此函数不返回值。
setVelocity#
Tells a Motor 393 how fast to spin. A higher percentage makes the Motor 393 spin faster and a lower percentage makes the Motor 393 spin slower.
Every project begins with each Motor 393 spinning at 50% velocity by default.
可用功能
void setVelocity(
double velocity,
percentUnits units );
参数
范围 |
类型 |
描述 |
|---|---|---|
|
|
The velocity to spin with from 0% to 100% when using |
|
|
The velocity unit: |
返回值
此函数不返回值。
setReversed#
设置是否反转电机的旋转方向。
可用功能
void setReversed(
bool value );
参数
范围 |
类型 |
描述 |
|---|---|---|
|
|
Whether the Motor 393’s direction is reversed:
|
返回值
此函数不返回值。
条笔记
Calling
setReversedis the same as changing thereverseparameter in the constructor.