Put wake up sequence out of measurement loop
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 26 Nov 2024 10:07:34 +0000 (11:07 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 26 Nov 2024 10:13:18 +0000 (11:13 +0100)
Before this change the long evacuation would happen every time the
program switched from desorption to absorption measurement. Now it only
happens when turned on.

Servomatic.ino

index 01787b6bbaa8305cb214bae198e57f3028e00fe7..7e59678f34b7d274da8dce53d25ac4e0e8959df6 100644 (file)
@@ -51,19 +51,20 @@ void        main_loop()
        gas_threeway_valve.open();
        while (1)
        {
+               if (!interrupt_happened && digitalRead(SWITCH_PIN) == HIGH)
+               // aparature initialization - valve positioning, evacuation
+               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();
+               vacuum_valve.close_open_clean();
+               interruptable_delay(EVACUATION_LONG_MS);
+               vacuum_valve.close();
+               cell_valve.close();
                while (!interrupt_happened && digitalRead(SWITCH_PIN) == HIGH)
                {
-                       // aparature initialization - valve positioning, evacuation
-                       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();
-                       vacuum_valve.close_open_clean();
-                       interruptable_delay(EVACUATION_LONG_MS);
-                       vacuum_valve.close();
-                       cell_valve.close();
                        while (!interrupt_happened
                                        && sensor_1.get_pressure() < MEASUREMENT_UPPER_LIMIT)
                        {
@@ -72,8 +73,6 @@ void  main_loop()
                                cell_valve.open_barely();
                                delay(CELL_BARELY_OPEN_EQUILIBRATION_MS);
                                cell_valve.open();
-                               measurement.get_measurement();
-                               cell_valve.close_open_clean();
                                measurement.wait_for_equilibrium(0.01);
                                measurement.clear();
                                cell_valve.close();
@@ -89,8 +88,6 @@ void  main_loop()
                                cell_valve.open_barely();
                                delay(CELL_BARELY_OPEN_EQUILIBRATION_MS);
                                cell_valve.open();
-                               measurement.get_measurement();
-                               cell_valve.close_open_clean();
                                measurement.wait_for_equilibrium(0.01);
                                measurement.clear();
                                cell_valve.close();