Auto Air Pump Code

I have seen a lot of auto air pump code out there that is longer and more sophisticated than it should be. I wrote the following code to accomplish the same task but it uses less lines of code and less IF statements. Yes, it includes a delay on turning off the pump.

Just copy and paste the following:

'=============================================
’ Auto Air Pump Sub
'=============================================

’ pressure is an alias for the pressure sensor
’ pressure = 0 when tank is full
’ pressure = 1 when tank is empty

’ pump is an alias for the relay output to the pump
’ When pump=1 the compressor is on.

’ num_loops is a byte variable that counts loops until…
’ pump_delay which is a constant for the number of loops
’ to run the pressure switch after it has been
’ toggled

’ This code is written as a subroutine. Place the code
’ after the main loop and call it by typing:
’ “gosub subAutoAirPump” in the main loop

subAutoAirPump:
if (pressure = 0) then pump_check
num_loops = 0
pump = 1
return

pump_check:
if (num_loops = pump_delay) then pump_off
pump = 1
num_loops = num_loops + 1
return

pump_off:
pump = 0
return

’ END CODE

Reply if you have any questions.

Greg Szorc

“Overfilling” the accumulators accomplishes nothing except stressing the compressor/breaker and wasting electricity.

  1. The check valve begins to “leak” at 120PSI. Feel free to overfill, but it will only waste electricity and give our team an easier time. Rules indicate that this must be the first thing in the pneumatics line after the compressor.

  2. It’s far easier to adjust the pressure sensors instead. I have ours set at 120 PSI (well, the point just before the valve starts to leak) and approx 100 PSI. This creates a buffer zone in case of miniscule leaks.

The code is smaller too…


Compressor:
  if low_pressure = ON then Compressor_on
  if high_pressure = OFF then Compressor_off
  goto Compressor_return

Compressor_on:
  compressor_relay = ON
  goto Compressor_return

Compressor_off:
  compressor_relay = OFF
  goto Compressor_return

Compressor_return:
  return

Sometimes the simplest approach is the easiest. I’ll let you do the reading on how this works. If you just implement it, then it will not get you anywhere.

Anyways, FIRST is about sharing and it’s nice to be of help. Just remember the KISS principle. Keep It Simple, Stupid. Another thing: The technical manuals and team updates contain a ton of pneumatics information, READ THEM.

Jnadke - you beat me to it! I was just going to post that! :stuck_out_tongue:

  • Katie

Woah! I didn’t realize we had two pressure sensors. I guess we misplaced the 2nd one last year. Maybe if you loose the second like I did you will need my code, otherwise the other code is easier. Now I can figure out what to do with the 8 bits of variable space I just gained back…

Sorry, but last year, people were posting counting routines to keep the pump switched on for a while after the pressure reached rock bottom (the low set point of the one pressure switch). This is the first year since we first Firsted that we have been given two pressure switches.

Odd, considering that with one allowed-this-tear IC you could purchase, you could get pressure readings instead of pressure set points, to feed into an analog port, and read it on the dashboard.

Our team just found out that pressure switches actually serve a purpose (from reading this thread) but now we’re kind of confused. How do you wire a pressure switch (12v, ground & signal…?) Thanks in advance.

There is an example in the manual in section 2.1.6. Basically you wire the ground to a ground pin on the digital input (pins 3,6,9,12,13,14,17,20,23) and the other to a digital sensor input pin (1,2,15,16,4,5,18,19,7,8,21,22,10,11,24,25). On the sensor itself, ground is marked as “C” and the signal is “NC.”

But you forget one thing…

software weighs nothing, and takes no sensor input.

BUT the extra switch weighs something…(not a lot i know… but it can make a difference) and takes an extra sensor input that if you have a very complicated robot with lots of sensor inputs and such, you may not have the extra sensor input to spare.

just a thought

We used the two switches at the same time to keep the pump from cycling when using only one sensor. It responds instantly to low pressure and does not use a delay. We hope to use sensors to do away with delays since it may be critial for the robot to respond during the delay.

The pump starts when below 110 PSI and stops when above 115 PSI. The fall between 115 and 110 does not cause a pump start. Even for small leaks, the pump only cycles about 2 times per minute not 20 times per minute like before.

not flameing or anything but i was wondering…

  1. how did you hook both pressure switches up to only one input and have it change state
    and
  2. why wouldent the robot respond during the pump delay?

I don’t think I explained it well. We use two sensors, and two digital inputs. The software determines if the pump is currently running before reading the sensors and deciding what to do.

We will stay with this setup unless we need to save the weight or input channel by removing the one extra sensor.

yea, thats like i said… one will save weight and an input… but the down side to that is you add a bit more code…

there is give and take in everything you do…

just a question guys what’s the difference between having one pressure switch or two pressure switch, is there any advantages?

*Originally posted by Antonio *
**just a question guys what’s the difference between having one pressure switch or two pressure switch, is there any advantages? **

One pressure switch weighs less than two.

Ergo, if you can do the job with one switch and some clever code (which weighs no more than stupid code), you can save some weight that can be used elsewhere…

-dave

  1. The sensor only weighs a couple of ounces. It is not going to cause your robot to be overweight. There are more signifacant things on your robot that will cause it to be overweight.

  2. You need to have two sensors in order to establish a hysteresis. Hysteresis is used to prevent wear and tear on the air pump.

The code is at the bottom of the post

a) You could use one sensor that would turn the air pump on and off whenever the air pressure drops below 120 PSI, but this will cause the battery to drain very quickly and it will steal vital current from your drive motors (the battery can only deliver so much current. Try running the drive motors and the pump at the same time. You should notice a difference) plus your pump motor will eventually burn out.

b) You could use one sensor to indicate a minimum pressure of 80 - 100 psi, then turn the pump on for a set amount of time aka: x number of program scans, and then turn it off after that amount of time. The problem with this is that you need to make sure that the pump turns off before the accumulators (The silver cylinders included in the kit that attach to the pump) reach 120psi. This means that you MUST use a freshly charged battery and time how long it takes for the pump to go from your minimum pressure to 120 psi. As the battery drains down and the amount of voltage at the terminals decreases, the pump will need more time to fill the accumulators with air, but if you are using one sensor you will need to sacrifice that the acculmulators will not fill all the way. You CANNOT depend upon the safety valve to bleed off your excess air. Will it work, yes, but it is a safety hazard. A few years ago, a steam engine at the Cuyahoga County Fair blew up and killed several people. The reason: the safety valve did not release when the pressure reached a critical pressure. The safety valve included on the pump is meant to be a safety precaution, a last resort, a oh my goodness my sensor is not working please save me. It is not meant to be used for general purpose use.

Using two sensors compensates for the degradation of voltage as the battery wears down, while allowing you to maintain your desired pressures and minimizing wear and tear on the pump motor.

FIRST posted code last year for the air pump. It is excellent:

Pump = (HighPres & ~PumpMan) & (LowPres | Pump)
Pump_rev = 0

HighPres = High Pressure Sensor
Low Pres = Low Pressure Sensor
PumpMan = An override switch that I can use to disable the pump for any reason (SAFETY)
Pump = The Pump Relay switch
Pump_rev = The relays included in the kit have a forward and a reverse output. The reverse output on the relay must be set to 0 at all times when using the air pump.

**The sensor only weighs a couple of ounces. It is not going to cause your robot to be overweight. There are more signifacant things on your robot that will cause it to be overweight. **

OK, all those that have had their robots arrive at inspection at 129.75 pounds, raise your hands!!!

An awful lot of teams spend an amazing amount of time carving out every extra ounce from their robots to allow them to just barely fit within the weight limits of the competition. Just take a look at the number of machines peppered with “lightening holes” that were obviously added in during the last few days of the build phase (or even at the competition site). So, if there is a way to avoid using a redundant sensors and saving four ounces on the robot, there are a lot of folks that will be interested in doing it.

Using one pressure sensor to detect when the system pressure drops below 110 psi, and firing the compressor for “X seconds” (where “X” is the time required for the compressor to increase system pressure from 110 psi to 120 psi) when the pressure drops below the set point is an acceptable algorithm.

The key is to have the compressor deliver a bolus of air for a fixed period of time – the shortest time sufficient to recharge the system under ideal conditions (as determined experimentally under optimal conditions with a fresh battery and no stress on the system), and not to try to extend the recharge period based on perceived system efficiency. Instead, just repeat the cycle as frequently as necessary – once each time the system pressure drops below 110 psi.

If, due to decreased battery output or other efficiency factors, the system is only charged to 115 psi instead of 120, we don’t really care – that is close enough, since what we are really concerned with is that the high pressure side of the system has enough pressure to recharge the low pressure (60 psi) side as air is used by the cylinders (note: 110 is not a magic number – this set point can be anywhere above 60 psi; based on how extensively your robot uses the pneumatics, adjust as necessary to ensure that pressure is maintained in the high pressure portion of the system to provide a constant reserve pressure to the low pressure side while not causing the pump to cycle continuously). If control system/battery/compressor efficiency drops, the recharge will just approach, but not meet or exceed the 120 psi limit. There is no concern about overcharging the accumulators.

For this set up to fail and cause any sort of unexpected energy release, there has to be at least a quadruple failure. The compressor needs to fail-on for an extended period of time to start to build up pressure in the system. The relief valve, set to 120 psi, has to fail to release at the design pressure. The compressor bypass seals need to fail to release at the overpressure level (if I remember the spec sheets correctly, around 140 psi). And finally, some element of the physical system (tubing, cylinder, or accumulator) needs to mechanically fail and release the pressure (assuming the compressor, which has a design output of 120 psi, is even capable of generating anything close to the 250 psi failure ratings of any of these components before it has a pressure lock and stalls out).

Although a constant-use system would probably not be designed this way, this approach is suitable for the low duty cycle, short lifetime applications like our competition robots.

-dave

p.s. If the boiler explosion referenced is the one that occurred at the Cuyahoga County Fair in July 2001, it actually was not caused by a safety valve failure. The boiler in question was in very poor condition, and had apparently been improperly maintained for several years. As a result, the crown sheet above the firebox was severely corroded. The corrosion in several places near the crown staybolts had reduced the crown sheet from a design thickness of 0.375” to less than 0.125”, and in some locations to less than 0.087”. Although it was later determined that the safety valve was inoperable (it was rusted shut, along with the inspection port and fusable plug), this explosion occurred because of a mechanical failure at a pressure well below the designed operating pressure of the boiler.

Letter excerpts from John D. Payton (Director, certified Boiler Engineers for the Commonwealth of Pennsylvania), who conducted an inspection of the damaged boiler at the request of County Sheriff Neil Hassinger and Chief Dean Jagger (Chief Boiler Inspector for the State of Ohio):

“…the crown sheet failure started at the 0.087” thickness area, the weakest point in the crown sheet, and this is where the most bending damage is done to the sheet. The rest of the sheet shows signs of being peeled away much as peeling wallpaper off of a wall. This was caused by the massive expansion of released steam. It is my evaluation that because of the very poor condition of the crown sheet with the reduction of the original thickness from 0.375” to 0.087” leaving only 23% of the original thickness, this was insufficient metal to hold the pressure of the steam resulting in a mechanical failure of the boiler.”

“Computations using formulas ASME 1924 and ASME 1998 computed using a thickness of 0.087” indicated a failure at between 40 psi and 47 psi.”

“The inoperative safety valve had no direct bearing on the explosion as the valve was set for 125 psi and, with the condition of the crown sheet, it is doubtful that 125 psi. was attainable.”


Y = AX^2 + BX + C

*Originally posted by dlavery *
The key is to have the compressor deliver a bolus of air for a fixed period of time…

Bolus is a neat word, but this is the first time I’ve ever heard it applied to air.:smiley:

From Websters -

Bo"lus (?), n.; pl. Boluses (#) A rounded mass of anything, esp. a large pill.

It’s my weird background showing through. When I used to work on ambulance crews, we referred to a “bolus” in the context of medications delivered as a supplemental I.V. charge. After a while, we tended to generalize it to mean anything running through a tube (and trust me, you don’t want to know how it is appropriate to describe large masses of anything running back wards through tubes, particularly after eating college dining hall food!).

-dave


Y = AX^2 + BX + C

David, True, that our little robot air system is unlikely to cause a catastrophic failure, but the purpose of the competition is to teach students proper building practices. I am a programmer, not a pneumatics expert, but using a relief valve as your high pressure sensor does not seem like proper building practices in the industry. Maybe you have some insight that I lack.

PS: Thanks for the correction. I was going off of what I heard in the news.

Animator,

I’m not a Pnuemattics expert either, but I do spend a lot of time around really big pressure vessels (15’x45’ autoclaves), and some time running them.

You are correct in saying that it is not proper design to use a relief valve as a “pressure sensor”, or even as a “control”.

However, in Dave’s system the relief valve should never need to do it’s thing. By setting the system timing so that at optimal conditions it just barely reaches 120 psi from the threshold pressure, you pratically ensure that it never quite does so under competition conditions. What really happens is that when the pressure drops, the compressor runs for X seconds and then stops. The final pressure will be close to but always less than 120psi. Remember, we are less than optimal here. If at the end of the cycle, the pressure is less than your threshold then the compressor can restart and try again. If the pressure is greater than the threshold but less than 120, it will just sit there until something changes.

I think that part of Dave’s point is that the extra psi or two you can get with two sensors probably won’t make a difference. If you’re drawing down the air system that far you don’t have enough margin to start with.