电机 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 V5 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 the positive direction of motor rotation:
|
例子#
// 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 — 设置后续运动命令使用的默认电机速度。
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#
使电机 393 沿指定方向无限期旋转。
可用功能
1 — 使用 当前配置的速度 旋转。
void spin( directionType dir );
2 — 以指定速度旋转。
void spin( directionType dir, double velocity, velocityUnits units );
参数
范围 |
类型 |
描述 |
|---|---|---|
|
|
The direction in which the motor spins:
|
|
|
施加于电机的速度值。 |
|
|
The unit used to represent velocity:
|
返回值
此函数不返回值。
条笔记
该函数不等待,调用后项目将立即继续执行。
The Motor 393 will continue spinning until
stopis called or anotherspinis used.
stop#
停止电机运转。
可用功能
void stop();
参数
此函数不接受任何参数。
返回值
此函数不返回值。
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.
可用功能
void setVelocity(
double velocity,
percentUnits units );
参数
范围 |
类型 |
描述 |
|---|---|---|
|
|
施加于电机 393 的速度值。 |
|
|
The unit used to represent velocity:
|
返回值
此函数不返回值。
setReversed#
设置是否反转电机的旋转方向。
可用功能
void setReversed(
bool value );
参数
范围 |
类型 |
描述 |
|---|---|---|
|
|
Sets the motor’s direction behavior:
|
返回值
此函数不返回值。
条笔记
Calling
setReversedis the same as changing thereverseparameter in the constructor.