throttle model runs a little bit

This commit is contained in:
Matthew Kennedy 2023-03-14 20:49:47 -07:00
parent cffc8e851f
commit 2ba3881ba0
3 changed files with 17 additions and 3 deletions

View File

@ -93,8 +93,12 @@ float ThrottleModelBase::estimateThrottleFlow(float tip, float tps, float map, f
// What throttle position gives us that flow at 0.95 PR?
float throttleAngle95Pr = throttlePositionForFlow(p95Flow, crossoverPr, tip, iat);
throttleModelCrossoverAngle = throttleAngle95Pr;
if (tps > throttleAngle95Pr) {
bool useWotModel = tps > throttleAngle95Pr;
throttleUseWotModel = useWotModel;
if (useWotModel) {
// "WOT" model
// Maximum flow if the throttle was removed
@ -128,6 +132,10 @@ expected<float> ThrottleModelBase::estimateThrottleFlow(float map, float tps) {
return estimateThrottleFlow(tip.Value, tps, map, iat.Value);
}
void ThrottleModelBase::onSlowCallback() {
throttleEstimatedFlow = estimateThrottleFlow(Sensor::getOrZero(SensorType::Map), Sensor::getOrZero(SensorType::Tps1)).value_or(0);
}
float ThrottleModel::effectiveArea(float tps) const {
return interpolate2d(tps, config->throttleEstimateEffectiveAreaBins, config->throttleEstimateEffectiveAreaValues);
}

View File

@ -2,8 +2,10 @@
#include "throttle_model_generated.h"
struct ThrottleModelBase : public throttle_model_s {
struct ThrottleModelBase : public throttle_model_s, public EngineModule {
public:
void onSlowCallback() override;
float estimateThrottleFlow(float tip, float tps, float map, float iat);
expected<float> estimateThrottleFlow(float map, float tps);

View File

@ -1,3 +1,7 @@
struct_no_prefix throttle_model_s
bit throttleUseWotModel
int16_t autoscale throttleModelCrossoverAngle;;"%", 0.01, 0, 0, 100, 1
float throttleEstimatedFlow;;"kg/s", 1, 0, 0, 5, 4
end_struct