Coding the IQ Pneumatics Kit

This guide is designed to help IQ Pneumatics Kit users navigate the process of understanding, configuring, and coding their pneumatics. For more information about the components within the IQ Pneumatics Kit, view this article from the VEX Library.

Important Update Notice: Make sure the firmware on your IQ Robot Brain and Pneumatic Control Unit is up to date. Using outdated firmware could result in unexpected behavior and performance issues with the pneumatic components. To learn how to update your firmware, view the "Firmware" Section in the VEX Library, ensuring you follow the instructions specific to your IQ generation control system.

Control Options and Setup

In the IQ Pneumatics Kit, the Pneumatic Solenoid plays a key role in enabling users to control pneumatic systems via VEXcode IQ.

To learn how the solenoid works, view this article from the VEX Library.

Configuring the Solenoid

As with motors and sensors, the Pneumatic Solenoid must be configured in VEXcode IQ before it can be used.

VEXcode IQ Toolbar with the Devices icon highlighted in between the Code Viewer and Monitor Console icons.

Open VEXcode IQ and select the Devices button to open the Devices window.

VEXcode IQ Devices menu with the Add a device button shown.

Select ‘Add a device.’

VEXcode IQ Devices menu after the Add a device button has been selected. The Pneumatic option is highlighted.

Select ‘PNEUMATIC.’

VEXcode IQ Devices menu after the Pneumatic option has been selected. There is a list of the robot's 12 Smart Ports, and the port numbered 12 is highlighted.

After selecting ‘PNEUMATIC,’ choose which port you plugged the Pneumatic Solenoid into your Robot Brain. Ports that are already configured for other devices will be unavailable.

Once the port has been selected, select ‘DONE’ to submit the device to the configuration or ‘CANCEL’ to return back to the Devices menu.

Note: Selecting ‘CANCEL’ will undo any changes you have made to the device and will not be a part of the configuration.

VEXcode IQ Devices Pneumatic menu after the Smart Port has been selected. There is a diagram of the Solenoid with two Pneumatic Cylinders, and there are options to reverse the Cylinder's inputs and outputs. By default, A and B on the Solenoid connect to A and B on the Cylinder.

After selecting ‘DONE,’ an image of the preconfigured Pneumatic Solenoid will appear.

The diagram shows the default configuration. We connect 'A' from the Pneumatic Solenoid to 'A' on the Cylinder, and 'B' to 'B'. This way, we can set our code to either ‘extend’ or ‘retract,’ because the ports on the Cylinders are connected to the matching ports on the Pneumatic Solenoid.

VEXcode IQ Devices Pneumatic menu after the Smart Port has been selected. There is a diagram of the Solenoid with two Pneumatic Cylinders, and the second Cylinder is set to Reverse, so now A connects to B and B connects to A.

VEXcode IQ has a feature in the configuration menu that lets you reverse your setups. So, even if your tubing is not connected as default, the extend and retract commands will match the operation of your robot.

Once satisfied with the wiring configuration, select ‘DONE’ to close the device menu and begin coding.

Coding the Pneumatic Solenoid

Let's now explore an example of coding the Pneumatic Solenoid using Blocks, Python, and C++ with a straightforward one-cylinder pneumatic system, which is depicted below. An example use case of this system could be to power a launcher mechanism. For more information on the components and assembly of this system, view this article from the VEX Library.

Diagram illustrating the components and setup of a VEX IQ Pneumatics system, featuring a VEX IQ Brain, Air Tank, Air Pump, Pneumatic Solenoid, and a 4 Pitch Stroke Pneumatic Cylinder. All of the pneumatic pieces are connected using the 4mm Tubing, and the Solenoid is connected to the Brain using a Smart Cable.

VEXcode IQ Blocks VEXcode IQ Python
VEXcode IQ Blocks Project that reads When started, set Pneumatic12 pump to on, and then set Pneumatic12 cylinder1 to retract.
pneumatic_12.pump_on()
pneumatic_12.retract(CYLINDER1)
VEXcode IQ C++
int main() 
{ Pneumatic12.pumpOn();
Pneumatic12.retract(cylinder1); }

Using a one-cylinder pneumatic setup shown previously, this example will cause the cylinder to fully retract immediately because of the powered on Air Pump.

Turning on the Air Pump before using the cylinder is crucial, as it provides the cylinder with the required air pressure. As long as you want your system to maintain air pressure, the Air Pump should remain on. Including a code to retract the cylinder is a typical safety feature. This way, your cylinder always starts from the same known spot (retracted) every time. When your code completes, the Pneumatic Solenoid will remain in the last position that you instructed it to move to.

VEXcode IQ Blocks VEXcode IQ Python
VEXcode IQ Blocks Project that reads When started, set Pneumatic12 pump to on, set Pneumatic12 cylinder1 to retract, wait 1 second, and then set Pneumatic12 cylinder1 to extend.
pneumatic_12.pump_on()
pneumatic_12.retract(CYLINDER1)
wait(1, SECONDS)
pneumatic_12.extend(CYLINDER1)
VEXcode IQ C++
int main() 
{ Pneumatic12.pumpOn();
Pneumatic12.retract(cylinder1);
wait(1, seconds);
Pneumatic12.extend(cylinder1); }

After running the previous example and stopping the program, the Pneumatic Solenoid stays in the retracted state. If you add an 'extend' command, the cylinder will first retract when the program begins, and then fully extend after one second. If you stop the program here, the solenoid will stay in the 'extended' state.

By using the 'Wait' commands between the retract and extend actions you allow time for the cylinder to complete its movement.

This forms the basic foundation for controlling pneumatics using VEXcode IQ. Remember that controlling your pneumatic system is a blend of 'extend' and 'retract' commands. Understanding how and why these actions occur is important. Combined with your customized pneumatic setup, these commands allow you to precisely control your system, making it behave exactly as you want.

 

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: