Oxygen concentration system help

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
}

K20IN303:
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.

Noted, doesn't sound like you need that speech.

I'll just note the "interesting" combination of an inexperienced programmer, a hobbyist-quality processor board, and high-pressure, flammable gas.

I imagine it could be argued that oxygen is technically not "flammable" itself. But, other things really like to burn when it's present in copious quantity.

Replace:

if (digitalread, comprelay) = LOW

With:
if ((digitalread, comprelay) == LOW)

if (digitalRead(comprelay) == LOW)

But first thing first, you need to fix your indentation. Code format is more important than the code itself. To fix it: Crt+A to select All -> Crt+T to auto indent

So what is not working so far?

arduino_new:
Replace:

if (digitalread, comprelay) = LOW

With:

if ((digitalread, comprelay) == LOW)

But first thing first, you need to fix your indentation. Code format is more important than the code itself. To fix it: Crt+A to select All -> Crt+T to auto indent

No, its

if (digitalRead (comprelay) == LOW)

// or

if (! digitalRead (comprelay))  // if not comprelay...

gfvalvo:
Noted, doesn't sound like you need that speech.

I'll just note the "interesting" combination of an inexperienced programmer, a hobbyist-quality processor board, and high-pressure, flammable gas.

I imagine it could be argued that oxygen is technically not "flammable" itself. But, other things really like to burn when it's present in copious quantity.

I understand the inexperienced programmer part, this has been the most difficult part of the project. The hobbyist quality board part i plan on getting everything working properly then removing the chip and making a board with everything on one board wired properly but is there really a problem with using a arduino chip on the final project?

Oxygen in itself is not flammable but it is a accelerant.. This is much better then my previous setup witch was a 180liter liquid oxygen dewar in my shop venting to atmosphere anytime im not working don't you think? Sometimes it is the name of the game in this profession...

arduino_new:
Replace:

if (digitalread, comprelay) = LOW

With:

if ((digitalread, comprelay) == LOW)

But first thing first, you need to fix your indentation. Code format is more important than the code itself. To fix it: Crt+A to select All -> Crt+T to auto indent

Good to know i wasn't aware that was a thing i made this all without using that feature. That was the exact section i was having a problem compiling just thought i was missing something.

zoomkat:
So what is not working so far?

It was giving me a error compiling in that section but i wanted to get some experienced peoples advice on the project.

MarkT:
No, its

if (digitalRead (comprelay) == LOW)

// or

if (! digitalRead (comprelay))  // if not comprelay...

Ok i will try this when i get back from work today, it was giving me errors but i rewrote that section at work before i posted it to the forum. Something didn't seem right in that section but wanted to see if anyone seen more problems with the project that i wasn't seeing

K20IN303:
but is there really a problem with using a arduino chip on the final project?

Designing processor-controlled systems for Life / Mission / Safety - Critical applications is a very involved, specialized engineering task. There are fail-safe and redundancy considerations for both hardware and software. It requires components screened to higher reliability levels.

You don’t see many Arduino-controlled autopilots, at least not in certified aircraft. The experimental aircraft field is more wild and wooly, but has no paying passengers.

gfvalvo:
Designing processor-controlled systems for Life / Mission / Safety - Critical applications is a very involved, specialized engineering task. There are fail-safe and redundancy considerations for both hardware and software. It requires components screened to higher reliability levels.

You don’t see many Arduino-controlled autopilots, at least not in certified aircraft. The experimental aircraft field is more wild and wooly, but has no paying passengers.

Hopefully only a proof-of-concept not to be used on human subjects. I would certainly not rely on it.

K20IN303:
Something to note, i know oxygen and oil is a big nono and have taken all the precautions

By "all the precautions" have you performed a fault tree analysis to ensure the proper software and hardware interlocks to prevent dangerous over-pressurization or other hazards? To ensure that you can detect a fault in critical sensors? (like using redundant sensors, etc) Power on self test to ensure the integrity of hardware? Continuous test to ensure the same during operation?

All things to consider when designing a safety-critical system.

gfvalvo:
Designing processor-controlled systems for Life / Mission / Safety - Critical applications is a very involved, specialized engineering task. There are fail-safe and redundancy considerations for both hardware and software. It requires components screened to higher reliability levels.

You don’t see many Arduino-controlled autopilots, at least not in certified aircraft. The experimental aircraft field is more wild and wooly, but has no paying passengers.

ToddL1962:
Hopefully only a proof-of-concept not to be used on human subjects. I would certainly not rely on it.

By "all the precautions" have you performed a fault tree analysis to ensure the proper software and hardware interlocks to prevent dangerous over-pressurization or other hazards? To ensure that you can detect a fault in critical sensors? (like using redundant sensors, etc) Power on self test to ensure the integrity of hardware? Continuous test to ensure the same during operation?

