mirror of https://github.com/rusefi/bldc.git
Merge pull request #726 from luna-cycle/pas_torque_sensor_safety_improvement
Pas torque sensor safety improvement
This commit is contained in:
commit
20d311e189
|
@ -35,7 +35,8 @@
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
#define PEDAL_INPUT_TIMEOUT 0.2
|
#define PEDAL_INPUT_TIMEOUT 0.2
|
||||||
#define MAX_MS_WITHOUT_CADENCE 5000
|
#define MAX_MS_WITHOUT_CADENCE_OR_TORQUE 5000
|
||||||
|
#define MAX_MS_WITHOUT_CADENCE 1000
|
||||||
#define MIN_MS_WITHOUT_POWER 500
|
#define MIN_MS_WITHOUT_POWER 500
|
||||||
#define FILTER_SAMPLES 5
|
#define FILTER_SAMPLES 5
|
||||||
#define RPM_FILTER_SAMPLES 8
|
#define RPM_FILTER_SAMPLES 8
|
||||||
|
@ -164,6 +165,7 @@ void pas_event_handler(void) {
|
||||||
pedal_rpm = 60.0 / period_filtered;
|
pedal_rpm = 60.0 / period_filtered;
|
||||||
pedal_rpm *= (direction_conf * (float)direction_qem);
|
pedal_rpm *= (direction_conf * (float)direction_qem);
|
||||||
inactivity_time = 0.0;
|
inactivity_time = 0.0;
|
||||||
|
correct_direction_counter = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inactivity_time += 1.0 / (float)config.update_rate_hz;
|
inactivity_time += 1.0 / (float)config.update_rate_hz;
|
||||||
|
@ -253,10 +255,21 @@ static THD_FUNCTION(pas_thread, arg) {
|
||||||
ms_without_cadence_or_torque = 0.0;
|
ms_without_cadence_or_torque = 0.0;
|
||||||
} else {
|
} else {
|
||||||
ms_without_cadence_or_torque += (1000.0 * (float)sleep_time) / (float)CH_CFG_ST_FREQUENCY;
|
ms_without_cadence_or_torque += (1000.0 * (float)sleep_time) / (float)CH_CFG_ST_FREQUENCY;
|
||||||
if(ms_without_cadence_or_torque > MAX_MS_WITHOUT_CADENCE) {
|
if(ms_without_cadence_or_torque > MAX_MS_WITHOUT_CADENCE_OR_TORQUE) {
|
||||||
output = 0.0;
|
output = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if cranks are not moving, there should not be any output. This covers the case of a torque sensor
|
||||||
|
// stuck with a non-zero signal.
|
||||||
|
static float ms_without_cadence = 0.0;
|
||||||
|
if(pedal_rpm < 0.01) {
|
||||||
|
ms_without_cadence += (1000.0 * (float)sleep_time) / (float)CH_CFG_ST_FREQUENCY;
|
||||||
|
if(ms_without_cadence > MAX_MS_WITHOUT_CADENCE) {
|
||||||
|
output = 0.0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ms_without_cadence = 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -280,7 +280,7 @@
|
||||||
#define APPCONF_PAS_INVERT_PEDAL_DIRECTION 0
|
#define APPCONF_PAS_INVERT_PEDAL_DIRECTION 0
|
||||||
|
|
||||||
// Sensor Magnets
|
// Sensor Magnets
|
||||||
#define APPCONF_PAS_MAGNETS 12
|
#define APPCONF_PAS_MAGNETS 48
|
||||||
|
|
||||||
// Use Filter
|
// Use Filter
|
||||||
#define APPCONF_PAS_USE_FILTER 1
|
#define APPCONF_PAS_USE_FILTER 1
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef HW_LUNA_M600_H_
|
#ifndef HW_LUNA_M600_H_
|
||||||
#define HW_LUNA_M600_H_
|
#define HW_LUNA_M600_H_
|
||||||
|
|
||||||
#define FW_NAME "2023.12.13"
|
#define FW_NAME "2024.05.08"
|
||||||
|
|
||||||
#ifdef M600_60V_BATTERY
|
#ifdef M600_60V_BATTERY
|
||||||
#include "mcconf_luna_m600_60V.h"
|
#include "mcconf_luna_m600_60V.h"
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include "mcpwm_foc.h" // for encoder angle error
|
#include "mcpwm_foc.h" // for encoder angle error
|
||||||
|
|
||||||
#define LUNA_TORQUE_SENSOR_DEFAULT_TORQUE 0x02EE
|
#define LUNA_TORQUE_SENSOR_DEFAULT_TORQUE 0x02EE
|
||||||
#define LUNA_TORQUE_SENSOR_MINIMUM_TORQUE 0x0360
|
#define LUNA_TORQUE_SENSOR_MINIMUM_TORQUE 0x044C
|
||||||
#define LUNA_TORQUE_SENSOR_MAXIMUM_TORQUE 0x0600
|
#define LUNA_TORQUE_SENSOR_MAXIMUM_TORQUE 0x0600
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
Loading…
Reference in New Issue