Hey, this is my first post so sorry in advance for errors in my post. Also a very intermediate in C++ so bear with me.
I'm trying to build a vacuum monitoring system for two chambers, I have sourced small scale components at the start and will scale up later.
My component list consists of this:
- Vacuum pump
- 3-way electronic valve
- 2 FSR (force-sensitive resistors)
- manual switch (for one vacuum region)
- proximity sensor ( for other vacuum regions)
My truth table:
Input Output
FSR-1 |FSR-2|MSwitch|ProxSens VacumPump | 3 way valve
1 0 0 0 1 1
0 1 0 0 1 0
0 0 1 0 1 1
0 0 0 0 1 0
0 0 0 0 0 0
The operation of the systems works as follows.
when the manual switch is pressed the vacuum pump would start from atmospheric to maximum vacuum. this is done by turning on the 3-way valve and pump until the pressure reaches maximum.
Pressure is monitored by FSR1 which triggers pump and 3-way valve to maintain pressure and set presure range.
when the proximity sensor is triggered it turns on pump from atmospheric pressure to pump down to maximum vacuum. FSR 2 maintains pressure and triggers pump in the selected region
I'm using a ESP32 due to the fact I can future proof it for Bluetooth later.
here is my code as follows, instead of prox sensor I used current sensor for now.
const int Carfsr = 34; //pin link for car side FSR
const int Phonefsr = 35; //pin link for phone side FSR
const int QiwirelessI = 32; //pink link for Qi wireless chearger
const int Threeway = 27; //pin link for 3 way electronic valve
const int PumpL = 26; // pin link for Pump
const int Mswitch = 25; // manual switch
int Cfsrvalue = 0; // setting value for car side to start at 0
int Pfsrvalue = 0; // setting value for phone side to start at 0
void setup()
{
Serial.begin(115200);
delay(1000);
// Setting pins I/O mode
pinMode(Threeway, OUTPUT);
pinMode(PumpL, OUTPUT);
pinMode(Mswitch, INPUT);
pinMode(QiwirelessI, INPUT);
// Setting pin state
digitalWrite(Threeway, LOW);
digitalWrite(PumpL, LOW);
digitalWrite(Mswitch, LOW);
digitalWrite(QiwirelessI, HIGH);
}
void loop()
{
// Manual switch reading
int ManualS = digitalRead(Mswitch);
// Qi wireless charger current sensor trigger reading
int QwirelessA = digitalRead(QiwirelessI);
// Presure reading from car side
Cfsrvalue = analogRead(Carfsr);
// Presure reading from phone side
Pfsrvalue = analogRead(Phonefsr);
// if both car and phone presure is low
if ( Pfsrvalue >= 250 && Pfsrvalue <=3800 && Cfsrvalue >= 3000 && Cfsrvalue <= 3800)
{
digitalWrite(Threeway, HIGH);
delay(10);
digitalWrite(PumpL, HIGH);
}
// if both manual switch and phone is on
if( ManualS == HIGH && QwirelessA == LOW)
{
digitalWrite(Threeway, HIGH);
delay(10);
digitalWrite(PumpL, HIGH);
}
// manual switch pump trigger
if( ManualS == HIGH )
{
digitalWrite(Threeway, HIGH);
delay(10);
digitalWrite(PumpL, HIGH);
}
// wireless charger current senese pump trigger
if (QwirelessA == LOW)
{
digitalWrite(PumpL, HIGH);
}
// on condtions for car presure
if(Cfsrvalue >= 3000 || Cfsrvalue <= 3800)
{
digitalWrite(Threeway,HIGH);
delay(10);
digitalWrite(PumpL, HIGH);
}
//on conditons for phone side
if(Pfsrvalue >= 250 || Pfsrvalue<=3800)
{
digitalWrite(PumpL, HIGH);
}
Serial.println(Cfsrvalue);
Serial.println(Pfsrvalue);
Serial.println(ManualS);
Serial.println(QwirelessA);
}
I think there are flaws with my current approach to programming this as this doesn't work.
any suggestions would be appreciated.