Pneumatics Programming

I’m somewhat new to programming, and am wondering if someone could give me some help with programming my pneumatics. Basically what I want it to do is when I press one of the digital buttons the pneeumatics open and stay open until I press a different button.

I am using EasyC V2 but if you could post code from any program I could probably translate it

Thanks

on behaf of 1064A i would love to help

I use EasyC V4 but I can post some simple written code.

The pneumatics solenoids can either have a value of 1 or 0, so either extended or retracted. (This is for double acting pistons, the pistons with 2 hose ports).

I am assuming you want to be bale to control the piston (s) with a button so we will say Button 1 (For simplicity)

In your code you will need to get the value of “Button 1” and retrieve it to a variable, then you will say.

IF ( “Button 1” == 1 )
{
Set Digital Output 12 to 1 // This sets the solenoid to a certain number while “Button 1” is pressed.
}

Else
{
Set Digital Output 12 to 0
}

Now ^^This^^ is a very simple code yet if done correctly it gets the job done.

Please let me know if you still need help after this because if you really need it I can possibly post a video tutorial depending on how busy I am.

Good code, Dpbailey!
Based on that, I would add to it so it looks this:

void OperatorControl ( unsigned long ulTime )
{
      int ClawOpenButton; 
      int ClawClosedButton; 

      while ( 1 ) // Insert Your RC Code Below
      {
            ClawOpenButton = GetJoystickDigital ( 1 , 6 , 1 ) ;
            ClawOpenButton = GetJoystickDigital ( 1 , 6 , 2 ) ;
            if ( ClawOpenButton == 1 )
            {
                  SetDigitalOutput ( 1 , 1 ) ;
            }
            else if ( ClawClosedButton == 1 )
            {
                  SetDigitalOutput ( 1 , 0 ) ;
            }
      }
}

(That was from EasyC V4)

Basically, this lets you have one button that you can press which causes the pneumatics to fire one way, and have another button you can press which releases the pneumatics to spring back the other way (or fire back depending on if it’s double acting vs single acting).

You’ll need to set up two variables by double clicking on the Variables block underneath void OperatorControl (or your own custom function if that’s how you have it set up), typing int, then ClawOpenButton, going down a line and typing int, then ClawClosedButton (or whatever variable names you want to use for that)

It is very important that this code executes in a loop, because otherwise the program will only check your joystick and set your pneumatics once, but you want it to check and set continually while the robot is on.

Thank you for the compliment! :slight_smile:

The code I posted was a really simple program for retracting or extending the piston when the button was held and the opposite when it is released. Of course, once you get good at programming you can then program it so if you simply press the button the piston will stay extended until you press it again but that is a bit more advanced.

Anyways, there are many ways to perform tasks when it comes to programming and you just have to play around until you find what you want and what suits your needs.

Hopefully you understand all that we have said so far and again if you need anything just post back here and hell if you really want shoot me a PM, I will be more then happy to help you!

Thanks guys. I got a program that works. Also a quick question is there an easy way to set like a buffer zone on the analog controls so I don’t accidentally bump the robot in a direction that I don’t want to go on easyc v2?

Basically

if(joystickY<54||joystickY>76)
motorports=joystickY;

hey, see this thread is kind of old but i was wondering if you guys an update the sample code. I have been struggling with the variable part of the program.

specifically which variables, and what language are you using?

Alternatively, you can just use a Joystick to digital latch instead of a Joystick to digital output. This simplifies the code because for digital latch, you press the button one time without holding it and then to release it you press that same button again.

I don’t know if this is what you mean, but you can use the joystick analog deadband and set the values you don’t want the motors to respond.

my team is also using the pneumatic system and we have not done any tests but on the specs (http://www.vexrobotics.com/pneumatics.html) the force is 54N! that is roughly 34x vex motor power, is that accurate? Does the force decrease as the piston extends? If so, what is the average force? Why aren’t pneumatics used more often if they are that powerful (even if their stroke size is 2 inches)?

Well for starters they’re expensive, only have a limited amount of shots and are simply not practical in some situations ( drive trains etc ). Don’t get me wrong, they can be really helpful in some situations, but not so much in other situations :(.