Skip to main content

Pneumatics

Air Pressure Controlled Movement

With Pneumatics we can make linear motion using air pressure and software controlled valves. The VEX system provides for single acting and double acting pistons. A single acting gives a push with air pressure, while the double acting can give a push or pull force with air. Mostly we use double acting, if we need only single we just use one side of the double acting.

Pneumatic set up

Pneumatic set up is shown in this image. The system requires a tank to store air, a manual valve to control the air. This image shows a system with 2 double acting pistons, each controlled by a solenoid valve.

Pneumatics Instructions

How to assemble and use the components of the VEX pneumatics system are shown in this Document.

The document gives detailed descriptions of each part and how to assemble them. If this is you first experience with pneumatics you must read this Document.

Code for Pneumatics

The code for the VEX pneumatics is basically telling the solenoid valve to switch from one position to another. This is done with a digital signal through the 3 wire ports of the V5 Brain. The method we use is

digital_out.set(bool)

Where bool is either true or false. True will send the air one way, false will send it the other.

 

We first have to create an object of digital_out class in the robot configuration. This is done in device set up .  Select three wire port and digital out.  You get this code in robotconfig.cpp.

digital_out Pneu1 = digital_out( Brain.ThreeWirePort.A);

This line creates an object named Pneu1, you can name it anything you want but just like naming motors it would be good if it is descriptive of what it is like claw or grabber. Brain.ThreeWirePort.A sets it as connected to port A you can use any of the available letters. If you have more than one solenoid you will certainly use different letters.

 

in main.cpp these lines can now be written in any function to control the pneumatics.

  Pneu1.set(true);
  wait(1000, msec);
  Pneu1.set(false);
  wait(1000, msec);
  Pneu1.set(true);

This code will just move the pneumatic cylinder from one position to the other after waiting a second between moves.

Driver Control

Here is a user control code that will let you move a pneumatic based on pushing buttons A or B

void driverControl() {
  while (true) {
    if (Controller1.ButtonA.pressing()) {
      Pneu1.set(true);
    } else if (Controller1.ButtonB.pressing()) {
      Pneu1.set(false);
    }
  }
}

Function

Using a function will organize your code better and make it easier to debug any problems. To write a function we need a type, a name, a list of arguments and some code conetained in curly braces.

void pushPneu1(bool push)
{
  Pneu1.set(push);
}

This is our function. It just sets the Pneumatic to true or false based on the argument that we send it when we call the function. Next is how to call the function from driver control. This code will set the pneumatic when we push buttonA. or send it the other way when we push buttonB

void driver() {
  // User control code here, inside the loop
 
  while (true) {

    //use ButtonA and ButtonB to activate the Pneumatic 1
    if(Controller1.ButtonA.pressing())
    {
     
      pushPneu1(true);
    }
    else if(Controller1.ButtonB.pressing())
    {
      pushPneu1(false);
    }
    wait(10, msec); // Sleep the task for a short amount of time to
                    // prevent wasted resources.
  }
}

 

You can also call this function while in auton mode.