|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 Last edited by zorro : 10-01-2002 at 17:23. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does your team use the Default code. | Jeff McCune | General Forum | 2 | 09-01-2003 14:46 |
| What are pneumatics? | Aignam | Pneumatics | 23 | 16-10-2002 21:17 |
| Need help with 255 Variable | Joseph F | Programming | 18 | 26-02-2002 14:49 |
| Error found in programming for the pump and pressure switch | sjharobotics | Programming | 4 | 06-02-2002 17:46 |
| Pneumatics pump allowed on robot? | bigqueue | Pneumatics | 5 | 06-01-2002 12:30 |