Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Auto Air Pump Code (http://www.chiefdelphi.com/forums/showthread.php?t=1658)

zorro 10-01-2002 17:20

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

Jnadke 19-01-2002 14:15

"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...

Code:

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.

Katie Reynolds 19-01-2002 16:53

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

- Katie

zorro 20-01-2002 18:28

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...

Lloyd Burns 20-01-2002 23:17

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.

kangarue23 21-01-2002 14:32

Wiring for the pressure switch...?
 
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.

zorro 21-01-2002 15:45

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."

Justin Stiltner 21-01-2002 18:59

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

Tim Skloss 22-01-2002 10:41

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.

Justin Stiltner 22-01-2002 12:53

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?

Tim Skloss 22-01-2002 14:33

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.

Justin Stiltner 22-01-2002 20:20

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..

Antonio 08-12-2002 23:23

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

dlavery 08-12-2002 23:40

Quote:

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

Animator 09-12-2002 18:35

Why you should use two sensors
 
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.


All times are GMT -5. The time now is 00:04.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi