Controlling pressure from a CO2 Cartridge

I'm trying to harness the pressure from a CO2 cartridge using a combination of analog pressure sensors and open/closed valves. My problem is that the chamber where pressure from the CO2 cartridge hikes up its pressure and I need to reduce it without releasing much CO2 and maintaining the internal pressure of the other chambers. The sensors are ASDX100PAAA5s and the valves are Parker 312-000007-03 (12V)s. The microcontroller I'm using is a Teensy 4.1.

Please post the code, using code tags and a schematic showing the wiring details.

What should the program do, and what does it do instead?

Google doesn't know ASDX100PAAA5 sensors.
Searching at Parker.com does not give a result for 312-000007-03
This is the Teensy 4.1: https://www.pjrc.com/store/teensy41.html

Sorry, the Parker valves' model number is 912-000007-003 and the Honeywell sensors' model number is ASDXACX100PAAA5.

Here is the code:

#include <Wire.h>
#include <Adafruit_GFX.h> //Include libraries for different components
#include <Adafruit_SSD1306.h>

//Setup for OLED:
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define SysValve 37
#define ExitValve 36
#define DistValve 35
#define MidValve 34
#define ProxValve 33

#define SysTarget 23
#define DistTarget 23
#define MidTarget 23
#define ProxTarget 23

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Wire.begin();

  pinMode(SysValve, OUTPUT);  //Setting the output pins to the valves:
  pinMode(ExitValve, OUTPUT);
  pinMode(DistValve, OUTPUT);
  pinMode(MidValve, OUTPUT);
  pinMode(ProxValve, OUTPUT);

  pinMode(A0, INPUT); //Setting input pins from sensors
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A3, INPUT);

  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
   display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
}

void loop() {


      digitalWrite(ExitValve, LOW);   //Reset all valves to closed:
  digitalWrite(SysValve, LOW);
  digitalWrite(DistValve, LOW);
  digitalWrite(MidValve, LOW);
  digitalWrite(ProxValve, LOW);
  
  int ProxRead=analogRead(A0);
  int DistRead=analogRead(A2); //Sensor readings
  int MidRead=analogRead(A1);
  int SysRead=analogRead(A3);

  int SysPSI= SysRead/(222/14.7);
  int DistPSI= DistRead/(222/14.7);
  int MidPSI= MidRead/(222/14.7);
  int ProxPSI= ProxRead/(222/14.7);

  display.clearDisplay(); //Display setup
  display.setCursor(0,0);

  display.print(F("System Pressure: ")); //Displaying sensor readings:
  display.println(SysPSI);
  display.print(F("Distal Pressure: "));
  display.println(DistPSI);
  display.print(F("Middle Pressure: "));
  display.println(MidPSI);
  display.print(F("Proximal Pressure: "));
  display.println(ProxPSI);
  display.display();  

       if (SysPSI<SysTarget) { // If the pressure is lower than desired pressure let air in:
        digitalWrite(ExitValve, LOW);
        digitalWrite(SysValve, HIGH);
      }
      if (DistPSI<DistTarget) {
        digitalWrite(ExitValve, LOW);
        digitalWrite(DistValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }
      if (MidPSI<MidTarget) {
        digitalWrite(ExitValve, LOW);
        digitalWrite(MidValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }
      if (ProxPSI<ProxTarget) {
        digitalWrite(ExitValve, LOW);
        digitalWrite(ProxValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }
      
      if (SysPSI>SysTarget) {
        digitalWrite(ExitValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }
      if (DistPSI>DistTarget) {  // If the pressure is higher than desired pressure let air out:
        digitalWrite(SysValve, LOW);
        digitalWrite(ExitValve, HIGH);
        digitalWrite(DistValve, HIGH);
      }
      if (MidPSI>MidTarget) {
        digitalWrite(SysValve, LOW);
        digitalWrite(ExitValve, HIGH);
        digitalWrite(MidValve, HIGH);
      }
      if (ProxPSI>ProxTarget) {
        digitalWrite(SysValve, LOW);
        digitalWrite(ExitValve, HIGH);
        digitalWrite(ProxValve, HIGH);
      }

     

      if (SysPSI>SysTarget) {
        digitalWrite(ExitValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }
      if (SysPSI>SysTarget) {
        digitalWrite(ExitValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }if (SysPSI>SysTarget) {
        digitalWrite(ExitValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }if (SysPSI>SysTarget) {
        digitalWrite(ExitValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }if (SysPSI>SysTarget) {
        digitalWrite(ExitValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }if (SysPSI>SysTarget) {
        digitalWrite(ExitValve, HIGH);
        digitalWrite(SysValve, HIGH);
      }

  delay(25);
    
  
}

Currently I'm opening the Exhaust valve and System valve several times before a delay but even then it has trouble keeping up with the CO2 cartridge.

I can't find the ASDXACX100PAAA5 on a Honeywell website, but it is at mouser with a datasheet.
It is a 5V 100 psi analog output 0.5 - 4.5 pressure sensor.

The Manufacturer of the valve redirects me here: https://ph.parker.com/us/12051/en/x-valve-miniature-pneumatic-solenoid-valve, but after a lot of trial and error, and I can not get the right number. I'm guessing it is a 24V 100psi valve, but I'm not sure.
[UPDATE] Found it, it is here: https://ph.parker.com/us/en/x-valve-miniature-pneumatic-solenoid-valve/912-000007-003.
It is a 12V, bi-directional, normally closed valve.
I don't know the difference between these two:

Application Pressure Requirement: 30 psi (.030" orifice)
Operating Pressure: 0 to 100 psi

You need a reducing valve.

Dunno if you can find one with the right specs or if you could do it DIY yourself.

a7

You might try measuring, then (if a valve needs to be opened) open and close the valve as fast as possible,* loop and measure again. Maybe you can make it "smart" and if you're far-off you can open the valve a little longer.

[quote]and I need to reduce it without releasing much CO2 [/quote]Well, what else are you going to do? I the pressure is too high you have to release the required amount of gas. (The only other way to reduce the pressure is to reduce the temperature...)

*The time it takes to open and re-close a valve is probably determined by the inertia/mechanics of the valve. I'd guess nothing will happen with a short-pulse from the Arduino.

A quick google search tells us the nominal pressure of a CO2 cartridge is 850 PSI.

Your valve is limited to 100 PSI and your sensor only goes to 100 PSI.

The valve quoted response time: "as low as 20 ms" Which it means it is >20 ms. I'll guess the minimum open time is >> 20ms.

You might get by if you have an extremely small hole throttling the CO2 flow. And you get a different solenoid valve.

You could look at the technology associated with PCP air rifles.

Good luck............