Merge pull request #340 from mark99i/dev_fw_5_03

Fixes in traction control for scooters
This commit is contained in:
Benjamin Vedder 2021-10-01 09:49:08 +02:00 committed by GitHub
commit 6f1b674e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -34,6 +34,7 @@
#define MIN_MS_WITHOUT_POWER 500
#define FILTER_SAMPLES 5
#define RPM_FILTER_SAMPLES 8
#define TC_DIFF_MAX_PASS 60 // TODO: move to app_conf
// Threads
static THD_FUNCTION(adc_thread, arg);
@ -541,6 +542,8 @@ static THD_FUNCTION(adc_thread, arg) {
}
float diff = rpm_tmp - rpm_lowest;
if (diff < TC_DIFF_MAX_PASS) diff = 0;
if (diff > config.tc_max_diff) diff = config.tc_max_diff;
current_out = utils_map(diff, 0.0, config.tc_max_diff, current_rel, 0.0);
}
@ -554,6 +557,8 @@ static THD_FUNCTION(adc_thread, arg) {
if (config.tc) {
float diff = rpm_local - rpm_lowest;
if (diff < TC_DIFF_MAX_PASS) diff = 0;
if (diff > config.tc_max_diff) diff = config.tc_max_diff;
current_out = utils_map(diff, 0.0, config.tc_max_diff, current_rel, 0.0);
}
}