This commit is contained in:
rusEfi 2019-03-01 23:09:33 -05:00
parent 69c8cf92c7
commit e452b6802b
4 changed files with 36 additions and 7 deletions

View File

@ -276,8 +276,9 @@ void setEtbTestConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_PROD_CODE || defined(__DOXYGEN__) #if EFI_PROD_CODE || defined(__DOXYGEN__)
setDefaultEtbParameters(PASS_ENGINE_PARAMETER_SIGNATURE); setDefaultEtbParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
engineConfiguration->etb.minValue = -100; // values are above 100% since we have feedforward part of the total summation
engineConfiguration->etb.maxValue = 100; engineConfiguration->etb.minValue = -200;
engineConfiguration->etb.maxValue = 200;
#endif #endif
engineConfiguration->tpsAdcChannel = EFI_ADC_2; // PA2 engineConfiguration->tpsAdcChannel = EFI_ADC_2; // PA2

View File

@ -38,6 +38,11 @@
* set debug_mode 17 * set debug_mode 17
* for PID outputs * for PID outputs
* *
* set etb_p X
* set etb_i X
* set etb_d X
*
*
* http://rusefi.com/forum/viewtopic.php?f=5&t=592 * http://rusefi.com/forum/viewtopic.php?f=5&t=592
* *
* @date Dec 7, 2013 * @date Dec 7, 2013
@ -104,10 +109,11 @@ static percent_t currentEtbDuty;
//static bool wasEtbBraking = false; //static bool wasEtbBraking = false;
// todo: need to fix PWM so that it supports zero duty cycle // looks like my H-bridge does not like 100% duty cycle and it just hangs up?
//#define PERCENT_TO_DUTY(X) (maxF(minI(X, 99.9), 0.1) / 100.0) // so we use 99.9% to indicate that things are alive
#define PERCENT_TO_DUTY(X) (maxF(minI(X, 99.9), -99.9) / 100.0)
#define PERCENT_TO_DUTY(X) ((X) / 100.0) //#define PERCENT_TO_DUTY(X) ((X) / 100.0)
class EtbController : public PeriodicController<UTILITY_THREAD_STACK_SIZE> { class EtbController : public PeriodicController<UTILITY_THREAD_STACK_SIZE> {
public: public:
@ -222,6 +228,7 @@ static void showEthInfo(void) {
getPinNameByAdcChannel("tPedal", engineConfiguration->throttlePedalPositionAdcChannel, pinNameBuffer)); getPinNameByAdcChannel("tPedal", engineConfiguration->throttlePedalPositionAdcChannel, pinNameBuffer));
scheduleMsg(&logger, "TPS=%.2f", getTPS()); scheduleMsg(&logger, "TPS=%.2f", getTPS());
scheduleMsg(&logger, "dir=%d", dcMotor.isOpenDirection());
scheduleMsg(&logger, "etbControlPin1=%s duty=%.2f freq=%d", scheduleMsg(&logger, "etbControlPin1=%s duty=%.2f freq=%d",
hwPortname(CONFIGB(etbControlPin1)), hwPortname(CONFIGB(etbControlPin1)),
@ -231,18 +238,27 @@ static void showEthInfo(void) {
pid.showPidStatus(&logger, "ETB"); pid.showPidStatus(&logger, "ETB");
} }
/**
* set etb_p X
*/
void setEtbPFactor(float value) { void setEtbPFactor(float value) {
engineConfiguration->etb.pFactor = value; engineConfiguration->etb.pFactor = value;
pid.reset(); pid.reset();
showEthInfo(); showEthInfo();
} }
/**
* set etb_i X
*/
void setEtbIFactor(float value) { void setEtbIFactor(float value) {
engineConfiguration->etb.iFactor = value; engineConfiguration->etb.iFactor = value;
pid.reset(); pid.reset();
showEthInfo(); showEthInfo();
} }
/**
* set etb_d X
*/
void setEtbDFactor(float value) { void setEtbDFactor(float value) {
engineConfiguration->etb.dFactor = value; engineConfiguration->etb.dFactor = value;
pid.reset(); pid.reset();
@ -377,7 +393,7 @@ void initElectronicThrottle(void) {
tuneWorkingPidSettings.maxValue = 100; tuneWorkingPidSettings.maxValue = 100;
tuneWorkingPidSettings.periodMs = 100; tuneWorkingPidSettings.periodMs = 100;
// this is useful one you do "enable etb_auto" // this is useful once you do "enable etb_auto"
addConsoleActionF("set_etbat_output", setTempOutput); addConsoleActionF("set_etbat_output", setTempOutput);
addConsoleActionF("set_etbat_step", setAutoStep); addConsoleActionF("set_etbat_step", setAutoStep);
addConsoleActionI("set_etbat_period", setAutoPeriod); addConsoleActionI("set_etbat_period", setAutoPeriod);

View File

@ -15,12 +15,20 @@ TwoPinDcMotor::TwoPinDcMotor(SimplePwm* pwm, OutputPin* dir1, OutputPin* dir2)
{ {
} }
bool TwoPinDcMotor::isOpenDirection() {
return isPositiveOrZero;
}
float TwoPinDcMotor::Get() {
return value;
}
/** /**
* @param duty value between -1.0 and 1.0 * @param duty value between -1.0 and 1.0
*/ */
bool TwoPinDcMotor::Set(float duty) bool TwoPinDcMotor::Set(float duty)
{ {
bool isPositiveOrZero; this->value = duty;
if(duty < 0) if(duty < 0)
{ {

View File

@ -41,6 +41,8 @@ private:
SimplePwm* const m_pwm; SimplePwm* const m_pwm;
OutputPin* const m_dir1; OutputPin* const m_dir1;
OutputPin* const m_dir2; OutputPin* const m_dir2;
float value = 0;
bool isPositiveOrZero = false;
public: public:
/** /**
* @param pwm SimplePwm driver for enable pin, for PWM speed control. * @param pwm SimplePwm driver for enable pin, for PWM speed control.
@ -50,4 +52,6 @@ public:
TwoPinDcMotor(SimplePwm* pwm, OutputPin* dir1, OutputPin* dir2); TwoPinDcMotor(SimplePwm* pwm, OutputPin* dir1, OutputPin* dir2);
virtual bool Set(float duty) override; virtual bool Set(float duty) override;
float Get();
bool isOpenDirection();
}; };