static const unsigned long EVACUATION_LONG_MS = 600000;
static const unsigned long EVACUATION_MS = 60000;
+static const unsigned int THREEWAY_TURNS_TO_FILL = 3;
+
static const float MEASUREMENT_UPPER_LIMIT = 8;
static const float MEASUREMENT_LOWER_LIMIT = 0.5;
+void threeway_fill(Valve &threeway_valve, unsigned int count)
+{
+ while (count > 0)
+ {
+ threeway_valve.close();
+ threeway_valve.open();
+ --count;
+ }
+ threeway_valve.close();
+}
+
+// The gas valve needs special treatment, because it is threeway.
+// Let's say open means cell-side and closed means gas-side
void main_loop()
{
PressureSensor sensor_1{PRESSURE_SENSOR1_PIN, 10};
Measurement measurement{sensor_1};
Valve vacuum_valve{VACUUM_VALVE_PIN, 760, 2400};
CellValve cell_valve{CELL_VALVE_PIN, 760, 1600, 2400};
- Valve gas_valve{GAS_VALVE_PIN, 760, 2400};
+ Valve gas_threeway_valve{GAS_VALVE_PIN, 760, 2400};
+ vacuum_valve.close();
+ cell_valve.close();
+ gas_threeway_valve.open();
while (1)
{
while (!interrupt_happened && digitalRead(SWITCH_PIN) == HIGH)
{
// aparature initialization - valve positioning, evacuation
- cell_valve.open_barely();
vacuum_valve.open();
+ gas_threeway_valve.open();
+ cell_valve.open_barely();
delay(CELL_BARELY_OPEN_EQUILIBRATION_MS);
cell_valve.open();
cell_valve.close_open_clean();
&& sensor_1.get_pressure() < MEASUREMENT_UPPER_LIMIT)
{
// absorption cycle
- gas_valve.open();
- gas_valve.close_open_clean();
- gas_valve.close();
+ threeway_fill(gas_threeway_valve, THREEWAY_TURNS_TO_FILL);
cell_valve.open_barely();
delay(CELL_BARELY_OPEN_EQUILIBRATION_MS);
cell_valve.open();