diff --git a/flash.sh b/flash.sh old mode 100755 new mode 100644 diff --git a/scripts/compile_and_dfu_hardware_v3.sh b/scripts/compile_and_dfu_hardware_v3.sh old mode 100755 new mode 100644 diff --git a/scripts/compile_and_flash.sh b/scripts/compile_and_flash.sh old mode 100755 new mode 100644 diff --git a/scripts/compile_only.sh b/scripts/compile_only.sh old mode 100755 new mode 100644 diff --git a/srcs/pc_cmv_controller.cpp b/srcs/pc_cmv_controller.cpp index 2c8f4353..79b2fd37 100644 --- a/srcs/pc_cmv_controller.cpp +++ b/srcs/pc_cmv_controller.cpp @@ -109,14 +109,13 @@ void PC_CMV_Controller::inhale() { void PC_CMV_Controller::exhale() { // Close the inspiratory valve - inspiratoryValve.open(VALVE_CLOSED_STATE-PCexpiratoryPID(mainController.pressureCommand(), + inspiratoryValve.open(-PCexpiratoryPID(mainController.pressureCommand(), mainController.pressure(), mainController.dt())); // Open the expiratos valve so the patient can exhale outside // expiratoryValve.open(PCexpiratoryPID(mainController.pressureCommand(), // mainController.pressure(), mainController.dt())); } - void PC_CMV_Controller::endCycle() { calculateBlowerIncrement(); } void PC_CMV_Controller::calculateBlowerIncrement() { diff --git a/srcs/pressure_valve.cpp b/srcs/pressure_valve.cpp index d4dec7e5..5cb4f3d4 100644 --- a/srcs/pressure_valve.cpp +++ b/srcs/pressure_valve.cpp @@ -17,9 +17,9 @@ // Internal libraries #include "../includes/parameters.h" +#include "Arduino.h" // INITIALISATION ============================================================= - PressureValve expiratoryValve; PressureValve inspiratoryValve; @@ -145,21 +145,30 @@ void PressureValve::openSection(int32_t p_sectionMultiplyBy100) { } void PressureValve::execute() { + + // Position milieu - les deux vannes sont ouvertes + int Pos_dxl_valve_open = 2048 ; + // Position vanne expiratoire fermée + int Pos_dxl_exp_valve_closed = 2300; + // Position vanne insipratoire fermée + int Pos_dxl_insp_valve_closed = 1800; + // On évite d'aller plus loin que les limites de la valve - if (command < minApertureAngle) { - command = minApertureAngle; - } else if (command > maxApertureAngle) { + if (command > maxApertureAngle) { command = maxApertureAngle; - } else { + } + else { } if (command != position) { //Serial.println((4095*(position-maxApertureAngle))/(maxApertureAngle-minApertureAngle)); - dxl_Position((4095*(position-minApertureAngle))/(maxApertureAngle-minApertureAngle)); + dxl_Position(Pos_dxl_valve_open+((Pos_dxl_exp_valve_closed-Pos_dxl_valve_open)*position/maxApertureAngle)); position = command; } } + + void PressureValve::open() { command = openApertureAngle; } void PressureValve::close() { command = closeApertureAngle; } diff --git a/srcs/srcs.ino b/srcs/srcs.ino index 2d80c39e..a40beb7b 100644 --- a/srcs/srcs.ino +++ b/srcs/srcs.ino @@ -44,7 +44,7 @@ HardwareTimer* hardwareTimer1; // ESC command HardwareTimer* hardwareTimer3; // valves command -HardwareSerial Serial6(PIN_TELEMETRY_SERIAL_RX, PIN_TELEMETRY_SERIAL_TX); +HardwareSerial Serial6(PIN_TELEMETRY_SERIAL_RX, PIN_TELEMETRY_SERIAL_TX); HardwareSerial Serial7(PC6); void setup(void) {