ETB
This commit is contained in:
parent
69c8cf92c7
commit
e452b6802b
|
@ -276,8 +276,9 @@ void setEtbTestConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
setDefaultEtbParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
engineConfiguration->etb.minValue = -100;
|
||||
engineConfiguration->etb.maxValue = 100;
|
||||
// values are above 100% since we have feedforward part of the total summation
|
||||
engineConfiguration->etb.minValue = -200;
|
||||
engineConfiguration->etb.maxValue = 200;
|
||||
#endif
|
||||
|
||||
engineConfiguration->tpsAdcChannel = EFI_ADC_2; // PA2
|
||||
|
|
|
@ -38,6 +38,11 @@
|
|||
* set debug_mode 17
|
||||
* 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
|
||||
*
|
||||
* @date Dec 7, 2013
|
||||
|
@ -104,10 +109,11 @@ static percent_t currentEtbDuty;
|
|||
|
||||
//static bool wasEtbBraking = false;
|
||||
|
||||
// todo: need to fix PWM so that it supports zero duty cycle
|
||||
//#define PERCENT_TO_DUTY(X) (maxF(minI(X, 99.9), 0.1) / 100.0)
|
||||
// looks like my H-bridge does not like 100% duty cycle and it just hangs up?
|
||||
// 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> {
|
||||
public:
|
||||
|
@ -222,6 +228,7 @@ static void showEthInfo(void) {
|
|||
getPinNameByAdcChannel("tPedal", engineConfiguration->throttlePedalPositionAdcChannel, pinNameBuffer));
|
||||
|
||||
scheduleMsg(&logger, "TPS=%.2f", getTPS());
|
||||
scheduleMsg(&logger, "dir=%d", dcMotor.isOpenDirection());
|
||||
|
||||
scheduleMsg(&logger, "etbControlPin1=%s duty=%.2f freq=%d",
|
||||
hwPortname(CONFIGB(etbControlPin1)),
|
||||
|
@ -231,18 +238,27 @@ static void showEthInfo(void) {
|
|||
pid.showPidStatus(&logger, "ETB");
|
||||
}
|
||||
|
||||
/**
|
||||
* set etb_p X
|
||||
*/
|
||||
void setEtbPFactor(float value) {
|
||||
engineConfiguration->etb.pFactor = value;
|
||||
pid.reset();
|
||||
showEthInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* set etb_i X
|
||||
*/
|
||||
void setEtbIFactor(float value) {
|
||||
engineConfiguration->etb.iFactor = value;
|
||||
pid.reset();
|
||||
showEthInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* set etb_d X
|
||||
*/
|
||||
void setEtbDFactor(float value) {
|
||||
engineConfiguration->etb.dFactor = value;
|
||||
pid.reset();
|
||||
|
@ -377,7 +393,7 @@ void initElectronicThrottle(void) {
|
|||
tuneWorkingPidSettings.maxValue = 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_step", setAutoStep);
|
||||
addConsoleActionI("set_etbat_period", setAutoPeriod);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
bool TwoPinDcMotor::Set(float duty)
|
||||
{
|
||||
bool isPositiveOrZero;
|
||||
this->value = duty;
|
||||
|
||||
if(duty < 0)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,8 @@ private:
|
|||
SimplePwm* const m_pwm;
|
||||
OutputPin* const m_dir1;
|
||||
OutputPin* const m_dir2;
|
||||
float value = 0;
|
||||
bool isPositiveOrZero = false;
|
||||
public:
|
||||
/**
|
||||
* @param pwm SimplePwm driver for enable pin, for PWM speed control.
|
||||
|
@ -50,4 +52,6 @@ public:
|
|||
TwoPinDcMotor(SimplePwm* pwm, OutputPin* dir1, OutputPin* dir2);
|
||||
|
||||
virtual bool Set(float duty) override;
|
||||
float Get();
|
||||
bool isOpenDirection();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue