I am designing a oxygen concentration system with a arduino uno. It will Run 4 Oxygen cons, a oil free air compressor and a solenoid valve or two (currently only one). To register the psi of the system i am using a pressure transducer that goes from .5v to 4.5v wired to analog 0 and to turn all the others on i am using a 8 relay board that i will send 110v in and out for the cons and compressor. For the normally closed solenoids i will send 12v in and out to power them.
I have to have the oxy cons come on for 2 minutes to get the purity up before turning on the compressor, so the solenoid needs to open to let the oxy vent for the 2 mins before it turn on. After the cons are at purity the system will turn the compressor on and the con vent off till the system reaches 95psi then turn compressor and oxy cons off and the oxy con vent on to let them discharge the excess pressure. Then once the system goes below 70 psi it will repeat the process.
I am very new to arduino and c programming language but with enough reading and breaking down other code i have came up with this but it seems to me i am doing something wrong with my coding
Any help with the project would be greatly appreciated! This is just the start of the system and i will be adding several more parts to be where i want it and possibly will need to switch to a mega just so i have the inputs i need to complete it properly. Will want to add menus to change the variables and eeprom to store those values for the next time the system is turned on. I will also want to add a shutdown sequence just encase the pressure goes higher then designed.
Something to note, i know oxygen and oil is a big nono and have taken all the precautions so i don't get a big bang so please save me the this is dangerous speech. In my industry this has been done for awhile just very few people have made a controller to do this job most use very basic control's or none at all.
/*
Th./,e circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Pressure sensor is -
0 psi = 0.5v = 102.4
200 psi = 4.5v = 921.6 ///// 817?
Analog:
A0 – psisensor1
Digital:
D9 – compressor relay
D10 - concentrator vent
D0 - oxy con1
D1 - oxy con2
D6 - oxy con3
D7 - oxy con4
*/
// include the library code:
#include <Wire.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int psisensor1 = A0;
const int comprelay = 9;
const int convent = 10;
const int con1 = 0;
const int con2 = 1;
const int con3 = 6;
const int con4 = 7;
void setup() {
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.print(" GokuGlass Hvo!"); // line 0 label
lcd.setCursor(5, 1); // set cursor to line 1 column 5
lcd.print("Psi"); // psi label
pinMode(convent, OUTPUT); // -
pinMode(con1, OUTPUT); // -
pinMode(con2, OUTPUT); // defines pins as outputs
pinMode(con3, OUTPUT); // defines pins as outputs
pinMode(con4, OUTPUT); // -
}
void loop() {
float psisensor1 = (analogRead(A0) - 102) * 200.0 / 817; // gets psi reading
if(psisensor1 > 95) // if 95 psi or over turns cons & comp off
{
digitalWrite(convent, HIGH); // con vent before turning them off
digitalWrite(con1, LOW); // -
digitalWrite(con2, LOW); // cons off
digitalWrite(con3, LOW); // cons off
digitalWrite(con4, LOW); // -
digitalWrite(comprelay, LOW); // turn comp off
}
if(psisensor1 < 70) // if 70 psi or under turns cons and comp on
{
if (digitalread, comprelay) = LOW
{ digitalWrite(convent, HIGH); // con vent on so they have somewhere to push oxy while comp is off
digitalWrite(con1, HIGH); // -
digitalWrite(con2, HIGH); // cons on
digitalWrite(con3, HIGH); // cons on
digitalWrite(con4, HIGH); // -
delay (120000); // delay 2 mins to get to purity up
digitalWrite(convent, LOW); // con vent off
delay (250); // delay so its not instantly on
digitalWrite(comprelay, HIGH); // comp on after cons are at purity and con vent is off
}
else {
digitalWrite(con1, HIGH); // -
digitalWrite(con2, HIGH); // cons on
digitalWrite(con3, HIGH); // cons on
digitalWrite(con4, HIGH); // -
digitalWrite(comprelay, HIGH); // comp on
}
}
lcd.setCursor(9, 1); // set the cursor to column 9, line 1
lcd.print(psisensor1); // print the psireading
}