13 #include "../includes/pressure_valve.h"
19 #include "../includes/parameters.h"
31 uint16_t p_timerChannel,
33 uint16_t p_openApertureAngle,
34 uint16_t p_closeApertureAngle) {
60 int32_t cappedSectionMultiplyBy100 =
62 min(max(int32_t(0), p_sectionMultiplyBy100), int32_t(3318));
65 if (cappedSectionMultiplyBy100 < 1960) {
66 tempCommand = 98 - (318 * cappedSectionMultiplyBy100 / 10000);
69 2626 - (36 * cappedSectionMultiplyBy100) / 10
70 + 168 * ((cappedSectionMultiplyBy100 * cappedSectionMultiplyBy100) / 100) / 1000
72 * (((cappedSectionMultiplyBy100 * cappedSectionMultiplyBy100) / 100)
73 * (cappedSectionMultiplyBy100) / 100)
82 uint16_t cappedCommand =
91 uint32_t intermediateValue =
92 (((
static_cast<uint32_t
>(cappedCommand) * 75u) / 125u) + 30u) * 10u;
125 (((76u * intermediateValue) / 10u)
126 - (((985u * intermediateValue) * intermediateValue) / 100000u)
127 + (((((44u * intermediateValue) * intermediateValue) / 1000u) * intermediateValue)
144 section = 5760u - (558u *
command / 10u);
149 return max(int32_t(0), section);
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.
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 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.
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