software:firmware
MakAir Firmware
pc_cmv_controller.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "../includes/parameters.h"
11 #include "../includes/ventilation_controller.h"
12 
15  public:
18 
20  void setup() override;
21 
23  void initCycle() override;
24 
26  void inhale() override;
27 
29  void exhale() override;
30 
32  void endCycle() override;
33 
35  struct Alarms enabledAlarms() const override {
37  RCM_SW_6, RCM_SW_7, 0u, 0u, 0u,
40  RCM_SW_23};
41  return a;
42  }
43 
44  private:
47 
50 
53 
61  int32_t PCinspiratoryPID(int32_t targetPressure, int32_t currentPressure, int32_t dt);
62 
70  int32_t PCexpiratoryPID(int32_t targetPressure, int32_t currentPressure, int32_t dt);
71 
73  uint16_t m_blowerSpeed;
74 
77 
80 
83 
86 
89 
92 
95 
102 
109 };
110 
#define RCM_SW_11
#define RCM_SW_20
#define RCM_SW_12
#define RCM_SW_15
#define RCM_SW_3
#define RCM_SW_5
#define RCM_SW_18
#define RCM_SW_23
#define RCM_SW_19
#define RCM_SW_6
#define RCM_SW_16
#define RCM_SW_1
#define RCM_SW_14
#define RCM_SW_4
#define RCM_SW_21
#define RCM_SW_2
#define RCM_SW_22
#define RCM_SW_7
Controller for the CMV mode.
int32_t m_expiratoryPidLastError
Error of the last computation of the expiratory PID.
int32_t m_inspiratoryPidLastError
Error of the last computation of the expiratory PID.
uint16_t m_blowerSpeed
Current blower speed.
bool m_expiratoryPidFastMode
Fast mode at start of expiration.
int32_t m_inspiratoryPidIntegral
Error of the last computation of the blower PID.
PC_CMV_Controller()
Default constructor.
int32_t m_expiratoryValveLastAperture
Last aperture of the blower valve.
void initCycle() override
Begin a new breathing cycle.
int32_t m_expiratoryPidIntegral
Integral gain of the patient PID.
int32_t m_inspiratoryPidLastErrorsIndex
Last error index in inspiratory PID.
void inhale() override
Control the inhalation.
int32_t m_inspiratoryPidLastErrors[PC_NUMBER_OF_SAMPLE_DERIVATIVE_MOVING_MEAN]
Last errors in inspiratory PID.
bool m_inspiratoryPidFastMode
Fast mode at start of inspiration.
void setup() override
Initialize controller.
int32_t m_expiratoryPidLastErrors[PC_NUMBER_OF_SAMPLE_DERIVATIVE_MOVING_MEAN]
Last errors in expiratory PID.
struct Alarms enabledAlarms() const override
List of alarms that must be enabled for this mode.
uint16_t m_plateauStartTime
Number of ticks when plateau is reached for the first time.
void exhale() override
Control the exhalation.
int32_t m_blowerIncrement
Current blower speed increment (to apply at the beginning of the next cycle)
int32_t PCexpiratoryPID(int32_t targetPressure, int32_t currentPressure, int32_t dt)
PID to control the patient valve during some specific steps of the cycle.
int32_t m_expiratoryPidLastErrorsIndex
Last error index in inspiratory PID.
bool m_plateauPressureReached
True if plateau pressure has been reached (but not necessarily converged)
int32_t PCinspiratoryPID(int32_t targetPressure, int32_t currentPressure, int32_t dt)
PID to control the blower valve during some specific steps of the cycle.
void endCycle() override
End the current breathing cycle.
void calculateBlowerIncrement()
Determine the blower speed to adopt for next cycle.
int32_t m_inspiratoryValveLastAperture
Last aperture of the blower valve.
Abstract class for ventilation controllers.
#define PC_NUMBER_OF_SAMPLE_DERIVATIVE_MOVING_MEAN
Definition: parameters.h:152
PC_CMV_Controller pcCmvController
List of alarms (named by their code)