Commit 37788480 by RBO lab

fix desired flow integration, be defensive when comparing valve state

parent 72be16c1
......@@ -184,15 +184,13 @@ namespace AirserverController{
//Compute the current desired mass from either desired massflow or just use a user-supplied value:
if (config.in_desired_massflow != SIGNAL_NONE) {
float delta_mass_desired = GetData(config.in_desired_massflow) * PERIOD_S;
desired_mass = + delta_mass_desired;
desired_mass += GetData(config.in_desired_massflow) * PERIOD_S;
} else if (config.in_desired_mass != SIGNAL_NONE) {
desired_mass = GetData(config.in_desired_mass); //else just get value from a signal
} else {
desired_mass = 0.;
}
// E V A L U A T E E R R O R
// calculate current error:
this->error= desired_mass - observer_mass_estimate;
......@@ -208,13 +206,12 @@ namespace AirserverController{
}
if( (this->error <= config.c_inflation_threshold) && (this->error >= config.c_deflation_threshold) ) {// I N S I D E T O L E R A N C E S
return EXIT_SUCCESS;
} else { // O U T S I D E T O L E R A N C E S
if( this->error > 0 ) { // mass is lower than desired -> start to inflate
if (config.out_inflate != SIGNAL_NONE) {
out_inflation_valvestate = GetData(config.out_inflate); //make sure to use real out state
}
if(out_inflation_valvestate == 0) {
if(out_inflation_valvestate < 0.5) {
// Add constant inflation error at inflation start
float mass_bias = config.c_inflate;
mass_bias += GetData(config.pressure_supply) * config.c_inflate_Psupply;
......@@ -229,7 +226,7 @@ namespace AirserverController{
out_deflation_valvestate = GetData(config.out_deflate); //make sure to use real out state
}
// add constants deflation model when deflation starts
if(GetData(out_deflation_valvestate) == 0) {
if(GetData(out_deflation_valvestate) < 0.5) {
float mass_bias = config.c_deflate;
mass_bias += GetData(config.pressure_supply) * config.c_deflate_Psupply;
mass_bias += GetData(config.pressure_out) * config.c_deflate_Pout;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment