ETB progress
This commit is contained in:
parent
fe7d75a185
commit
dc0ae33a54
|
@ -4,6 +4,8 @@
|
|||
*
|
||||
* todo: make this more universal if/when we get other hardware options
|
||||
*
|
||||
* Jan 2019 actually driven around the block but still need some work.
|
||||
*
|
||||
* Jan 2017 status:
|
||||
* Electronic throttle body with it's spring is definitely not linear - both P and I factors of PID are required to get any results
|
||||
* PID implementation tested on a bench only
|
||||
|
@ -86,8 +88,8 @@ static SimplePwm etbPwmUp("etbUp") CCM_OPTIONAL;
|
|||
static float valueOverride = NAN;
|
||||
/*
|
||||
static SimplePwm etbPwmDown("etbDown") CCM_OPTIONAL;
|
||||
static OutputPin outputDirectionOpen CCM_OPTIONAL;
|
||||
*/
|
||||
static OutputPin outputDirectionOpen CCM_OPTIONAL;
|
||||
static OutputPin outputDirectionClose CCM_OPTIONAL;
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
@ -157,7 +159,7 @@ static msg_t etbThread(void *arg) {
|
|||
currentEtbDuty = pid.getValue(targetPosition, actualThrottlePosition);
|
||||
|
||||
etbPwmUp.setSimplePwmDutyCycle(PERCENT_TO_DUTY(currentEtbDuty));
|
||||
|
||||
/*
|
||||
if (CONFIGB(etbDirectionPin2) != GPIO_UNASSIGNED) {
|
||||
bool needEtbBraking = absF(targetPosition - actualThrottlePosition) < 3;
|
||||
if (needEtbBraking != wasEtbBraking) {
|
||||
|
@ -166,7 +168,7 @@ static msg_t etbThread(void *arg) {
|
|||
}
|
||||
outputDirectionClose.setValue(needEtbBraking);
|
||||
}
|
||||
|
||||
*/
|
||||
if (engineConfiguration->isVerboseETB) {
|
||||
pid.showPidStatus(&logger, "ETB");
|
||||
}
|
||||
|
@ -295,8 +297,8 @@ void startETBPins(void) {
|
|||
freq,
|
||||
0.80,
|
||||
applyPinState);
|
||||
outputDirectionOpen.initPin("etb dir open", CONFIGB(etbDirectionPin1));
|
||||
*/
|
||||
outputDirectionOpen.initPin("etb dir open", CONFIGB(etbDirectionPin1));
|
||||
outputDirectionClose.initPin("etb dir close", CONFIGB(etbDirectionPin2));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,19 +15,23 @@ TwoPinDcMotor::TwoPinDcMotor(SimplePwm* pwm, OutputPin* dir1, OutputPin* dir2)
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param duty value between -1.0 and 1.0
|
||||
*/
|
||||
bool TwoPinDcMotor::Set(float duty)
|
||||
{
|
||||
bool dir;
|
||||
bool isPositiveOrZero;
|
||||
|
||||
if(duty < 0)
|
||||
{
|
||||
dir = false;
|
||||
isPositiveOrZero = false;
|
||||
duty = -duty;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = true;
|
||||
isPositiveOrZero = true;
|
||||
}
|
||||
// below here 'duty' is a not negative
|
||||
|
||||
// Clamp to 100%
|
||||
if(duty > 1.0f)
|
||||
|
@ -47,8 +51,8 @@ bool TwoPinDcMotor::Set(float duty)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_dir1->setValue(dir);
|
||||
m_dir2->setValue(!dir);
|
||||
m_dir1->setValue(isPositiveOrZero);
|
||||
m_dir2->setValue(!isPositiveOrZero);
|
||||
}
|
||||
|
||||
m_pwm->setSimplePwmDutyCycle(duty);
|
||||
|
|
Loading…
Reference in New Issue