All things to consider when designing a safety-critical system.

Wow if only i knew you guys were going to be so critical without knowing anything about the systems... What happens when the pump over pressure's the tank? NOTHING the pump will only pump till 110 psi before it stalls out(storage tank is fine till 200psi and there is a pop off valve at 125 psi). It is only a 1.2 cfm 1700 rpm pump rated to 90 psi that is not going to cause harm to anything. What happens is the solenoid fails and stays open all the time? Nothing dangerous, the oxygen will be vented to atmosphere, again will cause no damage(exp with my well ventilated room moving 2500 cfm of air through it) the purity of the tank will decrease and cause a colder flame that will be noticed instantly... What other hazards can happen? The only thing that would cause a problem is introducing oil to the system and mixing it with oxygen and high pressure... Simple solution, use a oil free compressor and insure all tanks and lines are free of oil.. Oxygen is regularly compressed to 3000+ psi without any problems so if pressure on pump even were to exceed 150 psi what problem can arise?... NONE

Has anyone here ever heard of a homefill oxygen unit? Fills tanks at home to 3000 psi and is fine to run for days on end maybe you should hunt down all the old ladies and tell them how dangerous there at home oxygen system is..

Thanks to the people that actually helped, you are greatly appreciated

"Designing processor-controlled systems for Life / Mission / Safety - Critical applications is a very involved, specialized engineering task. There are fail-safe and redundancy considerations for both hardware and software. It requires components screened to higher reliability levels."

So, just where did you get that the project is "Life / Mission / Safety - Critical application"? Maybe switch to decaf. Not much different than using electrolysis to get H2 and O2 for various projects.

K20IN303:
Wow if only i knew you guys were going to be so critical without knowing anything about the systems...

Not being critical. Just pointing out that it would be ill-advised to use hobbyist-quality hardware and sketchy software in a control system where failure of said system could cause highly-undesirable results. If you, as the design engineer, are qualified and authorized to make the determination that's not the case, then have at it.

K20IN303:
Has anyone here ever heard of a homefill oxygen unit? Fills tanks at home to 3000 psi and is fine to run for days on end

Are such systems run by micro-controllers? If so, who designed the hardware and software? What qualifications do they possess? What procedures (if any) were required to ensure that failures of the system do not cause catastrophic results? What testing was done? The plaintiff's lawyers will surely ask such questions.

Are you using the oxygen for lampworking? I have extensive experience using 2nd hand medical oxygen concentrators for this purpose. I used concentrators directly plumbed into my torch (GTT Mirage) for the first 4 years and never noticed a difference in the flame on startup compared to after the concentrators had been running for a while.

For the last 15 years, I've switched to a system with the concentrators running into an oil-free compressor which boosts the pressure into a storage tank. This is able to easily provide all the O2 I need for my GTT Delta Mag and GTT Cheetah hand torch running full blast at the same time, and can even keep up reasonably well with the GTT Mirage running at the same time. I love having O2 on demand any time and not having to deal with getting tanks delivered.

Based on my knowledge of how the concentrators work, I wouldn't expect any significant difference in oxygen purity in the first 2 minutes. Have you noticed this being a problem? The only possible hypothesis I could make for this would be that maybe the zeolite works better at a higher temperature so it needs time to heat up. But again, I have not noticed this with concentrators starting at temperatures in the 20F range.

As far as the safety thing goes, if you're going to stick with regularly venting for 2 minutes, I would go ahead and vent the O2 outside. With your system, it will be easy enough to run a hose out a window or through a hole in the wall.

And if people are nervous about that little O2, they would not enjoy being present when a liquid dewar of O2 vents!

pert:
Are you using the oxygen for lampworking? I have extensive experience using 2nd hand medical oxygen concentrators for this purpose. I used concentrators directly plumbed into my torch (GTT Mirage) for the first 4 years and never noticed a difference in the flame on startup compared to after the concentrators had been running for a while.

For the last 15 years, I've switched to a system with the concentrators running into an oil-free compressor which boosts the pressure into a storage tank. This is able to easily provide all the O2 I need for my GTT Delta Mag and GTT Cheetah hand torch running full blast at the same time, and can even keep up reasonably well with the GTT Mirage running at the same time. I love having O2 on demand any time and not having to deal with getting tanks delivered.

Based on my knowledge of how the concentrators work, I wouldn't expect any significant difference in oxygen purity in the first 2 minutes. Have you noticed this being a problem? The only possible hypothesis I could make for this would be that maybe the zeolite works better at a higher temperature so it needs time to heat up. But again, I have not noticed this with concentrators starting at temperatures in the 20F range.

As far as the safety thing goes, if you're going to stick with regularly venting for 2 minutes, I would go ahead and vent the O2 outside. With your system, it will be easy enough to run a hose out a window or through a hole in the wall.

And if people are nervous about that little O2, they would not enjoy being present when a liquid dewar of O2 vents!

Yes i am using it for lamp working, i run a herbert arnold 40mm torch. The 2 minute delay is something i will be adjusting, my buddy that has a regular system he build with a time delay relay. He was big on setting a 2 minute delay before turning on the pump to get them up to the highest purity so i started with that but figured a would tweak it a little.

I uploaded the program as is and it reads the pressure fine but it seems to be stuck going to the else section, the digital read portion may not be reading the relay HIGH or LOW. It is keeping the convent relay on at all times with a psi reading at 0.44 psi

I put a section in the code to

lcdprint "on1" in the comprelay = low
lcdprint "on 2" in the comprelay = high
in the psi sensor > 95 i put a lcdprint "off"

So this way i will know what segment of the code it is at, it seems it is stuck in the else segment because it reads "on2" but the convent relay is stuck on and there is no code in that section for it to be on. The only section for it to be on is the comprelay = low but right after it comes on the con 1 - 4 should come on as well but they are not.

Any idea what is going on here? I am kinda lost why it is not registering the comprelay = high or low and continuing in that section

K20IN303:
Any idea what is going on here? I am kinda lost why it is not registering the comprelay = high or low and continuing in that section

Psst - we can't see your code.

Here is the new code with lcd prints off/on1/on2

/*
   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:
         D10 – compressor relay
		     D13 - concentrator vent
		     D6 - oxy con1
		     D7 - oxy con2
	       D8 - oxy con3
         D9 - 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 = 10;
const int convent = 13;
const int con1 = 6;
const int con2 = 7;
const int con3 = 8;
const int con4 = 9;


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
    lcd.setCursor(0, 1);                  // set the cursor to column 0, line 1
    lcd.print("Off");                      // print the psireading
  }
  if (psisensor1 < 70)                   // if 70 psi or under turns cons and comp on
  {
    if (digitalRead (comprelay) == HIGH) {
      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 (5000);                 // 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
      lcd.setCursor(0, 1);                  // set the cursor to column 0, line 1
      lcd.print("On1");                      // print the psireading
    }
    else {
      digitalWrite(con1, HIGH);       // -
      digitalWrite(con2, HIGH);       // cons on
      digitalWrite(con3, HIGH);       // cons on
      digitalWrite(con4, HIGH);       // -
      digitalWrite(comprelay, HIGH);  // comp on
      lcd.setCursor(0, 1);                  // set the cursor to column 0, line 1
      lcd.print("On2");                      // print the psireading
    }
  }
  lcd.setCursor(9, 1);                        // set the cursor to column 9, line 1
  lcd.print(psisensor1);                      // print the psireading
}

delay (5000); Not two minutes.

Do you have a question?

oops was trying to diagnose what was going on and changed it to 5 sec, changed my code to be correct at 2 mins although i may still change the time that they are purging to get the purity up

TheMemberFormerlyKnownAsAWOL:
delay (5000); Not two minutes.

Do you have a question?

Anyone have any idea why is is sticking in digital read else section?

I was thinking instead of digital read to put a wire jumping from comprelay to an analog input so it registers when the voltage is high or low instead

instead of this

if (digitalRead (comprelay) == HIGH)

jump a wire from comprealy (d10) to a1

if (analogRead (a1) == HIGH)

It seems to me it cant read from high or low while using d10 as a output. Should the arduino be able to read high or low and write to the same digital output?

The only reason i have added the digital read section is so it does not go thru a loop of venting the con and restarting the relays. Every time it sees psi under 70 if it is on already it just continues running cons and compressor till it gets to 90. From the first time it sees the psi under 70 and starts the loop till it gets to 90 may take 5 to 10 minutes depending on use

You never set comprelay as an output.

K20IN303:
I was thinking instead of digital read to put a wire jumping from comprelay to an analog input so it registers when the voltage is high or low instead

No, that's not necessary.

K20IN303:
instead of this

if (digitalRead (comprelay) == HIGH)

jump a wire from comprealy (d10) to a1

if (analogRead (a1) == HIGH)

As I said this is not necessary, but just FYI:

  • The pin name is A1, not a1.
  • You don't use HIGH and LOW with analogRead. analogRead returns a value between 0 and 1023.
  • It's silly to use analogRead to get a digital reading.
  • You can use digitalRead with the analog pins. They can be used as normal digital pins, they just have the extra characteristic of being able to do analog readings as well.

K20IN303:
Should the arduino be able to read high or low and write to the same digital output?

Yes, you can do this. More efficient would be to use a global or static variable to track the state of the pin:

byte comprelayState;

...

comprelayState = HIGH;
digitalWrite(comprelay, comprelayState);

...

if(comprelayState == HIGH) {

but for this application, code efficiency is likely not a big concern, so go with whatever you prefer.