software:firmware
MakAir Firmware
vc_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 {
36  struct Alarms a = {0u, RCM_SW_2, RCM_SW_3, 0u, 0u, 0u,
37  0u, 0u, 0u, RCM_SW_10, RCM_SW_11, RCM_SW_12,
39  0u, RCM_SW_22, RCM_SW_23};
40  return a;
41  }
42 
43  private:
45  void calculateBlower();
46 
54  int32_t PCexpiratoryPID(int32_t targetPressure, int32_t currentPressure, int32_t dt);
55 
56  bool m_duringPlateau = true;
57 
59  uint16_t m_blowerSpeed;
60 
62 
65 
68 
71 
74 
77 
80 
83 
86 
89 
92 
95 
97  int32_t m_blowerTicks;
98 };
99 
#define RCM_SW_11
#define RCM_SW_12
#define RCM_SW_15
#define RCM_SW_3
#define RCM_SW_18
#define RCM_SW_23
#define RCM_SW_19
#define RCM_SW_16
#define RCM_SW_2
#define RCM_SW_22
#define RCM_SW_10
Controller for the Volume Controled mode.
uint16_t m_blowerSpeed
Current blower speed.
struct Alarms enabledAlarms() const override
List of alarms that must be enabled for this mode.
int32_t m_blowerTicks
Blower ticks.
void endCycle() override
End the current breathing cycle.
int32_t m_inspiratoryFlowLastValuesIndex
Last flow index.
void calculateBlower()
Determine the blower speed to adopt for 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.
VC_CMV_Controller()
Default constructor.
void exhale() override
Control the exhalation.
int32_t m_inspiratoryPidIntegral
Integral gain of the inspiratory PID.
int32_t m_expiratoryPidLastErrorsIndex
Last error index in expiratory PID.
void initCycle() override
Begin a new breathing cycle.
int32_t m_maxInspiratoryFlow
Max flow during inspiration.
int32_t m_expiratoryPidLastErrors[PC_NUMBER_OF_SAMPLE_DERIVATIVE_MOVING_MEAN]
Last errors in expiratory PID.
int32_t m_expiratoryPidIntegral
Integral gain of the expiratory PID.
void setup() override
Initialize controller.
bool m_expiratoryPidFastMode
Fast mode at start of expiration.
int32_t m_inspiratoryFlowLastValues[NUMBER_OF_SAMPLE_LAST_VALUES]
Last flow values.
int32_t m_expiratoryPidLastError
Error of the last computation of the PID.
int32_t m_expiratoryValveLastAperture
Last aperture of the blower valve.
int32_t m_targetFlowMultiplyBy1000
int32_t m_inspiratoryValveLastAperture
Last aperture of the inspiratory valve.
void inhale() override
Control the inhalation.
Abstract class for ventilation controllers.
#define NUMBER_OF_SAMPLE_LAST_VALUES
Definition: parameters.h:154
#define PC_NUMBER_OF_SAMPLE_DERIVATIVE_MOVING_MEAN
Definition: parameters.h:152
List of alarms (named by their code)
VC_CMV_Controller vcCmvController