|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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); Code:
void PressureSwitch(void)
{
unsigned char pswitch;
pswitch = GetDigitalInput(psInput);
if (pswitch)
{
SetRelay(airpump, 1, 0);
}
else
{
SetRelay(airpump, 0, 0);
}
}
|
|
#2
|
||||
|
||||
|
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. Last edited by Kingofl337 : 05-02-2008 at 22:05. |
|
#3
|
||||
|
||||
|
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. ![]() |
|
#4
|
||||
|
||||
|
Re: Automated Air Compressor code
Why not use the KISS method (Keep it simple silly!)
Code:
relay08_fwd != rc_dig_in18; relay08_rev = 0; |
|
#5
|
||||
|
||||
|
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.
|
|
#6
|
|||||
|
|||||
|
Re: Automated Air Compressor code
Quote:
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
|
||||
|
||||
|
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:
Last edited by Kingofl337 : 11-02-2008 at 13:11. |
|
#8
|
|||
|
|||
|
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?
|
|
#9
|
|||
|
|||
|
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. |
|
#10
|
||||
|
||||
|
Re: Automated Air Compressor code
We are having problems with ours also....
Quote:
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
|
|||||
|
|||||
|
Re: Automated Air Compressor code
Quote:
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. |
|
#12
|
|||
|
|||
|
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
|
||||
|
||||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |