气动元件#

介绍#

The VEX IQ Brain can control the VEX IQ Pneumatic system using the pneumatics class. This class allows the Brain to control the pneumatic pump and extend or retract pneumatic cylinders.

类构造函数#

pneumatics( 
  int32_t index );

类析构函数#

Destroys the pneumatics object and releases associated resources.

~pneumatics();

参数#

范围

类型

描述

index

int32_t

The Smart Port that the Pneumatic Solenoid is connected to, written as PORTx, where x is the port number (for example, PORT1).

例子#

// Create the pneumatics instance on Port 1
pneumatics Pneumatic1 = pneumatics(PORT1);

成员功能#

The pneumatics class includes the following member functions:

  • extend — Extend a cylinder.

  • retract — Retract a cylinder.

  • pump_on — Turns the pneumatic pump on.

  • pump_off — Turns the pneumatic pump off.

  • pump — Turns the pneumatic pump on or off.

  • installed — Returns whether or not the solenoid is connected to the brain.

Before calling any pneumatics member functions, a pneumatics instance must be created, as shown below:

/* This constructor is required to use an
IQ Pneumatics Solenoid. Replace the values
as needed. */

// Create the pneumatics instance on Port 1
pneumatics Pneumatic1 = pneumatics(PORT1);

extend#

伸出气缸。

Available Functions
void extend( 
  cylinderType id );

Parameters

范围

类型

描述

id

cylinderType

The cylinder to extend:

  • cylinder1
  • cylinder2
  • cylinderAll – Both cylinders

Return Values

此函数不返回值。

Examples
// Extend cylinder 1
Pneumatic1.extend(cylinder1);

// Extend all cylinders
Pneumatic1.extend(cylinderAll);

retract#

缩回气缸。

Available Functions
void retract( 
  cylinderType id );

Parameters

范围

类型

描述

id

cylinderType

The cylinder to retract:

  • cylinder1
  • cylinder2
  • cylinderAll – Both cylinders

Return Values

此函数不返回值。

Examples
// Retract cylinder 2
Pneumatic1.retract(cylinder2);

// Retract all cylinders
Pneumatic1.retract(cylinderAll);

pump_on#

启动气动泵。

Available Functions
void pump_on();

Parameters

此函数没有参数。

Return Values

此函数不返回值。

Examples
// Turn the pneumatic pump on
Pneumatic1.pump_on();

pump_off#

关闭气动泵。

Available Functions
void pump_off();

Parameters

此函数没有参数。

Return Values

此函数不返回值。

Examples
// Turn the pneumatic pump off
Pneumatic1.pump_off();

pump#

开启或关闭气动泵。

Available Functions
void pump( 
  bool state );

Parameters

范围

类型

描述

state

bool

The state to set: true turns the pneumatic pump on. false turns the pneumatic pump off.

Return Values

此函数不返回值。

Examples
// Turn the pump on
Pneumatic1.pump(true);

// Turn the pump off
Pneumatic1.pump(false);

installed#

返回气动电磁阀是否与大脑连接。

Available Functions
bool installed();

Parameters

此函数没有参数。

Return Values

返回一个布尔值,指示螺线管是否连接到大脑。

  • true if the solenoid is connected to the Brain.

  • false if the solenoid is not connected to the Brain.

Examples
// Check if the pneumatic solenoid is connected
if (Pneumatic1.installed()) {
  // Pneumatic system is ready
  Pneumatic1.pump_on();
}