steps towards dual ETB

This commit is contained in:
rusefi 2019-11-27 22:07:36 -05:00
parent 0006d93b8a
commit 067aa0aeee
4 changed files with 20 additions and 16 deletions

View File

@ -76,6 +76,7 @@
#include "bluetooth.h"
#include "tunerstudio_io.h"
#include "tooth_logger.h"
#include "electronic_throttle.h"
#include <string.h>
#include "engine_configuration.h"
@ -256,7 +257,7 @@ static void onlineApplyWorkingCopyBytes(int currentPageId, uint32_t offset, int
}
}
extern Pid etbPid;
extern EtbController etbController;
static const void * getStructAddr(int structId) {
switch (structId) {
@ -274,7 +275,7 @@ static const void * getStructAddr(int structId) {
return static_cast<trigger_state_s*>(&engine->triggerCentral.triggerState);
#if EFI_ELECTRONIC_THROTTLE_BODY
case LDS_ETB_PID_STATE_INDEX:
return static_cast<pid_state_s*>(&etbPid);
return static_cast<pid_state_s*>(&etbController.etbPid);
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
#ifndef EFI_IDLE_CONTROL

View File

@ -90,8 +90,6 @@
#define ETB_MAX_COUNT 2
#endif /* ETB_MAX_COUNT */
static bool shouldResetPid = false;
static pid_s tuneWorkingPidSettings;
static Pid tuneWorkingPid(&tuneWorkingPidSettings);
static PID_AutoTune autoTune;
@ -178,8 +176,6 @@ static EtbHardware etbHardware[ETB_COUNT];
extern percent_t mockPedalPosition;
Pid etbPid;
static percent_t directPwmValue = NAN;
static percent_t currentEtbDuty;
@ -395,10 +391,14 @@ static void showEthInfo(void) {
scheduleMsg(&logger, "%d: dir=%d DC=%f", i, etb->dcMotor.isOpenDirection(), etb->dcMotor.get());
}
etbPid.showPidStatus(&logger, "ETB");
etbController.etbPid.showPidStatus(&logger, "ETB");
#endif /* EFI_PROD_CODE */
}
static void etbPidReset() {
etbController.etbPid.reset();
}
#if EFI_PROD_CODE
static void setEtbFrequency(int frequency) {
@ -415,7 +415,7 @@ static void etbReset() {
for (int i = 0 ; i < ETB_COUNT; i++) {
etbHardware[i].dcMotor.set(0);
}
etbPid.reset();
etbPidReset();
mockPedalPosition = MOCK_UNDEFINED;
}
@ -427,7 +427,7 @@ static void etbReset() {
*/
void setEtbPFactor(float value) {
engineConfiguration->etb.pFactor = value;
etbPid.reset();
etbPidReset();
showEthInfo();
}
@ -436,7 +436,7 @@ void setEtbPFactor(float value) {
*/
void setEtbIFactor(float value) {
engineConfiguration->etb.iFactor = value;
etbPid.reset();
etbPidReset();
showEthInfo();
}
@ -445,7 +445,7 @@ void setEtbIFactor(float value) {
*/
void setEtbDFactor(float value) {
engineConfiguration->etb.dFactor = value;
etbPid.reset();
etbPidReset();
showEthInfo();
}
@ -454,7 +454,7 @@ void setEtbDFactor(float value) {
*/
void setEtbOffset(int value) {
engineConfiguration->etb.offset = value;
etbPid.reset();
etbPidReset();
showEthInfo();
}
@ -542,7 +542,8 @@ void stopETBPins(void) {
#endif /* EFI_PROD_CODE */
void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration) {
shouldResetPid = !etbPid.isSame(&previousConfiguration->etb);
bool shouldResetPid = !etbController.etbPid.isSame(&previousConfiguration->etb);
etbController.shouldResetPid = shouldResetPid;
}
void startETBPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
@ -624,7 +625,7 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
addConsoleActionI("etb_freq", setEtbFrequency);
#endif /* EFI_PROD_CODE */
etbPid.initPidClass(&engineConfiguration->etb);
etbController.etbPid.initPidClass(&engineConfiguration->etb);
INJECT_ENGINE_REFERENCE(etbController);
@ -695,7 +696,7 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif /* EFI_PROD_CODE */
etbPid.reset();
etbPidReset();
etbController.Start();
}

View File

@ -23,6 +23,8 @@ public:
int getPeriodMs() override;
void PeriodicTask() override;
Pid etbPid;
bool shouldResetPid = false;
private:
DcMotor *m_motor;

View File

@ -819,6 +819,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20191123;
return 20191127;
}
#endif /* EFI_UNIT_TEST */