Controlling pneumatics with your V5 controller requires a customized project. This article will described how to create a VEXcode V5 project.
Configuring Your Project
Select the Devices button to open the Devices window.
Select ‘Add a device.’
To start your VEXcode V5 project to control your pneumatics you will need to configure two devices.
You will need to add the Controller device.
For more information on configuring a Controller device, see the Configuring the V5 Controller in VEXcode V5 article from the VEX Library.
You will also need to add the 3-Wire device Digital out.
For more information on configuring a Digital out device, see the Configuring 3-Wire Digital In and Digital Out Devices in VEXcode V5 article from the VEX Library.
Control Your Pneumatic Cylinder With Two Controller Buttons
There are two commonly preferred methods drivers use to control pneumatics on their robot.
One way is to use two different buttons on the controller: one button to extend in the pneumatic cylinder and one button to retract the pneumatic cylinder. The following can be added to your VEXcode V5 project to control your pneumatic cylinder using 2 buttons on the controller.
From the sensing toolbox add a set digital out block to the [when started] block.
The [set digital out] block should be set on ‘low’. This will ensure your pneumatic cylinder starts the project fully retracted.
From the Events tool box add a [when Controller button pressed] block.
Select the controller button you prefer to use to extend the pneumatic cylinder.
Button L1 is used in this example.
Add a [set DigitalOut] block.
Select ‘high’ for the digital out setting.
This will cause the pneumatic cylinder to extend when button L1 on the controller is pressed.
From the Events tool box add another [when Controller button pressed] block.
Select the controller button you prefer to use to retract the pneumatic cylinder.
Button L2 is used in this example.
Add a [set DigitalOut] block.
Leave it as ‘low’ for the digital out setting.
This will cause the pneumatic cylinder to retract when button L2 on the controller is pressed.
Save the project, download it to the V5 Robot Brain, and run the project to test your control of the pneumatic cylinder using your controller.
For more information on saving, downloading, and running VEXcode V5 projects, please see the Open and Save Blocks Projects section of the VEX Library.
Control Your Pneumatic Cylinder with a Single Controller Button
Another preferred method drivers use to control pneumatics on their robot is to use a single button: the button extends the pneumatic cylinder when pressed and then retracts the pneumatic cylinder when pressed again. The following can be added to your VEXcode V5 project to control your pneumatic cylinder using a single button on the controller.
From the sensing toolbox add a set digital out block to the [when started] block.
The [set digital out] block should be set on ‘low’. This will ensure your pneumatic cylinder starts the project fully retracted.
From the Variables toolbox select Make a Boolean.
For this example we are going to call the Boolean: digitaloutON.
Add a [set digitaloutON] block.
Leave the Boolean set to <true>.
From the Events toolbox add a {when Controller button pressed} block.
Select the controller button you prefer to use to extend the pneumatic cylinder.
Button L1 is used in this example.
From the Control toolbox add an [if then else] block
Add a <digitaloutON> Boolean to the if.
Add a [set DigitalOut] block to the ‘then’ portion of the C block.
Change the [set DigitalOut] block to ‘high’.
Add a [set DigitalOut] block to the ‘else’ portion of the C block.
Leave the [set DigitalOut] block as ‘low’.
Add a [set digitaloutON] block.
Change the Boolean to <false>.
This will change the Boolean so the next time the L1 button is pressed the condition will go to the ‘else’ of the control C block.
Add another [set digitaloutON] block.
Leave the Boolean as <true>.
This will change the Boolean so the next time the L1 button is pressed the condition will go to the ‘then’ of the control C block.
From the Control toolbox add a [wait] block to both sections of the [if then else] C block.
Change the value to (0.1) seconds in each [wait] block.
This will allow a brief period of time for the condition to detect the button being pressed.
The button will extend the pneumatic cylinder when pressed and then retract the pneumatic cylinder when pressed again.
Save the project, download it to the V5 Robot Brain, and run the project to test your control of the pneumatic cylinder using your controller.
For more information on saving, downloading, and running VEXcode V5 projects, please see the Open and Save Blocks Projects section of the VEX Library.
The blocks to control your pneumatic cylinders will need to be recreated in an example project for the Competition Template before your robot will be ready to use in a competition utilizing a field control system.
For more on the competition template, see the Using the Blocks Competition Template in VEXcode V5 article in the VEX Library.
These projects can be used to control both the Single acting and the Double acting pneumatic cylinders. If two pneumatic cylinders are attached to a Solenoid valve using a “T” fitting, both cylinders will be controlled by the same set of blocks.
Note: The 3-Wire port on the V5 Robot Brain will revert back to a Digital in port when the project is stopped. This may, if there is enough residual air pressure, cause the pneumatic cylinder to extend. To avoid this, release the air pressure by either switching the Finger Valve to the off position or depressing the core of the Schrader Tire Valve before stopping the project.