Coding the V5 Pneumatics Kit

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

Control Options and Setup

In the V5 Pneumatics Kit, the Double Acting Solenoid and its accompanying Double Acting Solenoid Driver Cable play key roles in enabling users to control pneumatic systems via VEXcode V5.

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

Configuring the Solenoid

Since we have learned the Solenoid is just a 3-Wire device that we can change the state of, we will now add and configure the device in VEXcode V5.

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

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

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

Select ‘Add a device.’

VEXcode V5 Devices menu after the Add a device button has been selected. The 3-Wire option is highlighted.

Select ‘3-WIRE.’

VEXcode V5 Devices menu after the Add a device button and then the 3-Wire device have been selected. A list of 3-Wire devices is shown, and the Digital Out option is highlighted.

After selecting ‘3-WIRE,’ select ‘DIGITAL OUT.’

Remember, we need to tell the Solenoid what state it should be in. To do this, we need to send information out through the 3-Wire, which is why we chose the Digital Out device.

VEXcode V5 Devices menu after the Digital Out option has been selected. There is a list of the robot's 8 3-Wire Ports, and the port labeled A is highlighted.

After selecting Digital Out, choose which 3-wire port you plugged the Solenoid Driver Cable into on 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 V5 Digital Out Sensing category is shown in the Toolbox, with one Digital out block available that reads set DigitalOutA low.

After this, the 'Digital Out' Sensing commands have now appeared in the Sensing section.

The digital out commands change the state of the Solenoid:

Low - Flow of air to outlet A

High - Flow of air to outlet B

VEXcode V5 Devices menu with the Digital Out options opened and the Delete button in the bottom left highlighted.

For more information about configuring 3-Wire Digital In and Digital Out devices in VEXcode V5 such as how to rename them, delete them from the configuration, or change their port number, view this article from the VEX Library.

Coding the Solenoid

Let's now explore an example of coding the 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. For examples of a basic V5 Pneumatics System operation, view this article from the VEX Library.

Complete V5 One Cylinder Pneumatics System, with several components that are all controlled by a connection to a V5 Brain.

VEXcode V5 Blocks VEXcode V5 Python
VEXcode V5 Blocks Project that reads When started, set DigitalOutA low.
digital_out_a.set(False)
VEXcode V5 C++
int main() 
{ DigitalOutA.set(false);
}

Using a one-cylinder pneumatic setup, this example will cause the cylinder to fully retract immediately, provided the Air Tank is pressurized and the Shut Off Valve Fitting is open.

Remember the default state for our solenoid is a low state (or 'false' with text coding), so this example will ensure our cylinder starts from a known position of being retracted.

VEXcode V5 Blocks VEXcode V5 Python
VEXcode V5 Blocks Project that reads When started, set DigitalOutA low, wait 1 seconds, and then set DigitalOutA high.
digital_out_a.set(False)
wait(1, SECONDS)
digital_out_a.set(True)
VEXcode V5 C++
int main() 
{ DigitalOutA.set(false); wait(1, seconds); DigitalOutA.set(true); }

After the above example is executed and the program ends, the solenoid stays in the low state. By adding a 'DigitalOut' high state, or True code, the cylinder will first retract when the program starts and then fully extend after one second. If you stop the program at this point, the solenoid will revert back to the low state.

It is helpful to separate 'DigitalOut' commands using 'Wait' commands. This will allow a brief period of time for the Cylinder to extend or retract.

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

Last Updated: