From: Lukáš Jiřiště Date: Mon, 18 Nov 2024 09:08:26 +0000 (+0100) Subject: Add "barely opened" position to Valve class X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=066a6e67d6ae3d4f6176abac1c88d8ba216bbeab;p=Servomatic.git Add "barely opened" position to Valve class 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. --- diff --git a/Servomatic.ino b/Servomatic.ino index 697f4ac..368bc60 100644 --- a/Servomatic.ino +++ b/Servomatic.ino @@ -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 ab4a915..f0f514f 100644 --- 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); }; diff --git a/Valve.ino b/Valve.ino index 19542c1..13cb83c 100644 --- 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()