ETB
This commit is contained in:
parent
b036d3f629
commit
0721678500
|
@ -57,8 +57,6 @@
|
||||||
extern TunerStudioOutputChannels tsOutputChannels;
|
extern TunerStudioOutputChannels tsOutputChannels;
|
||||||
static bool shouldResetPid = false;
|
static bool shouldResetPid = false;
|
||||||
|
|
||||||
#define ETB_FREQ 400
|
|
||||||
|
|
||||||
static LoggingWithStorage logger("ETB");
|
static LoggingWithStorage logger("ETB");
|
||||||
/**
|
/**
|
||||||
* @brief Control Thread stack
|
* @brief Control Thread stack
|
||||||
|
@ -174,6 +172,7 @@ void setDefaultEtbParameters(void) {
|
||||||
engineConfiguration->etb.pFactor = 1;
|
engineConfiguration->etb.pFactor = 1;
|
||||||
engineConfiguration->etb.iFactor = 0.5;
|
engineConfiguration->etb.iFactor = 0.5;
|
||||||
engineConfiguration->etb.period = 100;
|
engineConfiguration->etb.period = 100;
|
||||||
|
engineConfiguration->etbFreq = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopETBPins(void) {
|
void stopETBPins(void) {
|
||||||
|
@ -188,17 +187,20 @@ void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *pre
|
||||||
}
|
}
|
||||||
|
|
||||||
void startETBPins(void) {
|
void startETBPins(void) {
|
||||||
|
|
||||||
|
int freq = maxI(100, engineConfiguration->etbFreq);
|
||||||
|
|
||||||
// this line used for PWM
|
// this line used for PWM
|
||||||
startSimplePwmExt(&etbPwmUp, "etb1",
|
startSimplePwmExt(&etbPwmUp, "etb1",
|
||||||
boardConfiguration->etbControlPin1,
|
boardConfiguration->etbControlPin1,
|
||||||
&enginePins.etbOutput1,
|
&enginePins.etbOutput1,
|
||||||
ETB_FREQ,
|
freq,
|
||||||
0.80,
|
0.80,
|
||||||
applyPinState);
|
applyPinState);
|
||||||
startSimplePwmExt(&etbPwmDown, "etb2",
|
startSimplePwmExt(&etbPwmDown, "etb2",
|
||||||
boardConfiguration->etbControlPin2,
|
boardConfiguration->etbControlPin2,
|
||||||
&enginePins.etbOutput2,
|
&enginePins.etbOutput2,
|
||||||
ETB_FREQ,
|
freq,
|
||||||
0.80,
|
0.80,
|
||||||
applyPinState);
|
applyPinState);
|
||||||
|
|
||||||
|
@ -211,6 +213,7 @@ void initElectronicThrottle(void) {
|
||||||
// outputPinRegister("etb1", ELECTRONIC_THROTTLE_CONTROL_1, ETB_CONTROL_LINE_1_PORT, ETB_CONTROL_LINE_1_PIN);
|
// outputPinRegister("etb1", ELECTRONIC_THROTTLE_CONTROL_1, ETB_CONTROL_LINE_1_PORT, ETB_CONTROL_LINE_1_PIN);
|
||||||
// outputPinRegister("etb2", ELECTRONIC_THROTTLE_CONTROL_2, ETB_CONTROL_LINE_2_PORT, ETB_CONTROL_LINE_2_PIN);
|
// outputPinRegister("etb2", ELECTRONIC_THROTTLE_CONTROL_2, ETB_CONTROL_LINE_2_PORT, ETB_CONTROL_LINE_2_PIN);
|
||||||
|
|
||||||
|
addConsoleAction("ethinfo", showEthInfo);
|
||||||
if (!hasPedalPositionSensor()) {
|
if (!hasPedalPositionSensor()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -219,8 +222,6 @@ void initElectronicThrottle(void) {
|
||||||
|
|
||||||
addConsoleActionI("e", setThrottleConsole);
|
addConsoleActionI("e", setThrottleConsole);
|
||||||
|
|
||||||
addConsoleAction("ethinfo", showEthInfo);
|
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
|
|
||||||
chThdCreateStatic(etbTreadStack, sizeof(etbTreadStack), NORMALPRIO, (tfunc_t) etbThread, NULL);
|
chThdCreateStatic(etbTreadStack, sizeof(etbTreadStack), NORMALPRIO, (tfunc_t) etbThread, NULL);
|
||||||
|
|
Loading…
Reference in New Issue