software:firmware
MakAir Firmware
pressure_valve.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 // INCLUDES ===================================================================
11 
12 // Internal libraries
13 #include "../includes/config.h"
14 #include "../includes/parameters.h"
15 
16 // MACROS =================================================================
17 
24 uint16_t valveAngle2MicroSeconds(uint16_t value);
25 
26 // CLASS =================================================================
27 
30  public:
32  PressureValve();
33 
43  PressureValve(HardwareTimer* p_hardwareTimer,
44  uint16_t p_timerChannel,
45  uint16_t p_valvePin,
46  uint16_t p_openApertureAngle,
47  uint16_t p_closeApertureAngle);
53  void setup();
54 
56  void open();
57 
63  void open(uint16_t p_command);
64 
71  uint16_t openLinear(uint16_t p_command);
72 
73  int32_t getSectionBigHoseX100();
74 
80  void openSection(int32_t p_sectionMultiplyBy100);
81 
83  void close();
84 
90  inline void execute() {
91  // On évite d'aller plus loin que les limites de la valve
92  if (command < minApertureAngle) {
94  } else if (command > maxApertureAngle) {
96  } else {
97  }
98 
99  if (command != position) {
101  MICROSEC_COMPARE_FORMAT);
102  position = command;
103  }
104  }
105 
107  inline uint16_t minAperture() const { return minApertureAngle; }
108 
110  inline uint16_t maxAperture() const { return maxApertureAngle; }
111 
113  uint16_t command;
114 
116  uint16_t position;
117 
119  uint16_t positionLinear;
120 
121  private:
124 
127 
130 
133 
135  HardwareTimer* actuator;
136 
138  uint16_t timerChannel;
139 
141  uint16_t valvePin;
142 };
143 
Controls a pressure valve.
uint16_t valvePin
Data pin for this valve.
uint16_t maxApertureAngle
Maximum valve aperture angle in degrees.
uint16_t closeApertureAngle
Close aperture angle in degrees.
void setup()
Initialize this valve.
uint16_t minAperture() const
Minimum valve aperture angle in degrees.
PressureValve()
Default constructor.
uint16_t openApertureAngle
Open aperture angle in degrees.
uint16_t command
Value of the requested aperture.
void openSection(int32_t p_sectionMultiplyBy100)
Request opening of the Pressure Valve with a given section (in mm^2)
uint16_t minApertureAngle
Minimum valve aperture angle in degrees.
int32_t getSectionBigHoseX100()
void execute()
Command the valve to go to the requested aperture.
void open()
Request opening of the Pressure Valve.
HardwareTimer * actuator
Hardware time for this valve.
uint16_t timerChannel
TIM channel for this valve.
uint16_t positionLinear
Current aperture linear.
uint16_t maxAperture() const
Maximum valve aperture angle in degrees.
void close()
Request closing of the Pressure Valve.
uint16_t position
Current aperture.
uint16_t openLinear(uint16_t p_command)
Request opening of the Pressure Valve with a given angle with linearization.
PressureValve inspiratoryValve
uint16_t valveAngle2MicroSeconds(uint16_t value)
Convert an angle in degrees to a value in microseconds for the valve controller.
PressureValve expiratoryValve