I have an air compressor that has undesirable condensate collecting in the tank. I would like to trigger a pneumatic relay valve via Arduino controlled relay.
I want the relay to open for 1/2 sec two times when the compressor start up current is detected on A0. After that the valve should remain closed (relay off) until the next start up.
The relay is getting stuck closed.
I should note I wanted to try and write code based on runtime of the compressor as detected by current sensor but I don't have the experience yet.
Any help would be great.
void setup() {
// initialize the digital out pin1 as an output:
pinMode(1, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop() {
const int highthreshold = 700; // an threshold level that's in the range of compressor start up surge
const int lowthreshold = 0; // an threshold level that's in the range of compressor running after start up
int analogValue = analogRead(A0); // read the value of the current sensor
if (analogValue > highthreshold) {
digitalWrite(1, HIGH); //tap relay valve on D1 open and closed 2 times for 1/2 second
delay(500);
digitalWrite(1, LOW);
delay(500);
digitalWrite(1, HIGH);
delay(500);
digitalWrite(1, LOW);
} else {
digitalWrite(1, LOW);
}
// print the analog value:
Serial.println(analogValue);
Serial.println(digitalRead(1));
delay(1); // delay in between reads
}
With many years experience in an industrial setting, you actually need to wait until the tank cools before opening a valve to purge the liquid. That gives enough time for the water vapor to condense on the cold metal and run to the bottom of the tank.
Opening a valve when the compressor motor starts only gets rid of yesterday's liquid, but leaves the water vapor in the compressed air and tank until the next time the compressor starts.
Thanks for this tip. If I could write the code to purge if low current = (some long period of off) would that help. If you have ideas for a better approach I would love to hear them.
Ignore the current thing. Go by temperature of the tank. After being warm, and then going cold, open the valve for some set time and then go to sleep until the tank gets warm again.
You write the code, we will help when you encounter problems.
Removing "yesterday's" condensate is often enough though. At least that way it's not building up for a long time.
Automatic Condensate purge was one of the fun features I had to implement on a machine we built. The pneumatics normally ran at around 35psi with a low pressure warning around IIRC 30psi. The ask was to purge condensate every 8 hours, but the machine could potentially be in use all day long so I couldn't let the pressure drop. So what I ended up doing was turning on the compressor to bring the pressure up to 50psi (a regulator kept the pneumatics happy) and then opening the condensate release valve and watching the pressure to make sure it didn't drop below 30. It was fun watching the high pressure mist come blasting out with a loud hissing noise. Then we realized that would end up causing even more damage to stuff that got sprayed, so the purge line was routed to a Waste container.
I have a temp sensor laying around. That will be a code challenge for me. Im wondering how to have it happen just one time when temp gets low and not repeatedly. I’ll work on it.
Very easy to use. Just one 2 kOhm Pullup-resistor from Vcc to Data.
Then connect GND to GND, Vcc to 5V and the data-Pin to an arduino-IO-pin and start measuring.
If you have any questions feel free to ask them. As long as this is a "Give hints" and "take some own effor" to learn it you will get support on the forum.
If you post the country you are living in I can search and post a onlineshop where you can buy the DS18B20 sensor.
best regards Stefan
Be the change you want to see in the world
This notion of be the change you want to see in the world does 3 powerful things when we adopt it:
It stops us from judging others;
It replaces complaining about others with reflection on self;
It stirs us into taking action within the only thing in the world over which we have any control: ourselves.
I see the update about the DS18B20 and will get one and adjust the code. I am not in my workshop at the moment but I think this code will activate the relay repeatedly as long as the temp is below the threshold. bo matter what sensor I use I am lost on the coding at this point. , because I want it to cycle the relay one time and then remain closed until the compressor starts again. I have a current sensor that might work as reset.
#include "DHT11.h"
#define DHT11_DATA_PIN 2
DHT11 *dht11 ;
void setup() {
Serial.begin(115200);
dht11 = new DHT11( DHT11_DATA_PIN ) ;
}
void loop() {
// cut and paste code sensor code from https://github.com/rcorbish/DHT11
uint16_t temp ;
uint16_t humidity ;
if( dht11->read( temp, humidity ) ) {
Serial.print( temp ) ;
Serial.print( "C " ) ;
Serial.print( humidity ) ;
Serial.println( "%" ) ;
Serial.println(digitalRead(2));
const int highthreshold = 25; // an threshold high temp level
const int lowthreshold = 23; // an threshold tank temp level
// end cut and paste code from https://github.com/rcorbish/DHT11
// start relay action
if (temp < lowthreshold) {
digitalWrite(2, HIGH); //tap relay valve on D1 open and closed 2 times for 1/2 second
delay(500);
digitalWrite(2, LOW);
delay(500);
digitalWrite(2, HIGH);
delay(500);
digitalWrite(2, LOW);
} else {
digitalWrite(2, LOW);
// end relay action
// how do I pause here until some restart event?
}
}}