Go to Post "Find a problem? Think of the three I's: Invent and Innovate to Improve!" - yash101 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-02-2008, 19:31
ShotgunNinja's Avatar
ShotgunNinja ShotgunNinja is offline
Programming Mentor, FRC 4247
AKA: Nicholas Iannone
FRC #4247 (CougarBOTS)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Milwaukee, WI
Posts: 160
ShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the rough
Automated Air Compressor code

In case anyone needed some help with putting on an automated air compressor, here is some code that may be able to help. In order to use this, you would need a single pressure switch attached to a relay and an input, and a relay for the air compressor.

In Initialize:
Code:
InitPressureSwitch(psInput, psRelay);
And in a new function:
Code:
void PressureSwitch(void)
{
   unsigned char pswitch;

   pswitch = GetDigitalInput(psInput);
   if (pswitch)
   {
      SetRelay(airpump, 1, 0);
   }
   else
   {
      SetRelay(airpump, 0, 0);
   }
}
You also need to appropriately set the values of airpump, psInput, and psRelay.
__________________
Team #2970 Alum
Team #1652 Alum
2006: School Mascot for Team 1652
2007-2008: Programmer for Team 1652 (Robot Mafia)
2009: Programmer on Team 1652 (Robot Mafia), Programmer on Team 2970 (eSchool eBots)
2010-2016: Volunteer, Wisconsin Regional
2017: Programming Mentor, FRC 4247 (CougarBOTS, Obama SCTE, Milwaukee, WI)
  #2   Spotlight this post!  
Unread 05-02-2008, 22:03
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Automated Air Compressor code

You don't need both you only need to call InitPressureSwitch(psInput, psRelay); in the Initialize function.

It will take care of everything after that.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni

Last edited by Kingofl337 : 05-02-2008 at 22:05.
  #3   Spotlight this post!  
Unread 09-02-2008, 10:58
ShotgunNinja's Avatar
ShotgunNinja ShotgunNinja is offline
Programming Mentor, FRC 4247
AKA: Nicholas Iannone
FRC #4247 (CougarBOTS)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Milwaukee, WI
Posts: 160
ShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the rough
Re: Automated Air Compressor code

Well, the point is not only to set up a pressure switch, but to get that pressure switch to trigger an air compressor to activate, filling up our tanks if the pressure is too low.

If that IS what the InitPressureSwitch function would do, then please feel free to let me know, and I'll fix my code.
__________________
Team #2970 Alum
Team #1652 Alum
2006: School Mascot for Team 1652
2007-2008: Programmer for Team 1652 (Robot Mafia)
2009: Programmer on Team 1652 (Robot Mafia), Programmer on Team 2970 (eSchool eBots)
2010-2016: Volunteer, Wisconsin Regional
2017: Programming Mentor, FRC 4247 (CougarBOTS, Obama SCTE, Milwaukee, WI)
  #4   Spotlight this post!  
Unread 09-02-2008, 11:21
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Automated Air Compressor code

Why not use the KISS method (Keep it simple silly!)
Code:
relay08_fwd != rc_dig_in18;
relay08_rev = 0;
It uses less memory, and doesn't cause the program to jump to another section of the program.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
  #5   Spotlight this post!  
Unread 11-02-2008, 08:41
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Automated Air Compressor code

The function of InitPressureSwitch is to turn on the compressor when the air pressure falls below the maximum air pressure as indicated by the pressure switch.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
  #6   Spotlight this post!  
Unread 11-02-2008, 10:48
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Automated Air Compressor code

Quote:
Originally Posted by Kingofl337 View Post
The function of InitPressureSwitch is to turn on the compressor when the air pressure falls below the maximum air pressure as indicated by the pressure switch.
That sounds both confusing and unhelpful. First, shouldn't it turn on the compressor when the pressure falls below the minimum? The pressure switch doesn't give a "falls below maximum" indication. Second, you still haven't made it clear whether InitPressureSwitch has to be called regularly in order for it to work, or whether the single call in the Initialize function will set up some hidden background code to handle the compressor automatically without any further user action.

Naming it beginning with "Init" implies that it is intended to be run only once, at the start of the program. The name also implies that it initializes things that need to be processed later, but there doesn't seem to be an associated "ProcessPressureSwitch" function. Perhaps the tutorial explains the proper use, though I don't recall seeing anything about it.
  #7   Spotlight this post!  
Unread 11-02-2008, 12:04
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Automated Air Compressor code

From the help file....

Use the Pressure Switch block to automatically regulate a compressor in a pneumatic system.

The Pressure Switch function should be called a single time prior to your use of the compressor in a pneumatic system. The best place to use this block may be in 'Initialize'. The function will automatically monitor the state of the pressure switch (every 500ms), and will activate the spike to power the compressor whenever the pressure switch closes (at about 95 psi). The compressor will stop when it reaches it's maximum pressure of 115 psi.

edit: Also Alan if you read my earlier post

Quote:
You don't need both, you only need to call InitPressureSwitch(psInput, psRelay); in the Initialize function.

It will take care of everything after that.
My post you quoted made more sence.
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni

Last edited by Kingofl337 : 11-02-2008 at 13:11.
  #8   Spotlight this post!  
Unread 12-02-2008, 08:14
jonboy jonboy is offline
Engineer/Mentor
FRC #0885 (The Green Team)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Tunbridge, Vermont
Posts: 46
jonboy is an unknown quantity at this point
Re: Automated Air Compressor code

I assume that the pressure switch should be wired between DIO SIG and GND for the EasyCPro InitPressureSwitch() function to work correctly. Correct?
__________________
... jon
  #9   Spotlight this post!  
Unread 12-02-2008, 09:48
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Automated Air Compressor code

The InitPressureSwitch function causes the timer interrupt service routine to read the pressure sensor every millisecond (probably overkill, but it was an easy place to put it). If the pressure is low the supplied relay port will be turned on, and if it's high it will be turned off.

So you only need to call the function once, and for the rest of your program, both autonomous and operator control the compressor will operate on its own.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
  #10   Spotlight this post!  
Unread 13-02-2008, 23:28
Japper's Avatar
Japper Japper is offline
Registered User
FRC #3692 (RocknRobots)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Rutland Wisconsin
Posts: 147
Japper has a spectacular aura aboutJapper has a spectacular aura about
Re: Automated Air Compressor code

We are having problems with ours also....

Quote:
We tried the code:

relay07_fwd != rc_dig_in07;
relay07_rev = 0;
and the pressure switch is connected to digital input 7 with the signal on one side of the switch and ground on the other side of the switch, the spike controlling the compressor (spike 7) is on all the time and the air compressor will continue pumping until after I disconnect it at 125 psi... it should shut off at 120 I thought but when I connect an ohm meter to this switch, it is open regardless of the air pressure (< 90 or > 120)...

I thought I read that the presure switch is normally closed but opens when the pressure dips down below 90 psi and then remains open until it reaches 120 psi... is this correct?

Is this a bad pressure switch or is there something that we don't have connected correctly?

Thanks
  #11   Spotlight this post!  
Unread 14-02-2008, 11:44
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Automated Air Compressor code

Quote:
Originally Posted by Japper View Post
Is this a bad pressure switch or is there something that we don't have connected correctly?
The code you posted is for MPLAB, while this is a sub-forum for EasyC Pro discussions.

It sounds as if you are wired correctly, so concentrate on the behavior of the pressure switch first, but test it in isolation.
Disconnect one of the pressure switch terminals so there is no possibility of a short along the wire or grounded through the RC.
Then take a ohm measurement of the pressure switch with your multi-meter when there is no pressure in the system, then allow the system to run up to 120psi and take another measurement.
If there is no change then it's the pressure switch, otherwise...
reconnect the pressure switch, but disconnect the cable from the RC, and repeat your measurements at the RC end of the cable.

Work step-by-step on narrowing down the possibilities.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #12   Spotlight this post!  
Unread 14-02-2008, 12:48
Dad1279 Dad1279 is offline
Registered User
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: NJ
Posts: 511
Dad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud ofDad1279 has much to be proud of
Re: Automated Air Compressor code

For EasyC Pro, we just have InitPressureSwitch(18,8) in the Initialize section of project. 18 for Digital input 18, Relay 8.
  #13   Spotlight this post!  
Unread 14-02-2008, 15:52
ShotgunNinja's Avatar
ShotgunNinja ShotgunNinja is offline
Programming Mentor, FRC 4247
AKA: Nicholas Iannone
FRC #4247 (CougarBOTS)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Milwaukee, WI
Posts: 160
ShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the rough
Re: Automated Air Compressor code

Yeah... oops. Disregard my original post.

I guess that this did serve one purpose: To give people a place to go to figure out similar mistakes.
__________________
Team #2970 Alum
Team #1652 Alum
2006: School Mascot for Team 1652
2007-2008: Programmer for Team 1652 (Robot Mafia)
2009: Programmer on Team 1652 (Robot Mafia), Programmer on Team 2970 (eSchool eBots)
2010-2016: Volunteer, Wisconsin Regional
2017: Programming Mentor, FRC 4247 (CougarBOTS, Obama SCTE, Milwaukee, WI)
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AIR COMPRESSOR !!! edgar_amaro Pneumatics 11 05-02-2008 00:43
Air Compressor Question Jrocklz Pneumatics 4 17-01-2008 21:36
Air Compressor Wireing question Bochek General Forum 7 11-01-2007 21:34
Off robot air compressor sanddrag Rules/Strategy 52 11-01-2007 15:11
Air Compressor geo Technical Discussion 4 06-02-2002 22:52


All times are GMT -5. The time now is 19:09.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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