Pneumatics Help

I have the double-acting pistons and I was wondering exactly how to program it. What I have is a limit switch setup and want to use the same button to extend the pistons as well as retract them while utilizing the limit switches to achieve it. I also use robotc if that matters at all. I also have an issue when i pump up the tank. When I unlock the stem lock with the flip lock, it leaks out all the air. If anyone has any suggestions, please let me know. Thank you so much.

use the setDigital output command

setDigitalOutput(portNumber, State) state is one or zero the code would look lik this

Bool clawopen = false;
if(clawButton = 1){
        if(clawopen = false){
             setDigitalOutput(1,1);
             clawopen = true;
         }

         if(clawopen = true){
               setDigitalOutput(1,0);
               clawopen = false;
           }
}

Also in terms of the air leaks, check all of your hose connections for leaks, those are the most common location, next, check all the places where the valves screw in to tanks or pistons, add teflon tape to those locations to be safe.

if you still cannot figure it out, make a soap water solution, and lightly paint it onto suspect areas, bubbles will tell you where air is escaping, also use your ears to try and narrow down the location

Programming the pneumatics is quite simple, it is just a digital output. If you want to make it so the pneumatic cylinder is one state while the switch is pressed, you can do:


SensorValue[pneumatics] = SensorValue[limitSwitch];

Or you can do a simple toggle control with a button (or a switch too):


if(SensorValue[pneumatics] && VexRT[button])
    {
    SensorValue[pneumatics] = 0;
    while(VexRT[button]) //Waits until the button is released
        {}
    }
else if(VexRT[button])
    {
    SensorValue[pneumatics] = 1;
    while(VexRT[button]) //Waits until the button is released
        {}
    }

It’s not the best method as it will hold the program if you don’t release the button, but it is very simple. You can also do a state machine, but others are probably better at explaining that than me. (Note that some of the syntax is probably wrong, this is just semi-pseudo code)

For the leaks, make sure that all of the components are installed the right way around. Also, check that all hoses are cut perpendicular and smooth, and pushed fully into the one touch connectors.

Edit: I was too slow, some of the points were already mentioned!

Thank you for all of your help. The air leak I am having is when I unlock the lever on the end of the hose. I don’t know if something is getting stuck, but it loses all air when I unlock it.
PU277E00.jpg

Do you mean there is a leak somewhere in the system, or when you try to take the bike pump off some of your air leaks out before you fully remove the pump?

Because we have the second problem all the time. While releasing the bike pump the schrader valve will still be slightly depressed so air will leak out while you are removing the pump. This is annoying. We remedy it by over filling the tanks a bit, so that when we remove the pump it leaks to approximately the correct psi.

Definitely not the correct way, but its the best we can do.

I think the problem may be that you are pulling the lever but leaving the valve fitting on for some time?

if this is the case, try and remove the valve fitting from the nozzle as quickly as possible after pulling the lever

I’m having the problem when I’m pulling the pump off of it. I always try overfilling it some, but i lose all the air before I can pull it off. Idk if I try a different pump if it will help or not, but mine fits very snug.

I guess there’s a bit of an art to pulling a hose connection off of a Schrader valve. Usually I apply some firm upward pressure on the connection, then “pop” the lever so everything disconnects in one swift motion. It doesn’t always work and sometimes the stupid thing remains stuck there, hissing away. It’s thee main reason I discourage my kids from designing with pneumatics: they simply can’t get it to pop off properly more than 1 time out of maybe 4 or 5 tries. It takes some practice and, even then, more than once my kids have jerked the entire robot into the air when they try to pop the lever up. Some connectors just seem to pop off easier than others. I admit it’s frustrating. :frowning:

Okay so the trick to ensure you don’t lose any air when you disconnect is to use the old pump fitting and a switch.

The switch should go from the air tanks and point towards the pump fitting. Then when you finish pumping you flip the switch so the pump is emptied of air but the air tanks are sealed. Then release the pump however you want.

If your piston kits are new you can buy a external pump fitting here
http://www.plccenter.com/en-US/Buy/SMC/US3729

Maybe you could fix this by getting the old pump fitting.

That’s a very good idea. I don’t know why I never thought about that. Those old pump fittings help you place your refill point much more conveniently than having to always be at the tanks. Of course, another switch means another thing the kids might forget to turn on before a match. As always, it will be tough to train them not to forget that switch… but, hey, I don’t think the dogs will mind it much if I borrow their shock collars for another week or two.

There are a few different ways to control pneumatics, however, they all send either a “1” or “0” to a digital output port to place the piston in a retracted or extended state.

The simplest would be to send the state of a joystick button to the digital output.


#pragma config(Sensor, dgtl1,  pnu_out,        sensorDigitalOut)
#pragma config(Sensor, dgtl12, limit_sw,       sensorDigitalIn)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

void
PneumaticExample_1()
{
    SensorValue pnu_out ] = vexRT Btn8U ]; 
}

Next would be toggling the output every time a button is pressed. One feature we can use to help with this is that the current state of a digital output can be read back. The following code reads the state of the output and sets it to the opposite state. It also uses a static local variable (a variable that is only used in the function but retains its value between calls) to check if the joystick button has been released before looking for a press again.

void
PneumaticExample_2()
{
    static  bool wasPressed = false;
    
    if( (wasPressed == false) && vexRT Btn8U ] )
        {
        if( SensorValue pnu_out ] )
            SensorValue pnu_out ] = 0;
        else
            SensorValue pnu_out ] = 1;
        
        wasPressed = true;
        }
    else
    if( !vexRT Btn8U ] )
        wasPressed = false;
}

I often skip the if-then-else statement and use a simple trick to toggle the output state.

void
PneumaticExample_2a()
{
    static  bool wasPressed = false;
    
    if( (wasPressed == false) && vexRT Btn8U ] )
        {
        SensorValue pnu_out ] = 1 - SensorValue pnu_out ]; 
        
        wasPressed = true;
        }
    else
    if( !vexRT Btn8U ] )
        wasPressed = false;
}

You mentioned that you have a limit switch. If you want to set the pneumatics based on the state of the switch then you could do something like this.

void
PneumaticExample_3()
{
    static  bool wasPressed = false;
    
    if( (wasPressed == false) && vexRT Btn8U ] )
        {
        if( SensorValue limit_sw ] )
            SensorValue pnu_out ] = 1; 
        else
            SensorValue pnu_out ] = 0;
        
        wasPressed = true;
        }
    else
    if( !vexRT Btn8U ] )
        wasPressed = false;
}

It checks the state of the limit switch and then moves the pneumatic piston accordingly, not sure it’s really necessary to do this though (unless that switch is detecting another abject perhaps).

Call these function from your main while loop in driver control like this.

task usercontrol()
{
    while(1)
        {
        PneumaticExample_2();
        
        wait1Msec(25);
        }
}

I never even thought about that. I am going to try that. Thank you.

We are looking for something like this, however with the shipping costs and minimum order amount it will cost over $90. Know of any more economical alternatives.?