Pressure switch

We are using a pressure switch to turn on/off the compressor. I’ve been searching the interent with no luck in finding anything useful. If you can help it would be appreciated.

What exactly is the problem you are experiencing? You’re extremely vague about what you’re asking.

I just want to learn how to program a pressure switch to turn on the compressor when the pressure gets lower than 90psi and turn off at 120.

Run a periodic check on your Pressure Switch class to check if the value is less than 90 PSI, and if the compressor is not already on. If it isn’t, turn it on. Then do another check to see if pressure is greater than 120 PSI, and if the compressor is on. If it is, turn it off.

I just started learning java so I have no idea how to put that into code.

There is a method in the WPLIB? for the compressor. It should run in one of the periodic sections of code. The pressure switch is one of the digital inputs which the method reads & turns on & off the spike on one of the digital outputs. I believe you pass the IO you are using. Sorry for vagueness, I have minions that do actual programing. :slight_smile:

I still don’t understand. Can you put that in actual code?

Take a look at this web page. It shows how to use the Compressor object built into WPILib. It will automatically run the compressor when the pressure switch shows low pressure.

Be sure to not put the code in a loop since the Compressor class will start up a thread that will do all the checking in the background.

http://wpilib.screenstepslive.com/s/3120/m/7912/l/85779-operating-a-compressor-for-pneumatics

Brad