Commit 1bea8410 by RBO lab

removes psi model, adds documentation of the massflow controller interface,…

removes psi model, adds documentation of the massflow controller interface, removes unnecessary calibration mode code
parent 90981d20
......@@ -171,72 +171,36 @@ inline bool IsClientCompatible(uint32_t clientApiVersion)
//massflow signals
const AirServerSignal BLOCK_SIGNALS_MASS_FLOW= BLOCK_SIGNALS_SENSOR +0x40;
const AirServerSignal SIGNAL_MASS_DESIRED_0 = BLOCK_SIGNALS_MASS_FLOW;
const AirServerSignal SIGNAL_MASS_DELTA_PRESSURE_0= BLOCK_SIGNALS_MASS_FLOW +1;
const AirServerSignal SIGNAL_MASS_LINEAR_0 = BLOCK_SIGNALS_MASS_FLOW +2;
const AirServerSignal SIGNAL_MASS_LEECO_0 = BLOCK_SIGNALS_MASS_FLOW +3;
const AirServerSignal SIGNAL_MASS_PSI_0 = BLOCK_SIGNALS_MASS_FLOW +4;
const AirServerSignal SIGNAL_MASS_0 = BLOCK_SIGNALS_MASS_FLOW +5;
const AirServerSignal SIGNAL_MASS_FLOW_LINEAR_0 = BLOCK_SIGNALS_MASS_FLOW +6;
const AirServerSignal SIGNAL_MASS_FLOW_LEECO_0 = BLOCK_SIGNALS_MASS_FLOW +7;
const AirServerSignal SIGNAL_MASS_FLOW_PSI_0 = BLOCK_SIGNALS_MASS_FLOW +8;
const AirServerSignal SIGNAL_MASS_FLOW_0 = BLOCK_SIGNALS_MASS_FLOW +9;
const AirServerSignal SIGNAL_MASS_DESIRED_1 = BLOCK_SIGNALS_MASS_FLOW +10;
const AirServerSignal SIGNAL_MASS_DELTA_PRESSURE_1= BLOCK_SIGNALS_MASS_FLOW +11;
const AirServerSignal SIGNAL_MASS_LINEAR_1 = BLOCK_SIGNALS_MASS_FLOW +12;
const AirServerSignal SIGNAL_MASS_LEECO_1 = BLOCK_SIGNALS_MASS_FLOW +13;
const AirServerSignal SIGNAL_MASS_PSI_1 = BLOCK_SIGNALS_MASS_FLOW +14;
const AirServerSignal SIGNAL_MASS_1 = BLOCK_SIGNALS_MASS_FLOW +15;
const AirServerSignal SIGNAL_MASS_FLOW_LINEAR_1 = BLOCK_SIGNALS_MASS_FLOW +16;
const AirServerSignal SIGNAL_MASS_FLOW_LEECO_1 = BLOCK_SIGNALS_MASS_FLOW +17;
const AirServerSignal SIGNAL_MASS_FLOW_PSI_1 = BLOCK_SIGNALS_MASS_FLOW +18;
const AirServerSignal SIGNAL_MASS_FLOW_1 = BLOCK_SIGNALS_MASS_FLOW +19;
const AirServerSignal SIGNAL_MASS_DESIRED_2 = BLOCK_SIGNALS_MASS_FLOW +20;
const AirServerSignal SIGNAL_MASS_DELTA_PRESSURE_2= BLOCK_SIGNALS_MASS_FLOW +21;
const AirServerSignal SIGNAL_MASS_LINEAR_2 = BLOCK_SIGNALS_MASS_FLOW +22;
const AirServerSignal SIGNAL_MASS_LEECO_2 = BLOCK_SIGNALS_MASS_FLOW +23;
const AirServerSignal SIGNAL_MASS_PSI_2 = BLOCK_SIGNALS_MASS_FLOW +24;
const AirServerSignal SIGNAL_MASS_2 = BLOCK_SIGNALS_MASS_FLOW +25;
const AirServerSignal SIGNAL_MASS_FLOW_LINEAR_2 = BLOCK_SIGNALS_MASS_FLOW +26;
const AirServerSignal SIGNAL_MASS_FLOW_LEECO_2 = BLOCK_SIGNALS_MASS_FLOW +27;
const AirServerSignal SIGNAL_MASS_FLOW_PSI_2 = BLOCK_SIGNALS_MASS_FLOW +28;
const AirServerSignal SIGNAL_MASS_FLOW_2 = BLOCK_SIGNALS_MASS_FLOW +29;
const AirServerSignal SIGNAL_MASS_DESIRED_3 = BLOCK_SIGNALS_MASS_FLOW +30;
const AirServerSignal SIGNAL_MASS_DELTA_PRESSURE_3= BLOCK_SIGNALS_MASS_FLOW +31;
const AirServerSignal SIGNAL_MASS_LINEAR_3 = BLOCK_SIGNALS_MASS_FLOW +32;
const AirServerSignal SIGNAL_MASS_LEECO_3 = BLOCK_SIGNALS_MASS_FLOW +33;
const AirServerSignal SIGNAL_MASS_PSI_3 = BLOCK_SIGNALS_MASS_FLOW +34;
const AirServerSignal SIGNAL_MASS_3 = BLOCK_SIGNALS_MASS_FLOW +35;
const AirServerSignal SIGNAL_MASS_FLOW_LINEAR_3 = BLOCK_SIGNALS_MASS_FLOW +36;
const AirServerSignal SIGNAL_MASS_FLOW_LEECO_3 = BLOCK_SIGNALS_MASS_FLOW +37;
const AirServerSignal SIGNAL_MASS_FLOW_PSI_3 = BLOCK_SIGNALS_MASS_FLOW +38;
const AirServerSignal SIGNAL_MASS_FLOW_3 = BLOCK_SIGNALS_MASS_FLOW +39;
const AirServerSignal SIGNAL_MASS_DESIRED_4 = BLOCK_SIGNALS_MASS_FLOW +40;
const AirServerSignal SIGNAL_MASS_DELTA_PRESSURE_4= BLOCK_SIGNALS_MASS_FLOW +41;
const AirServerSignal SIGNAL_MASS_LINEAR_4 = BLOCK_SIGNALS_MASS_FLOW +42;
const AirServerSignal SIGNAL_MASS_LEECO_4 = BLOCK_SIGNALS_MASS_FLOW +43;
const AirServerSignal SIGNAL_MASS_PSI_4 = BLOCK_SIGNALS_MASS_FLOW +44;
const AirServerSignal SIGNAL_MASS_4 = BLOCK_SIGNALS_MASS_FLOW +45;
const AirServerSignal SIGNAL_MASS_FLOW_LINEAR_4 = BLOCK_SIGNALS_MASS_FLOW +46;
const AirServerSignal SIGNAL_MASS_FLOW_LEECO_4 = BLOCK_SIGNALS_MASS_FLOW +47;
const AirServerSignal SIGNAL_MASS_FLOW_PSI_4 = BLOCK_SIGNALS_MASS_FLOW +48;
const AirServerSignal SIGNAL_MASS_FLOW_4 = BLOCK_SIGNALS_MASS_FLOW +49;
const AirServerSignal SIGNAL_MASS_DESIRED_5 = BLOCK_SIGNALS_MASS_FLOW +50;
const AirServerSignal SIGNAL_MASS_DELTA_PRESSURE_5= BLOCK_SIGNALS_MASS_FLOW +51;
const AirServerSignal SIGNAL_MASS_LINEAR_5 = BLOCK_SIGNALS_MASS_FLOW +52;
const AirServerSignal SIGNAL_MASS_LEECO_5 = BLOCK_SIGNALS_MASS_FLOW +53;
const AirServerSignal SIGNAL_MASS_PSI_5 = BLOCK_SIGNALS_MASS_FLOW +54;
const AirServerSignal SIGNAL_MASS_5 = BLOCK_SIGNALS_MASS_FLOW +55;
const AirServerSignal SIGNAL_MASS_FLOW_LINEAR_5 = BLOCK_SIGNALS_MASS_FLOW +56;
const AirServerSignal SIGNAL_MASS_FLOW_LEECO_5 = BLOCK_SIGNALS_MASS_FLOW +57;
const AirServerSignal SIGNAL_MASS_FLOW_PSI_5 = BLOCK_SIGNALS_MASS_FLOW +58;
const AirServerSignal SIGNAL_MASS_FLOW_5 = BLOCK_SIGNALS_MASS_FLOW +59;
const AirServerSignal SIGNAL_MASS_DESIRED_0 = BLOCK_SIGNALS_MASS_FLOW +0;
const AirServerSignal SIGNAL_MASS_LINEAR_0 = BLOCK_SIGNALS_MASS_FLOW +1;
const AirServerSignal SIGNAL_MASS_LEECO_0 = BLOCK_SIGNALS_MASS_FLOW +2;
const AirServerSignal SIGNAL_MASS_0 = BLOCK_SIGNALS_MASS_FLOW +3;
const AirServerSignal SIGNAL_MASS_DESIRED_1 = BLOCK_SIGNALS_MASS_FLOW +4;
const AirServerSignal SIGNAL_MASS_LINEAR_1 = BLOCK_SIGNALS_MASS_FLOW +5;
const AirServerSignal SIGNAL_MASS_LEECO_1 = BLOCK_SIGNALS_MASS_FLOW +6;
const AirServerSignal SIGNAL_MASS_1 = BLOCK_SIGNALS_MASS_FLOW +7;
const AirServerSignal SIGNAL_MASS_DESIRED_2 = BLOCK_SIGNALS_MASS_FLOW +8;
const AirServerSignal SIGNAL_MASS_LINEAR_2 = BLOCK_SIGNALS_MASS_FLOW +9;
const AirServerSignal SIGNAL_MASS_LEECO_2 = BLOCK_SIGNALS_MASS_FLOW +10;
const AirServerSignal SIGNAL_MASS_2 = BLOCK_SIGNALS_MASS_FLOW +11;
const AirServerSignal SIGNAL_MASS_DESIRED_3 = BLOCK_SIGNALS_MASS_FLOW +12;
const AirServerSignal SIGNAL_MASS_LINEAR_3 = BLOCK_SIGNALS_MASS_FLOW +13;
const AirServerSignal SIGNAL_MASS_LEECO_3 = BLOCK_SIGNALS_MASS_FLOW +14;
const AirServerSignal SIGNAL_MASS_3 = BLOCK_SIGNALS_MASS_FLOW +15;
const AirServerSignal SIGNAL_MASS_DESIRED_4 = BLOCK_SIGNALS_MASS_FLOW +16;
const AirServerSignal SIGNAL_MASS_LINEAR_4 = BLOCK_SIGNALS_MASS_FLOW +17;
const AirServerSignal SIGNAL_MASS_LEECO_4 = BLOCK_SIGNALS_MASS_FLOW +18;
const AirServerSignal SIGNAL_MASS_4 = BLOCK_SIGNALS_MASS_FLOW +19;
const AirServerSignal SIGNAL_MASS_DESIRED_5 = BLOCK_SIGNALS_MASS_FLOW +20;
const AirServerSignal SIGNAL_MASS_LINEAR_5 = BLOCK_SIGNALS_MASS_FLOW +21;
const AirServerSignal SIGNAL_MASS_LEECO_5 = BLOCK_SIGNALS_MASS_FLOW +22;
const AirServerSignal SIGNAL_MASS_5 = BLOCK_SIGNALS_MASS_FLOW +23;
/*valve activation signals
......@@ -475,10 +439,38 @@ const eMessageType MSGTYPE_BROADCAST8 = 0x304; //reply message that
/*
Configures a Massflow Controller
in_desired: set the desired mass flow
out_inflate: signal to the valve responsible for inflating
out_deflate: signal to the valve responsible for deflating
pressure_supply: pressure at the inlet of the inflating valve (usually the supply pressure)
pressure_out: pressure at the outlet of the inflating valve (the channel pressure)
mass_desired: current estimate of the desired mass
mass_linear: current estimate of the channel mass, linear term
mass_leeco: current estimate of the channel mass, injector term
mass: current estimate of the channel mass by the mass observer
c_inf,
c_inf_linear,
c_inf_leeco,
c_inf_Psupp,
c_inf_Pact: coefficients of the mass observer for the inflation path
c_def
c_def_linear
c_def_leeco
c_def_Psupp
c_def_Pact: coefficients of the mass observer for the deflation path
inf_threshold: mass error to tolerate before triggering inflation. Should be as small as possible but larger than the smallest possible mass change of the hardware
inf_threshold: mass error to tolerate before triggering deflation. Should be as small as possible but larger than the smallest possible mass change of the hardware
*/
typedef struct {
HeaderConfigurationMsgs header_config;
AirServerSignal in_desired;
AirServerSignal out_inflate;
AirServerSignal out_deflate;
......@@ -486,18 +478,10 @@ const eMessageType MSGTYPE_BROADCAST8 = 0x304; //reply message that
AirServerSignal pressure_out;
AirServerSignal mass_desired;
AirServerSignal delta_pressure;
AirServerSignal mass_linear;
AirServerSignal mass_leeco;
AirServerSignal mass_psi;
AirServerSignal mass;
AirServerSignal mass_flow_linear;
AirServerSignal mass_flow_leeco;
AirServerSignal mass_flow_psi;
AirServerSignal mass_flow;
AirServerSignalValue c_inf;
AirServerSignalValue c_inf_linear;
......
......@@ -120,36 +120,26 @@ namespace AirserverController{
AirServerSignal pressure_supply;
AirServerSignal pressure_out;
// for offline analyses even though
// high sampled data already offers that
// with pressure supply and pressure out
AirServerSignal delta_pressure;
// the desired air mass in the actuator,
// equals zero at controller start
AirServerSignal mass_desired;
// the estimated air mass in the actuator as per multiple models
// equals zero at controller start
//If you want to monitor the estimates, set these signals to something other than SIGNAL_NONE
AirServerSignal mass_linear;
AirServerSignal mass_leeco;
AirServerSignal mass_psi;
AirServerSignal mass; // models and parameters combined
// current mass flow as per multiple models
AirServerSignal mass_flow_linear;
AirServerSignal mass_flow_leeco;
AirServerSignal mass_flow_psi;
AirServerSignal mass_flow; // models combined
// linear regression coefficients
// The next block specificies a list of coefficients to configure the mass observer model
// These parameters need to be calibrated for a given hardware.
// inflation:
AirServerSignalValue c_inf; // constant for each inflation, leap when valve opens
AirServerSignalValue c_inf_linear; // scaling factor for linear air mass flow model
AirServerSignalValue c_inf_leeco; // scaling factor for air mass flow model as per Lee Company
AirServerSignalValue c_inf_Psupp; // scaling factor for supply pressure at inflation start,
// results in a constant for each inflation,
// valve opening time might be influenced by supply pressure
AirServerSignalValue c_inf_Psupp; // scaling factor for supply pressure at inflation start, results in a constant for each inflation, valve opening time might be influenced by supply pressure
AirServerSignalValue c_inf_Pact; // scaling factor for actuator pressure at inflation start,
// results in a constant for each inflation
// deflation:
......@@ -159,12 +149,13 @@ namespace AirserverController{
AirServerSignalValue c_def_Psupp;
AirServerSignalValue c_def_Pact;
// air mass difference from desired value to start an inflation / deflation
//The next two parameters specify the hysteresis around the desired mass, inflation and deflation are only started when exiting the band.
//Set this as low as possible given the minimal change of air mass possible by the hardware
AirServerSignalValue inf_threshold;
AirServerSignalValue def_threshold;
// environment pressure:
float P_ENV= 103; //kPa
// nominal environment pressure:
float P_ENV= 101.3; //kPa
// error between mass desired
// and current in-/deflated mass
......
/*
* Massflow controller: actuate channel according to a signal:
* Mass flow controller: actuate channel according to a signal:
*
*
* Author: Raphael
......@@ -9,8 +9,6 @@
#include <iostream>
#include <math.h>
// valves are activated
#define MASSFLOW_SWITCH
namespace AirserverController{
......@@ -27,7 +25,6 @@ namespace AirserverController{
pressure_supply= conf->pressure_supply;
pressure_out = conf->pressure_out;
delta_pressure= conf->delta_pressure;
// the desired air mass in the actuator,
// equals zero at controller start
......@@ -37,16 +34,8 @@ namespace AirserverController{
// equals zero at controller start
mass_linear= conf->mass_linear;
mass_leeco = conf->mass_leeco;
mass_psi = conf->mass_psi;
mass = conf->mass; // models and parameters combined
// current mass flow as per multiple models
mass_flow_linear= conf->mass_flow_linear;
mass_flow_leeco = conf->mass_flow_leeco;
mass_flow_psi = conf->mass_flow_psi;
mass_flow = conf->mass_flow; // models combined
// coefficients to combine multiple mass flow models
// and parameters to one mass flow resp. one delta air mass
// for current step
......@@ -72,7 +61,6 @@ namespace AirserverController{
SetData( mass_linear, 0.0 );
SetData( mass_leeco , 0.0 );
SetData( mass_psi , 0.0 );
SetData( mass , 0.0 );
std::cout <<"[MASSFLOW CTRL] Coeff: " << std::endl
......@@ -173,7 +161,6 @@ namespace AirserverController{
SetData( mass_linear, 0.0);
SetData( mass_leeco , 0.0);
SetData( mass_psi , 0.0);
SetData( mass , 0.0);
return EXIT_SUCCESS;
......@@ -183,7 +170,6 @@ namespace AirserverController{
// current massflow for multiple models
float mf_curr_linear = 0.0;
float mf_curr_leeco = 0.0;
float mf_curr_psi = 0.0;
float mf_curr = 0.0;
// error can change in each step
......@@ -205,8 +191,7 @@ namespace AirserverController{
// compute current mass flow
mf_curr_linear= MFLinearModel( GetData(pressure_supply), P_out, c_inf_linear);
mf_curr_leeco = MFLeeCompanyModel( GetData(pressure_supply), P_out, c_inf_leeco );
mf_curr_psi = MFPSIModel( GetData(pressure_supply), P_out, 1.0);
// combination of above model:
// combination of above models:
mf_curr = mf_curr_leeco + mf_curr_linear;
// Constant error is added once when inflation is started,.
}
......@@ -216,7 +201,6 @@ namespace AirserverController{
// pressure out = 0
mf_curr_linear= MFLinearModel( P_out, 0.0, c_def_linear);
mf_curr_leeco = MFLeeCompanyModel( P_out, 0.0, c_def_leeco);
mf_curr_psi = MFPSIModel( P_out, 0.0, -1.0);
// scaled combination of above models:
mf_curr = mf_curr_leeco + mf_curr_linear;
// Constants are added once to mass when deflation is started.
......@@ -232,7 +216,6 @@ namespace AirserverController{
float delta_mass_linear= mf_curr_linear* PERIOD_S;
float delta_mass_leeco = mf_curr_leeco * PERIOD_S;
float delta_mass_psi = mf_curr_psi * PERIOD_S;
float delta_mass = mf_curr * PERIOD_S;
// U P D A T E M A S S
......@@ -248,26 +231,16 @@ namespace AirserverController{
// update air mass from last time step with current massflow
float mass_new_linear = GetData(mass_linear)+ delta_mass_linear;
float mass_new_leeco = GetData(mass_leeco) + delta_mass_leeco;
float mass_new_psi = GetData(mass_psi) + delta_mass_psi;
float mass_new = GetData(mass) + delta_mass; // combines models
// T R A C K S I G N A L S
SetData( delta_pressure, GetData(pressure_supply)-GetData(pressure_out) );
// track mass in actuator for client according to linear model
SetData( mass_linear, mass_new_linear );
SetData( mass_flow_linear, mf_curr_linear);
// track mass in actuator for client according to nonlinear model
SetData( mass_leeco, mass_new_leeco );
SetData( mass_flow_leeco, mf_curr_leeco);
SetData( mass_psi, mass_new_psi );
SetData( mass_flow_psi, mf_curr_psi);
// track mass according to both models
SetData( mass, mass_new );
SetData( mass_flow, mf_curr );
// E V A L U A T E E R R O R
// calculate current error:
......@@ -280,10 +253,8 @@ namespace AirserverController{
// -1*1 = 1* -1 < 0
// 1*1 =-1* -1 > 0
#ifdef MASSFLOW_SWITCH
SetData(out_inflate, 0.0);
SetData(out_deflate, 0.0);
#endif
SetData(out_inflate, 0.0);
SetData(out_deflate, 0.0);
}
if( (this->error <= inf_threshold)
......@@ -301,7 +272,7 @@ namespace AirserverController{
//S T A R T I N F L A T E
// only when mass desired rises
if(GetData(in_desired) >= 0) {
// if(GetData(in_desired) >= 0) {
// add constants for inflation model when inflation starts
if(GetData(out_inflate) == 0) {
......@@ -312,18 +283,16 @@ namespace AirserverController{
mass_new += GetData(pressure_out) * c_inf_Pact;
SetData( mass, mass_new );
}
#ifdef MASSFLOW_SWITCH
SetData(out_inflate, 1.0);
SetData(out_deflate, 0.0);
#endif
} //else: just let mass desired catch up with current mass
SetData(out_inflate, 1.0);
SetData(out_deflate, 0.0);
// } //else: just let mass desired catch up with current mass
} else {
// mass higher than desired
//S T A R T D E F L A T E
// only when mass desired falls
if( GetData(in_desired) <= 0) {
// if( GetData(in_desired) <= 0) {
// add constants deflation model when deflation starts
if(GetData(out_deflate) == 0) {
......@@ -333,11 +302,9 @@ namespace AirserverController{
mass_new += GetData(pressure_out) * c_def_Pact;
SetData( mass, mass_new );
}
#ifdef MASSFLOW_SWITCH
SetData(out_deflate, 1.0);
SetData(out_inflate, 0.0);
#endif
}// else: just let mass desired catch up with current mass
SetData(out_deflate, 1.0);
SetData(out_inflate, 0.0);
// }// else: just let mass desired catch up with current mass
} // error in-/outside tolerance checking
} // error threshold checking
......
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