etb pwm limit (#3408)

* etb pwm limit

* missed an arg

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-10-25 12:35:23 -07:00 committed by GitHub
parent 53d16c67fe
commit 558a6d01fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -64,6 +64,11 @@ public:
// Clamp to >100hz
int clampedFrequency = maxI(100, frequency);
if (clampedFrequency > ETB_HW_MAX_FREQUENCY) {
firmwareError(OBD_PCM_Processor_Fault, "Electronic throttle frequency too high, maximum %d hz", ETB_HW_MAX_FREQUENCY);
return;
}
if (useTwoWires) {
m_pinEnable.initPin("ETB Enable", pinEnable);

View File

@ -177,10 +177,8 @@ public:
// If we have too few usable bits, we run out of resolution, so don't allow that either.
// 200 counts = 0.5% resolution
if (m_period < _2_MHZ / ETB_HW_MAX_FREQUENCY) {
firmwareError(CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high %d limit %d hz on pin \"%s\"", frequency,
ETB_HW_MAX_FREQUENCY,
msg);
if (m_period < 200) {
firmwareError(CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high %d hz on pin \"%s\"", frequency, msg);
return;
}

View File

@ -135,7 +135,7 @@ struct_no_prefix engine_configuration_s
#define TCU_GEAR_COUNT 10
! Matt says: The problem is the driver chip. Tle9201 can't do 20k. The drivers are too slow. On purpose to reduce EMI
#define ETB_HW_MAX_FREQUENCY 10000
#define ETB_HW_MAX_FREQUENCY 3000
#define ETB_COUNT 2
#define DC_PER_STEPPER 2