Add "barely opened" position to Valve class
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 18 Nov 2024 09:08:26 +0000 (10:08 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 18 Nov 2024 09:08:26 +0000 (10:08 +0100)
When measuring solubility of gasses in liquids, opening of the valve and
the resulting movement of gas may upset the level of the liquid to the
point of blowing droplets somewhere, where they cause problems (mainly
weighing of the sample after measurement).
Opening the Valve barely to make equilibration of the pressures take
more time should prevent the violent gas flow.

Servomatic.ino
Valve.h
Valve.ino

index 697f4acd8cb49f92241ee4162db9d2b7fff7c0ea..368bc603a36264c048b59bfcd2a9274d794655d9 100644 (file)
@@ -24,7 +24,7 @@ int   main()
 void   main_loop()
 {
        PressureSensor  sensor_1{PRESSURE_SENSOR1_PIN, 10};
-       Valve                   test_valve{6, 760, 2400};
+       Valve                   test_valve{6, 760, 1600, 2400};
        int                             usec;
        Measurement             measurement{sensor_1};
 
diff --git a/Valve.h b/Valve.h
index ab4a9155723dd222c09860e67637d8399976ddcd..f0f514fb81737a889df1c371f6bb8d66b444c71d 100644 (file)
--- a/Valve.h
+++ b/Valve.h
@@ -10,6 +10,7 @@ class Valve
 
                const Servo     m_servo;
                const int       m_usec_opened;
+               const int       m_usec_barely_opened;
                const int       m_usec_closed;
                int                     m_usec_current;
 
@@ -19,12 +20,14 @@ class Valve
        public:
                Valve() = delete;
                Valve(const Valve &other) = delete;
-               Valve(pin pwm_pin, int usec_opened, int isec_closed);
+               Valve(pin pwm_pin, int usec_opened, int usec_barely_opened,
+                               int isec_closed);
                ~Valve();
 
                Valve   &operator=(const Valve &other) = delete;
 
                void    open(float seconds = 5);
+               void    open_barely(float seconds = 5);
                void    close(float seconds = 5);
 };
 
index 19542c1e689d5b05560889b3523ed1947867f332..13cb83cc39ddf0dd3558e9a8bfc4f44d6df76e3e 100644 (file)
--- a/Valve.ino
+++ b/Valve.ino
@@ -1,8 +1,9 @@
 #include "Valve.h"
 
-Valve::Valve(pin pwm_pin, int usec_opened, int usec_closed)
+Valve::Valve(pin pwm_pin, int usec_opened, int usec_barely_opened, int usec_closed)
        : m_servo{}
        , m_usec_opened{usec_opened}
+       , m_usec_barely_opened{usec_barely_opened}
        , m_usec_closed{usec_closed}
        , m_usec_current{usec_closed}
 {
@@ -49,13 +50,16 @@ void        Valve::write_usec_timed(int usec_wanted, float seconds)
 void   Valve::open(float seconds)
 {
        write_usec_timed(m_usec_opened, seconds);
-       //m_servo.writeMicroseconds(760);
+}
+
+void   Valve::open_barely(float seconds)
+{
+       write_usec_timed(m_usec_barely_opened, seconds);
 }
 
 void   Valve::close(float seconds)
 {
        write_usec_timed(m_usec_closed, seconds);
-       //m_servo.writeMicroseconds(2400);
 }
 
 void   Valve::update_pos()