This commit is contained in:
rusefi 2017-06-01 20:32:53 -04:00
commit 141dc0f586
35 changed files with 312 additions and 113 deletions

View File

@ -134,3 +134,17 @@ void boardInit(void) {
*/ */
void setBoardConfigurationOverrides(void) { void setBoardConfigurationOverrides(void) {
} }
/**
* @brief Board-specific Serial configuration code overrides. Needed by bootloader code.
* @todo Add your board-specific code, if any.
*/
void setSerialConfigurationOverrides(void) {
}
/**
* @brief Board-specific SD card configuration code overrides. Needed by bootloader code.
* @todo Add your board-specific code, if any.
*/
void setSdCardConfigurationOverrides(void) {
}

View File

@ -1345,6 +1345,8 @@ extern "C" {
#endif #endif
void boardInit(void); void boardInit(void);
void setBoardConfigurationOverrides(void); void setBoardConfigurationOverrides(void);
void setSerialConfigurationOverrides(void);
void setSdCardConfigurationOverrides(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -20,7 +20,6 @@ extern LoggingWithStorage tsLogger;
#if EFI_PROD_CODE || defined(__DOXYGEN__) #if EFI_PROD_CODE || defined(__DOXYGEN__)
#include "pin_repository.h" #include "pin_repository.h"
#include "usbconsole.h" #include "usbconsole.h"
#include "map_averaging.h"
#if HAL_USE_SERIAL_USB || defined(__DOXYGEN__) #if HAL_USE_SERIAL_USB || defined(__DOXYGEN__)
extern SerialUSBDriver SDU1; extern SerialUSBDriver SDU1;
@ -152,17 +151,21 @@ void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {
} }
} }
int sr5ReadData(ts_channel_s *tsChannel, uint8_t * buffer, int size) { int sr5ReadDataTimeout(ts_channel_s *tsChannel, uint8_t * buffer, int size, int timeout) {
#if TS_UART_DMA_MODE || defined(__DOXYGEN__) #if TS_UART_DMA_MODE || defined(__DOXYGEN__)
UNUSED(tsChannel); UNUSED(tsChannel);
return (int)chIQReadTimeout(&tsUartDma.fifoRxQueue, (uint8_t * )buffer, (size_t)size, SR5_READ_TIMEOUT); return (int)chIQReadTimeout(&tsUartDma.fifoRxQueue, (uint8_t * )buffer, (size_t)size, timeout);
#else /* TS_UART_DMA_MODE */ #else /* TS_UART_DMA_MODE */
if (tsChannel->channel == NULL) if (tsChannel->channel == NULL)
return 0; return 0;
return chnReadTimeout(tsChannel->channel, (uint8_t * )buffer, size, SR5_READ_TIMEOUT); return chnReadTimeout(tsChannel->channel, (uint8_t * )buffer, size, timeout);
#endif /* TS_UART_DMA_MODE */ #endif /* TS_UART_DMA_MODE */
} }
int sr5ReadData(ts_channel_s *tsChannel, uint8_t * buffer, int size) {
return sr5ReadDataTimeout(tsChannel, buffer, size, SR5_READ_TIMEOUT);
}
/** /**
* Adds size to the beginning of a packet and a crc32 at the end. Then send the packet. * Adds size to the beginning of a packet and a crc32 at the end. Then send the packet.

View File

@ -101,6 +101,7 @@ void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size);
void sr5WriteCrcPacket(ts_channel_s *tsChannel, const uint8_t responseCode, const void *buf, const uint16_t size); void sr5WriteCrcPacket(ts_channel_s *tsChannel, const uint8_t responseCode, const void *buf, const uint16_t size);
void sr5SendResponse(ts_channel_s *tsChannel, ts_response_format_e mode, const uint8_t * buffer, int size); void sr5SendResponse(ts_channel_s *tsChannel, ts_response_format_e mode, const uint8_t * buffer, int size);
int sr5ReadData(ts_channel_s *tsChannel, uint8_t * buffer, int size); int sr5ReadData(ts_channel_s *tsChannel, uint8_t * buffer, int size);
int sr5ReadDataTimeout(ts_channel_s *tsChannel, uint8_t * buffer, int size, int timeout);
bool sr5IsReady(bool isConsoleRedirect); bool sr5IsReady(bool isConsoleRedirect);
#endif /* CONSOLE_TUNERSTUDIO_TUNERSTUDIO_IO_H_ */ #endif /* CONSOLE_TUNERSTUDIO_TUNERSTUDIO_IO_H_ */

View File

@ -35,7 +35,7 @@ static SimplePwm auxPidPwm[AUX_PID_COUNT];
static OutputPin auxPidPin[AUX_PID_COUNT]; static OutputPin auxPidPin[AUX_PID_COUNT];
static pid_s *auxPidS = &persistentState.persistentConfiguration.engineConfiguration.auxPid[0]; static pid_s *auxPidS = &persistentState.persistentConfiguration.engineConfiguration.auxPid[0];
static Pid auxPid(auxPidS, 0, 90); static Pid auxPid(auxPidS);
static Logging *logger; static Logging *logger;
static bool isEnabled(int index) { static bool isEnabled(int index) {
@ -89,7 +89,6 @@ static msg_t auxPidThread(int param) {
if (engineConfiguration->debugMode == AUX_PID_1) { if (engineConfiguration->debugMode == AUX_PID_1) {
tsOutputChannels.debugFloatField1 = pwm;
auxPid.postState(&tsOutputChannels); auxPid.postState(&tsOutputChannels);
tsOutputChannels.debugIntField3 = (int)(10 * targetValue); tsOutputChannels.debugIntField3 = (int)(10 * targetValue);
} }

View File

@ -264,7 +264,7 @@ void Engine::setConfig(persistent_config_s *config) {
this->config = config; this->config = config;
engineConfiguration = &config->engineConfiguration; engineConfiguration = &config->engineConfiguration;
memset(config, 0, sizeof(persistent_config_s)); memset(config, 0, sizeof(persistent_config_s));
engineState.warmupAfrPid.init(&config->engineConfiguration.warmupAfrPid, 0.5, 1.5); engineState.warmupAfrPid.init(&config->engineConfiguration.warmupAfrPid);
} }
void Engine::printKnockState(void) { void Engine::printKnockState(void) {

View File

@ -344,6 +344,37 @@ void setDefaultBasePins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->configResetPin = GPIOB_1; engineConfiguration->configResetPin = GPIOB_1;
} }
// needed also by bootloader code
void setDefaultSerialParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
boardConfiguration->startConsoleInBinaryMode = true;
boardConfiguration->useSerialPort = true;
engineConfiguration->binarySerialTxPin = GPIOC_10;
engineConfiguration->binarySerialRxPin = GPIOC_11;
engineConfiguration->consoleSerialTxPin = GPIOC_10;
engineConfiguration->consoleSerialRxPin = GPIOC_11;
boardConfiguration->tunerStudioSerialSpeed = TS_DEFAULT_SPEED;
engineConfiguration->uartConsoleSerialSpeed = 115200;
#if EFI_PROD_CODE || defined(__DOXYGEN__)
// call overrided board-specific serial configuration setup, if needed (for custom boards only)
setSerialConfigurationOverrides();
#endif
}
// needed also by bootloader code
void setDefaultSdCardParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
boardConfiguration->is_enabled_spi_3 = true;
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3;
boardConfiguration->sdCardCsPin = GPIOD_4;
boardConfiguration->isSdCardEnabled = true;
#if EFI_PROD_CODE || defined(__DOXYGEN__)
// call overrided board-specific SD card configuration setup, if needed (for custom boards only)
setSdCardConfigurationOverrides();
#endif
}
// todo: move injector calibration somewhere else? // todo: move injector calibration somewhere else?
// todo: add a enum? if we have enough data? // todo: add a enum? if we have enough data?
static void setBosch02880155868(DECLARE_ENGINE_PARAMETER_SIGNATURE) { static void setBosch02880155868(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
@ -527,8 +558,6 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
boardConfiguration->mafSensorType = Bosch0280218037; boardConfiguration->mafSensorType = Bosch0280218037;
setBosch0280218037(config); setBosch0280218037(config);
boardConfiguration->startConsoleInBinaryMode = true;
setBosch02880155868(PASS_ENGINE_PARAMETER_SIGNATURE); setBosch02880155868(PASS_ENGINE_PARAMETER_SIGNATURE);
engineConfiguration->acCutoffLowRpm = 700; engineConfiguration->acCutoffLowRpm = 700;
@ -765,7 +794,6 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE;
boardConfiguration->useSerialPort = true;
boardConfiguration->useStepperIdle = false; boardConfiguration->useStepperIdle = false;
setDefaultStepperIdleParameters(PASS_ENGINE_PARAMETER_SIGNATURE); setDefaultStepperIdleParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
@ -820,11 +848,8 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->communicationPin = GPIOD_15; // blue LED on discovery engineConfiguration->communicationPin = GPIOD_15; // blue LED on discovery
engineConfiguration->runningPin = GPIOD_12; // greeb LED on discovery engineConfiguration->runningPin = GPIOD_12; // greeb LED on discovery
setDefaultBasePins(PASS_ENGINE_PARAMETER_SIGNATURE); setDefaultBasePins(PASS_ENGINE_PARAMETER_SIGNATURE);
engineConfiguration->binarySerialTxPin = GPIOC_10;
engineConfiguration->binarySerialRxPin = GPIOC_11; setDefaultSerialParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
engineConfiguration->consoleSerialTxPin = GPIOC_10;
engineConfiguration->consoleSerialRxPin = GPIOC_11;
boardConfiguration->triggerSimulatorPins[0] = GPIOD_1; boardConfiguration->triggerSimulatorPins[0] = GPIOD_1;
boardConfiguration->triggerSimulatorPins[1] = GPIOD_2; boardConfiguration->triggerSimulatorPins[1] = GPIOD_2;
@ -900,17 +925,13 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
setHip9011FrankensoPinout(); setHip9011FrankensoPinout();
#endif #endif
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; setDefaultSdCardParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
boardConfiguration->sdCardCsPin = GPIOD_4;
boardConfiguration->isSdCardEnabled = true;
boardConfiguration->isFastAdcEnabled = true; boardConfiguration->isFastAdcEnabled = true;
boardConfiguration->isEngineControlEnabled = true; boardConfiguration->isEngineControlEnabled = true;
boardConfiguration->isVerboseAlternator = false; boardConfiguration->isVerboseAlternator = false;
boardConfiguration->tunerStudioSerialSpeed = TS_DEFAULT_SPEED;
engineConfiguration->uartConsoleSerialSpeed = 115200;
engineConfiguration->warmupAfrPid.offset = 1; engineConfiguration->warmupAfrPid.offset = 1;
engineConfiguration->warmupAfrThreshold = 60; engineConfiguration->warmupAfrThreshold = 60;

View File

@ -53,6 +53,10 @@ void setWholeTimingTable(angle_t value DECLARE_ENGINE_PARAMETER_SUFFIX);
void setConstantDwell(floatms_t dwellMs DECLARE_ENGINE_PARAMETER_SUFFIX); void setConstantDwell(floatms_t dwellMs DECLARE_ENGINE_PARAMETER_SUFFIX);
void printFloatArray(const char *prefix, float array[], int size); void printFloatArray(const char *prefix, float array[], int size);
// needed by bootloader
void setDefaultSerialParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void setDefaultSdCardParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);
void rememberCurrentConfiguration(void); void rememberCurrentConfiguration(void);
void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE); void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE);
int getGlobalConfigurationVersion(void); int getGlobalConfigurationVersion(void);

View File

@ -1,4 +1,4 @@
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun May 28 22:30:58 EDT 2017 // this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon May 29 23:12:19 EDT 2017
// begin // begin
#ifndef ENGINE_CONFIGURATION_GENERATED_H_ #ifndef ENGINE_CONFIGURATION_GENERATED_H_
#define ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_
@ -1165,11 +1165,7 @@ typedef struct {
/** /**
* offset 572 * offset 572
*/ */
int16_t pedalPositionMin; int unusedAnother;
/**
* offset 574
*/
int16_t pedalPositionMax;
/** /**
* maximum total number of degrees to subtract from ignition advance * maximum total number of degrees to subtract from ignition advance
* when knocking * when knocking
@ -1208,6 +1204,7 @@ typedef struct {
offset 1488 bit 2 */ offset 1488 bit 2 */
bool isVerboseIAC : 1; bool isVerboseIAC : 1;
/** /**
* enable verbose_etb
offset 1488 bit 3 */ offset 1488 bit 3 */
bool isVerboseETB : 1; bool isVerboseETB : 1;
/** /**
@ -1538,7 +1535,16 @@ typedef struct {
/** /**
* offset 2012 * offset 2012
*/ */
float unusedetb[4]; float throttlePedalUpVoltage;
/**
* Pedal in the floor
* offset 2016
*/
float throttlePedalWOTVoltage;
/**
* offset 2020
*/
float unusedetb[2];
/** /**
* CLT-based target RPM for automatic idle controller * CLT-based target RPM for automatic idle controller
* offset 2028 * offset 2028
@ -2107,4 +2113,4 @@ typedef struct {
#endif #endif
// end // end
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun May 28 22:30:58 EDT 2017 // this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon May 29 23:12:19 EDT 2017

View File

@ -319,10 +319,8 @@
#define hip9011SpiDevice_offset_hex 234 #define hip9011SpiDevice_offset_hex 234
#define globalFuelCorrection_offset 568 #define globalFuelCorrection_offset 568
#define globalFuelCorrection_offset_hex 238 #define globalFuelCorrection_offset_hex 238
#define pedalPositionMin_offset 572 #define unusedAnother_offset 572
#define pedalPositionMin_offset_hex 23c #define unusedAnother_offset_hex 23c
#define pedalPositionMax_offset 574
#define pedalPositionMax_offset_hex 23e
#define maxKnockSubDeg_offset 576 #define maxKnockSubDeg_offset 576
#define maxKnockSubDeg_offset_hex 240 #define maxKnockSubDeg_offset_hex 240
#define mafAdcChannel_offset 580 #define mafAdcChannel_offset 580
@ -1097,8 +1095,12 @@
#define knockNoise_offset_hex 79c #define knockNoise_offset_hex 79c
#define knockNoiseRpmBins_offset 1980 #define knockNoiseRpmBins_offset 1980
#define knockNoiseRpmBins_offset_hex 7bc #define knockNoiseRpmBins_offset_hex 7bc
#define unusedetb_offset 2012 #define throttlePedalUpVoltage_offset 2012
#define unusedetb_offset_hex 7dc #define throttlePedalUpVoltage_offset_hex 7dc
#define throttlePedalWOTVoltage_offset 2016
#define throttlePedalWOTVoltage_offset_hex 7e0
#define unusedetb_offset 2020
#define unusedetb_offset_hex 7e4
#define cltIdleRpmBins_offset 2028 #define cltIdleRpmBins_offset 2028
#define cltIdleRpmBins_offset_hex 7ec #define cltIdleRpmBins_offset_hex 7ec
#define cltIdleRpm_offset 2092 #define cltIdleRpm_offset 2092

View File

@ -29,7 +29,7 @@ int alternatorPidResetCounter = 0;
static SimplePwm alternatorControl; static SimplePwm alternatorControl;
static pid_s *altPidS = &persistentState.persistentConfiguration.engineConfiguration.alternatorControl; static pid_s *altPidS = &persistentState.persistentConfiguration.engineConfiguration.alternatorControl;
static Pid altPid(altPidS, 1, 90); static Pid altPid(altPidS);
static THD_WORKING_AREA(alternatorControlThreadStack, UTILITY_THREAD_STACK_SIZE); static THD_WORKING_AREA(alternatorControlThreadStack, UTILITY_THREAD_STACK_SIZE);
@ -64,7 +64,6 @@ static msg_t AltCtrlThread(int param) {
if (engineConfiguration->debugMode == DBG_ALTERNATOR_PID) { if (engineConfiguration->debugMode == DBG_ALTERNATOR_PID) {
// this block could be executed even in on/off alternator control mode // this block could be executed even in on/off alternator control mode
// but at least we would reflect latest state // but at least we would reflect latest state
tsOutputChannels.debugFloatField1 = currentAltDuty;
altPid.postState(&tsOutputChannels); altPid.postState(&tsOutputChannels);
tsOutputChannels.debugIntField3 = alternatorPidResetCounter; tsOutputChannels.debugIntField3 = alternatorPidResetCounter;
} }

View File

@ -22,6 +22,11 @@
* *
* See also pid.cpp * See also pid.cpp
* *
* Relevant console commands:
*
* enable verbose_etb
* disable verbose_etb
* ethinfo
* *
* http://rusefi.com/forum/viewtopic.php?f=5&t=592 * http://rusefi.com/forum/viewtopic.php?f=5&t=592
* *
@ -57,8 +62,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
@ -75,7 +78,7 @@ static OutputPin outputDirectionClose CCM_OPTIONAL;
EXTERN_ENGINE; EXTERN_ENGINE;
static Pid pid(&engineConfiguration->etb, 0, 100); static Pid pid(&engineConfiguration->etb);
static float prevTps; static float prevTps;
@ -93,14 +96,14 @@ static msg_t etbThread(void *arg) {
} }
percent_t pedal = getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE); percent_t throttlePedal = getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE);
percent_t tps = getTPS(); percent_t tps = getTPS();
currentEtbDuty = pid.getValue(pedal, getTPS()); currentEtbDuty = pid.getValue(throttlePedal, getTPS());
etbPwmUp.setSimplePwmDutyCycle(currentEtbDuty / 100); etbPwmUp.setSimplePwmDutyCycle(currentEtbDuty / 100);
bool needEtbBraking = absF(pedal - tps) < 3; bool needEtbBraking = absF(throttlePedal - tps) < 3;
if (needEtbBraking != wasEtbBraking) { if (needEtbBraking != wasEtbBraking) {
scheduleMsg(&logger, "need ETB braking: %d", needEtbBraking); scheduleMsg(&logger, "need ETB braking: %d", needEtbBraking);
wasEtbBraking = needEtbBraking; wasEtbBraking = needEtbBraking;
@ -111,7 +114,7 @@ static msg_t etbThread(void *arg) {
pid.postState(&tsOutputChannels); pid.postState(&tsOutputChannels);
} }
if (engineConfiguration->isVerboseETB) { if (engineConfiguration->isVerboseETB) {
pid.showPidStatus(&logger, "ETB", engineConfiguration->etb.period); pid.showPidStatus(&logger, "ETB");
} }
@ -139,18 +142,20 @@ static void setThrottleConsole(int level) {
static void showEthInfo(void) { static void showEthInfo(void) {
static char pinNameBuffer[16]; static char pinNameBuffer[16];
scheduleMsg(&logger, "pedal=%f %d/%d @", getPedalPosition(), engineConfiguration->pedalPositionMin, engineConfiguration->pedalPositionMax, scheduleMsg(&logger, "throttlePedal=%f %f/%f @%s",
getPinNameByAdcChannel("etb", engineConfiguration->pedalPositionChannel, pinNameBuffer)); getPedalPosition(),
engineConfiguration->throttlePedalUpVoltage,
engineConfiguration->throttlePedalWOTVoltage,
getPinNameByAdcChannel("tPedal", engineConfiguration->pedalPositionChannel, pinNameBuffer));
scheduleMsg(&logger, "TPS=%f", getTPS()); scheduleMsg(&logger, "TPS=%f", getTPS());
scheduleMsg(&logger, "etbControlPin1=%s duty=%f", hwPortname(boardConfiguration->etbControlPin1), scheduleMsg(&logger, "etbControlPin1=%s duty=%f freq=%d",
currentEtbDuty); hwPortname(boardConfiguration->etbControlPin1),
currentEtbDuty,
engineConfiguration->etbFreq);
scheduleMsg(&logger, "close dir=%s", hwPortname(boardConfiguration->etbDirectionPin2)); scheduleMsg(&logger, "close dir=%s", hwPortname(boardConfiguration->etbDirectionPin2));
scheduleMsg(&logger, "etb P=%f I=%f D=%f dT=%d", engineConfiguration->etb.pFactor, pid.showPidStatus(&logger, "ETB");
engineConfiguration->etb.iFactor,
0.0,
engineConfiguration->etb.period);
} }
static void apply(void) { static void apply(void) {
@ -170,10 +175,23 @@ void setEtbIFactor(float value) {
} }
void setDefaultEtbParameters(void) { void setDefaultEtbParameters(void) {
engineConfiguration->pedalPositionMax = 6; engineConfiguration->throttlePedalUpVoltage = 0; // that's voltage, not ADC like with TPS
engineConfiguration->throttlePedalWOTVoltage = 6; // that's voltage, not ADC like with TPS
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;
}
bool isETBRestartNeeded(void) {
/**
* We do not want any interruption in HW pin while adjusting other properties
*/
return engineConfiguration->bc.etbControlPin1 != activeConfiguration.bc.etbControlPin1 ||
engineConfiguration->bc.etbControlPin2 != activeConfiguration.bc.etbControlPin2 ||
engineConfiguration->bc.etbDirectionPin1 != activeConfiguration.bc.etbDirectionPin1 ||
engineConfiguration->bc.etbDirectionPin2 != activeConfiguration.bc.etbDirectionPin2;
} }
void stopETBPins(void) { void stopETBPins(void) {
@ -188,17 +206,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 +232,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 +241,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);

View File

@ -13,6 +13,7 @@ void initElectronicThrottle(void);
void setDefaultEtbParameters(void); void setDefaultEtbParameters(void);
void setEtbPFactor(float value); void setEtbPFactor(float value);
void setEtbIFactor(float value); void setEtbIFactor(float value);
bool isETBRestartNeeded(void);
void stopETBPins(void); void stopETBPins(void);
void startETBPins(void); void startETBPins(void);
void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration); void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration);

View File

@ -45,7 +45,7 @@ EXTERN_ENGINE
static bool shouldResetPid = false; static bool shouldResetPid = false;
static Pid idlePid(&engineConfiguration->idleRpmPid, 1, 99); static Pid idlePid(&engineConfiguration->idleRpmPid);
// todo: extract interface for idle valve hardware, with solenoid and stepper implementations? // todo: extract interface for idle valve hardware, with solenoid and stepper implementations?
static SimplePwm idleSolenoid; static SimplePwm idleSolenoid;
@ -83,7 +83,7 @@ static void showIdleInfo(void) {
if (engineConfiguration->idleMode == IM_AUTO) { if (engineConfiguration->idleMode == IM_AUTO) {
idlePid.showPidStatus(logger, "idle", engineConfiguration->idleRpmPid.period); idlePid.showPidStatus(logger, "idle");
} }
} }
@ -239,7 +239,7 @@ static msg_t ivThread(int param) {
} }
if (engineConfiguration->isVerboseIAC && engineConfiguration->idleMode == IM_AUTO) { if (engineConfiguration->isVerboseIAC && engineConfiguration->idleMode == IM_AUTO) {
idlePid.showPidStatus(logger, "idle", engineConfiguration->idleRpmPid.period); idlePid.showPidStatus(logger, "idle");
} }

View File

@ -12,17 +12,15 @@
#include "math.h" #include "math.h"
Pid::Pid() { Pid::Pid() {
init(NULL, NAN, NAN); init(NULL);
} }
Pid::Pid(pid_s *pid, float minResult, float maxResult) { Pid::Pid(pid_s *pid) {
init(pid, minResult, maxResult); init(pid);
} }
void Pid::init(pid_s *pid, float minResult, float maxResult) { void Pid::init(pid_s *pid) {
this->pid = pid; this->pid = pid;
this->minResult = minResult;
this->maxResult = maxResult;
dTerm = iTerm = 0; dTerm = iTerm = 0;
prevResult = prevInput = prevTarget = prevError = 0; prevResult = prevInput = prevTarget = prevError = 0;
@ -52,17 +50,17 @@ float Pid::getValue(float target, float input, float dTime) {
* If we have exceeded the ability of the controlled device to hit target, the I factor will keep accumulating and approach infinity. * If we have exceeded the ability of the controlled device to hit target, the I factor will keep accumulating and approach infinity.
* Here we limit the I-term #353 * Here we limit the I-term #353
*/ */
if (iTerm > maxResult - (pTerm + dTerm + pid->offset)) if (iTerm > pid->maxValue - (pTerm + dTerm + pid->offset))
iTerm = maxResult - (pTerm + dTerm + pid->offset); iTerm = pid->maxValue - (pTerm + dTerm + pid->offset);
if (iTerm < minResult - (pTerm + dTerm + pid->offset)) if (iTerm < pid->minValue - (pTerm + dTerm + pid->offset))
iTerm = minResult - (pTerm + dTerm + pid->offset); iTerm = pid->minValue - (pTerm + dTerm + pid->offset);
float result = pTerm + iTerm + dTerm + pid->offset; float result = pTerm + iTerm + dTerm + pid->offset;
if (result > maxResult) { if (result > pid->maxValue) {
result = maxResult; result = pid->maxValue;
} else if (result < minResult) { } else if (result < pid->minValue) {
result = minResult; result = pid->minValue;
} }
prevResult = result; prevResult = result;
return result; return result;
@ -106,12 +104,13 @@ float Pid::getOffset(void) {
#if EFI_PROD_CODE || EFI_SIMULATOR #if EFI_PROD_CODE || EFI_SIMULATOR
void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) { void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) {
tsOutputChannels->debugFloatField1 = prevResult;
tsOutputChannels->debugFloatField2 = iTerm; tsOutputChannels->debugFloatField2 = iTerm;
tsOutputChannels->debugFloatField3 = getPrevError(); tsOutputChannels->debugFloatField3 = getPrevError();
tsOutputChannels->debugFloatField4 = getI(); tsOutputChannels->debugFloatField4 = getI();
tsOutputChannels->debugFloatField5 = getD(); tsOutputChannels->debugFloatField5 = getD();
tsOutputChannels->debugFloatField6 = minResult; tsOutputChannels->debugFloatField6 = pid->minValue;
tsOutputChannels->debugFloatField7 = maxResult; tsOutputChannels->debugFloatField7 = pid->maxValue;
tsOutputChannels->debugIntField1 = getP(); tsOutputChannels->debugIntField1 = getP();
tsOutputChannels->debugIntField2 = getOffset(); tsOutputChannels->debugIntField2 = getOffset();
tsOutputChannels->debugFloatField6 = dTerm; tsOutputChannels->debugFloatField6 = dTerm;
@ -125,17 +124,17 @@ void Pid::sleep() {
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */
} }
void Pid::showPidStatus(Logging *logging, const char*msg, int dTime) { void Pid::showPidStatus(Logging *logging, const char*msg) {
// todo: dTime should be taken from pid_s scheduleMsg(logging, "%s settings: offset=%d P=%.5f I=%.5f D=%.5f dT=%d",
scheduleMsg(logging, "%s o=%f P=%.5f I=%.5f D=%.5f dT=%d",
msg, msg,
pid->offset, pid->offset,
pid->pFactor, pid->pFactor,
pid->iFactor, pid->iFactor,
pid->dFactor, pid->dFactor,
dTime); pid->period);
scheduleMsg(logging, "%f input=%d/target=%f iTerm=%.5f dTerm=%.5f", scheduleMsg(logging, "%s status: value=%f input=%f/target=%f iTerm=%.5f dTerm=%.5f",
msg,
prevResult, prevResult,
prevInput, prevInput,
prevTarget, prevTarget,

View File

@ -20,8 +20,8 @@ class Pid {
public: public:
Pid(); Pid();
Pid(pid_s *pid, float minResult, float maxResult); Pid(pid_s *pid);
void init(pid_s *pid, float minResult, float maxResult); void init(pid_s *pid);
bool isSame(pid_s *pid); bool isSame(pid_s *pid);
float getValue(float target, float input); float getValue(float target, float input);
@ -42,7 +42,7 @@ public:
float maxResult; float maxResult;
float iTerm; float iTerm;
float dTerm; // we are remembering this only for debugging purposes float dTerm; // we are remembering this only for debugging purposes
void showPidStatus(Logging *logging, const char*msg, int dTime); void showPidStatus(Logging *logging, const char*msg);
void sleep(); void sleep();
private: private:
pid_s *pid; pid_s *pid;

View File

@ -124,7 +124,7 @@ bool hasPedalPositionSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE) { percent_t getPedalPosition(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
float voltage = getVoltageDivided("pPS", engineConfiguration->pedalPositionChannel); float voltage = getVoltageDivided("pPS", engineConfiguration->pedalPositionChannel);
float result = interpolate(engineConfiguration->pedalPositionMin, 0, engineConfiguration->pedalPositionMax, 100, voltage); float result = interpolate(engineConfiguration->throttlePedalUpVoltage, 0, engineConfiguration->throttlePedalWOTVoltage, 100, voltage);
// this would put the value into the 0-100 range // this would put the value into the 0-100 range
return maxF(0, minF(100, result)); return maxF(0, minF(100, result));
@ -144,6 +144,14 @@ percent_t getTPS(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return getPrimatyRawTPS(PASS_ENGINE_PARAMETER_SIGNATURE); return getPrimatyRawTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
} }
void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// see http://rusefi.com/wiki/index.php?title=Vehicle:VW_Passat_2002_1.8
engineConfiguration->tpsMin = 159;
engineConfiguration->tpsMax = 957;
// todo: add 2nd TPS sensor calibration
}
int convertVoltageTo10bitADC(float voltage) { int convertVoltageTo10bitADC(float voltage) {
// divided by 2 because of voltage divider, then converted into 10bit ADC value (TunerStudio format) // divided by 2 because of voltage divider, then converted into 10bit ADC value (TunerStudio format)
return (int) (voltage / 2 * 1024 / 3.3); return (int) (voltage / 2 * 1024 / 3.3);

View File

@ -29,6 +29,7 @@ int convertVoltageTo10bitADC(float voltage);
int getTPS12bitAdc(DECLARE_ENGINE_PARAMETER_SIGNATURE); int getTPS12bitAdc(DECLARE_ENGINE_PARAMETER_SIGNATURE);
float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE); float getTPSVoltage(DECLARE_ENGINE_PARAMETER_SIGNATURE);
percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX); percent_t getTpsValue(int adc DECLARE_ENGINE_PARAMETER_SUFFIX);
void setBosch0280750009(DECLARE_ENGINE_PARAMETER_SIGNATURE);
typedef struct { typedef struct {
efitimeus_t prevTime; efitimeus_t prevTime;

View File

@ -882,6 +882,8 @@ static void enableOrDisable(const char *param, bool isEnabled) {
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
} else if (strEqualCaseInsensitive(param, "HIP9011")) { } else if (strEqualCaseInsensitive(param, "HIP9011")) {
boardConfiguration->isHip9011Enabled = isEnabled; boardConfiguration->isHip9011Enabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "verbose_etb")) {
engineConfiguration->isVerboseETB = isEnabled;
} else if (strEqualCaseInsensitive(param, "verbose_idle")) { } else if (strEqualCaseInsensitive(param, "verbose_idle")) {
engineConfiguration->isVerboseIAC = isEnabled; engineConfiguration->isVerboseIAC = isEnabled;
} else if (strEqualCaseInsensitive(param, "auxdebug1")) { } else if (strEqualCaseInsensitive(param, "auxdebug1")) {

View File

@ -123,7 +123,7 @@ static efitimeus_t togglePwmState(PwmConfig *state) {
efitimeus_t nextSwitchTimeUs = getNextSwitchTimeUs(state); efitimeus_t nextSwitchTimeUs = getNextSwitchTimeUs(state);
#if DEBUG_PWM #if DEBUG_PWM
scheduleMsg(&logger, "%s: nextSwitchTime %d", state->name, nextSwitchTime); scheduleMsg(&logger, "%s: nextSwitchTime %d", state->name, nextSwitchTime);
#endif #endif /* DEBUG_PWM */
// signed value is needed here // signed value is needed here
// int64_t timeToSwitch = nextSwitchTimeUs - getTimeNowUs(); // int64_t timeToSwitch = nextSwitchTimeUs - getTimeNowUs();
// if (timeToSwitch < 1) { // if (timeToSwitch < 1) {

View File

@ -69,7 +69,7 @@ static const char *prevOutputName = NULL;
static Logging *logger; static Logging *logger;
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
static pid_s *fuelPidS = &persistentState.persistentConfiguration.engineConfiguration.fuelClosedLoopPid; static pid_s *fuelPidS = &persistentState.persistentConfiguration.engineConfiguration.fuelClosedLoopPid;
static Pid fuelPid(fuelPidS, -100, 100); static Pid fuelPid(fuelPidS);
extern TunerStudioOutputChannels tsOutputChannels; extern TunerStudioOutputChannels tsOutputChannels;
#endif #endif

View File

@ -55,7 +55,9 @@ typedef enum {
void initHip9011(Logging *sharedLogger); void initHip9011(Logging *sharedLogger);
void setHip9011FrankensoPinout(void); void setHip9011FrankensoPinout(void);
#if HAL_USE_ADC
void hipAdcCallback(adcsample_t value); void hipAdcCallback(adcsample_t value);
#endif /* HAL_USE_ADC */
void setHipGain(float value); void setHipGain(float value);
void setHipBand(float value); void setHipBand(float value);
void setPrescalerAndSDO(int value); void setPrescalerAndSDO(int value);

View File

@ -234,7 +234,10 @@ void applyNewHardwareSettings(void) {
stopInjectionPins(); stopInjectionPins();
stopIgnitionPins(); stopIgnitionPins();
stopCanPins(); stopCanPins();
stopETBPins(); bool etbRestartNeeded = isETBRestartNeeded();
if (etbRestartNeeded) {
stopETBPins();
}
stopVSSPins(); stopVSSPins();
stopAuxPins(); stopAuxPins();
@ -293,7 +296,9 @@ void applyNewHardwareSettings(void) {
startInjectionPins(); startInjectionPins();
startIgnitionPins(); startIgnitionPins();
startCanPins(); startCanPins();
startETBPins(); if (etbRestartNeeded) {
startETBPins();
}
startVSSPins(); startVSSPins();
startAuxPins(); startAuxPins();

View File

@ -90,10 +90,11 @@ iomode_t getInputMode(pin_input_mode_e mode) {
} }
} }
#if HAL_USE_ICU || defined(__DOXYGEN__)
void efiIcuStart(ICUDriver *icup, const ICUConfig *config) { void efiIcuStart(ICUDriver *icup, const ICUConfig *config) {
efiAssertVoid((icup->state == ICU_STOP) || (icup->state == ICU_READY), efiAssertVoid((icup->state == ICU_STOP) || (icup->state == ICU_READY),
"input already used?"); "input already used?");
icuStart(icup, config); icuStart(icup, config);
} }
#endif /* HAL_USE_ICU */

View File

@ -58,7 +58,9 @@ void efiSetPadMode(const char *msg, brain_pin_e pin, iomode_t mode);
bool efiReadPin(brain_pin_e pin); bool efiReadPin(brain_pin_e pin);
iomode_t getInputMode(pin_input_mode_e mode); iomode_t getInputMode(pin_input_mode_e mode);
#if HAL_USE_ICU || defined(__DOXYGEN__)
void efiIcuStart(ICUDriver *icup, const ICUConfig *config); void efiIcuStart(ICUDriver *icup, const ICUConfig *config);
#endif /* HAL_USE_ICU */
#endif /* EFI_GPIO_HARDWARE */ #endif /* EFI_GPIO_HARDWARE */

View File

@ -374,9 +374,7 @@ custom spi_device_e 4 bits,U32, @OFFSET@, [0:1], "Off", "SPI1", "SPI2", "SPI3"
float globalFuelCorrection;;"coef", 1, 0.0, 0, 1000.0, 2 float globalFuelCorrection;;"coef", 1, 0.0, 0, 1000.0, 2
int unusedAnother;
int16_t pedalPositionMin;;"ADC", 1, 0, 0, 1023, 0
int16_t pedalPositionMax;;"ADC", 1, 0, 0, 1023, 0
float maxKnockSubDeg;maximum total number of degrees to subtract from ignition advance\nwhen knocking float maxKnockSubDeg;maximum total number of degrees to subtract from ignition advance\nwhen knocking
adc_channel_e mafAdcChannel;See hasMafSensor adc_channel_e mafAdcChannel;See hasMafSensor
@ -591,7 +589,7 @@ board_configuration_s bc;
bit vvtDisplayInverted bit vvtDisplayInverted
bit fuelClosedLoopCorrectionEnabled bit fuelClosedLoopCorrectionEnabled
bit isVerboseIAC bit isVerboseIAC
bit isVerboseETB bit isVerboseETB;enable verbose_etb
bit useConstantDwellDuringCranking bit useConstantDwellDuringCranking
bit isEngineChartEnabled;This options enables data for 'engine sniffer' tab in console, which comes at some CPU price bit isEngineChartEnabled;This options enables data for 'engine sniffer' tab in console, which comes at some CPU price
bit silentTriggerError bit silentTriggerError
@ -705,7 +703,10 @@ custom pin_mode_e 4 bits, U32, @OFFSET@, [0:5], @@pin_mode_e_enum@@
brain_pin_e consoleSerialRxPin;todo: finish pin migration from hard-coded to configurable? brain_pin_e consoleSerialRxPin;todo: finish pin migration from hard-coded to configurable?
float[ENGINE_NOISE_CURVE_SIZE] knockNoise;Knock sensor output knock detection threshold depending on current RPM;"v", 1, 0, 0.0, 10, 2 float[ENGINE_NOISE_CURVE_SIZE] knockNoise;Knock sensor output knock detection threshold depending on current RPM;"v", 1, 0, 0.0, 10, 2
float[ENGINE_NOISE_CURVE_SIZE] knockNoiseRpmBins;;"RPM", 1, 0, 0.0, 18000, 2 float[ENGINE_NOISE_CURVE_SIZE] knockNoiseRpmBins;;"RPM", 1, 0, 0.0, 18000, 2
float[4] unusedetb;
float throttlePedalUpVoltage;;"voltage", 1, 0, -6, 6, 2
float throttlePedalWOTVoltage;+Pedal in the floor;"voltage", 1, 0, -6, 6, 2
float[2] unusedetb;
float[CLT_CURVE_SIZE] cltIdleRpmBins;CLT-based target RPM for automatic idle controller;"C", 1, 0, -100.0, 250.0, 2 float[CLT_CURVE_SIZE] cltIdleRpmBins;CLT-based target RPM for automatic idle controller;"C", 1, 0, -100.0, 250.0, 2
float[CLT_CURVE_SIZE] cltIdleRpm;;"RPM", 1, 0, 0.0, 400.0, 0 float[CLT_CURVE_SIZE] cltIdleRpm;;"RPM", 1, 0, 0.0, 400.0, 0
@ -782,7 +783,7 @@ float[MAP_ACCEL_TAPER] mapAccelTaperMult;;"mult", 1, 0, 0.0, 300,
int16_t fuelClosedLoopCltThreshold;;"C", 1, 0, 0, 100, 0 int16_t fuelClosedLoopCltThreshold;;"C", 1, 0, 0, 100, 0
int16_t fuelClosedLoopTpsThreshold;;"%", 1, 0, 0, 100, 0 int16_t fuelClosedLoopTpsThreshold;;"%", 1, 0, 0, 100, 0
int16_t fuelClosedLoopRpmThreshold;;"rpm", 1, 0, 0, 5000, 0 int16_t fuelClosedLoopRpmThreshold;;"rpm", 1, 0, 0, 5000, 0
int16_t etbFreq;;"Hz", 1, 0, 0, 500, 10 int16_t etbFreq;;"Hz", 1, 0, 0, 1500, 0
pid_s fuelClosedLoopPid; pid_s fuelClosedLoopPid;
float fuelClosedLoopAfrHighThreshold;;"ratio", 1, 0, 0, 100, 1 float fuelClosedLoopAfrHighThreshold;;"ratio", 1, 0, 0, 100, 1
pin_mode_e stepperEnablePinMode; pin_mode_e stepperEnablePinMode;

View File

@ -251,5 +251,5 @@ int getRusEfiVersion(void) {
return 123; // this is here to make the compiler happy about the unused array return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0) if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array return 3211; // this is here to make the compiler happy about the unused array
return 20170528; return 20170529;
} }

View File

@ -45,7 +45,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code ; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START ; CONFIG_DEFINITION_START
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun May 28 22:30:58 EDT 2017 ; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon May 29 22:21:18 EDT 2017
pageSize = 16376 pageSize = 16376
page = 1 page = 1
@ -169,8 +169,7 @@ page = 1
trigger_unusedcustomUseRiseEdge = bits, U32, 560, [0:0], "false", "true" trigger_unusedcustomUseRiseEdge = bits, U32, 560, [0:0], "false", "true"
hip9011SpiDevice = bits,U32, 564, [0:1], "Off", "SPI1", "SPI2", "SPI3" hip9011SpiDevice = bits,U32, 564, [0:1], "Off", "SPI1", "SPI2", "SPI3"
globalFuelCorrection = scalar, F32, 568, "coef", 1, 0.0, 0, 1000.0, 2 globalFuelCorrection = scalar, F32, 568, "coef", 1, 0.0, 0, 1000.0, 2
pedalPositionMin = scalar, S16, 572, "ADC", 1, 0, 0, 1023, 0 ;skipping unusedAnother offset 572
pedalPositionMax = scalar, S16, 574, "ADC", 1, 0, 0, 1023, 0
;skipping maxKnockSubDeg offset 576 ;skipping maxKnockSubDeg offset 576
mafAdcChannel = bits, U32, 580, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" mafAdcChannel = bits, U32, 580, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
afr_hwChannel = bits, U32, 584, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" afr_hwChannel = bits, U32, 584, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
@ -550,7 +549,9 @@ page = 1
consoleSerialRxPin = bits, U32, 1944, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" consoleSerialRxPin = bits, U32, 1944, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
knockNoise = array, F32, 1948, [8], "v", 1, 0, 0.0, 10, 2 knockNoise = array, F32, 1948, [8], "v", 1, 0, 0.0, 10, 2
knockNoiseRpmBins = array, F32, 1980, [8], "RPM", 1, 0, 0.0, 18000, 2 knockNoiseRpmBins = array, F32, 1980, [8], "RPM", 1, 0, 0.0, 18000, 2
;skipping unusedetb offset 2012 throttlePedalUpVoltage = scalar, F32, 2012, "voltage", 1, 0, -6, 6, 2
throttlePedalWOTVoltage = scalar, F32, 2016, "voltage", 1, 0, -6, 6, 2
;skipping unusedetb offset 2020
cltIdleRpmBins = array, F32, 2028, [16], "C", 1, 0, -100.0, 250.0, 2 cltIdleRpmBins = array, F32, 2028, [16], "C", 1, 0, -100.0, 250.0, 2
cltIdleRpm = array, F32, 2092, [16], "RPM", 1, 0, 0.0, 400.0, 0 cltIdleRpm = array, F32, 2092, [16], "RPM", 1, 0, 0.0, 400.0, 0
targetVBatt = scalar, F32, 2156, "Volts", 1, 0, 0,30, 1 targetVBatt = scalar, F32, 2156, "Volts", 1, 0, 0,30, 1
@ -643,7 +644,7 @@ page = 1
fuelClosedLoopCltThreshold = scalar, S16, 2732, "C", 1, 0, 0, 100, 0 fuelClosedLoopCltThreshold = scalar, S16, 2732, "C", 1, 0, 0, 100, 0
fuelClosedLoopTpsThreshold = scalar, S16, 2734, "%", 1, 0, 0, 100, 0 fuelClosedLoopTpsThreshold = scalar, S16, 2734, "%", 1, 0, 0, 100, 0
fuelClosedLoopRpmThreshold = scalar, S16, 2736, "rpm", 1, 0, 0, 5000, 0 fuelClosedLoopRpmThreshold = scalar, S16, 2736, "rpm", 1, 0, 0, 5000, 0
etbFreq = scalar, S16, 2738, "Hz", 1, 0, 0, 500, 10 etbFreq = scalar, S16, 2738, "Hz", 1, 0, 0, 1500, 0
fuelClosedLoopPid_pFactor = scalar, F32, 2740, "value", 1, 0, -1000, 1000, 5 fuelClosedLoopPid_pFactor = scalar, F32, 2740, "value", 1, 0, -1000, 1000, 5
fuelClosedLoopPid_iFactor = scalar, F32, 2744, "value", 1, 0, -1000, 1000, 5 fuelClosedLoopPid_iFactor = scalar, F32, 2744, "value", 1, 0, -1000, 1000, 5
fuelClosedLoopPid_dFactor = scalar, F32, 2748, "value", 1, 0, -1000, 1000, 5 fuelClosedLoopPid_dFactor = scalar, F32, 2748, "value", 1, 0, -1000, 1000, 5
@ -806,6 +807,7 @@ page = 1
ignMathCalculateAtIndex = "At what trigger index should some ignition-related math be executed? This is a performance trick to reduce load on synchronization trigger callback." ignMathCalculateAtIndex = "At what trigger index should some ignition-related math be executed? This is a performance trick to reduce load on synchronization trigger callback."
mapAveragingSchedulingAtIndex = "At what trigger index should some MAP-related math be executed? This is a performance trick to reduce load on synchronization trigger callback." mapAveragingSchedulingAtIndex = "At what trigger index should some MAP-related math be executed? This is a performance trick to reduce load on synchronization trigger callback."
tachPulseTriggerIndex = "Trigger cycle index at which we start tach pulse (performance consideration)" tachPulseTriggerIndex = "Trigger cycle index at which we start tach pulse (performance consideration)"
throttlePedalWOTVoltage = "Pedal in the floor"
slowAdcAlpha = "ExpAverage alpha coefficient" slowAdcAlpha = "ExpAverage alpha coefficient"
dizzySparkOutputPin = "This implementation makes a pulse every time one of the coils is charged. See also tachOutputPin" dizzySparkOutputPin = "This implementation makes a pulse every time one of the coils is charged. See also tachOutputPin"
@ -2388,8 +2390,8 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
dialog = etbDialog, "Electronic Thtottle Body (alpha)" dialog = etbDialog, "Electronic Thtottle Body (alpha)"
field = "pedal Position Channel", pedalPositionChannel field = "pedal Position Channel", pedalPositionChannel
field = "verbose", isVerboseETB field = "verbose", isVerboseETB
field = "Pedal min", pedalPositionMin field = "Throttle Pedal Up", throttlePedalUpVoltage
field = "Pedal max", pedalPositionMax field = "Throttle Pedal Wide Open", throttlePedalWOTVoltage
field = "PWM Frequency", etbFreq field = "PWM Frequency", etbFreq
field = "Dir #1", etbDirectionPin1 field = "Dir #1", etbDirectionPin1
field = "Dir #2", etbDirectionPin2 field = "Dir #2", etbDirectionPin2

View File

@ -1626,8 +1626,8 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
dialog = etbDialog, "Electronic Thtottle Body (alpha)" dialog = etbDialog, "Electronic Thtottle Body (alpha)"
field = "pedal Position Channel", pedalPositionChannel field = "pedal Position Channel", pedalPositionChannel
field = "verbose", isVerboseETB field = "verbose", isVerboseETB
field = "Pedal min", pedalPositionMin field = "Throttle Pedal Up", throttlePedalUpVoltage
field = "Pedal max", pedalPositionMax field = "Throttle Pedal Wide Open", throttlePedalWOTVoltage
field = "PWM Frequency", etbFreq field = "PWM Frequency", etbFreq
field = "Dir #1", etbDirectionPin1 field = "Dir #1", etbDirectionPin1
field = "Dir #2", etbDirectionPin2 field = "Dir #2", etbDirectionPin2

View File

@ -1,6 +1,6 @@
package com.rusefi.config; package com.rusefi.config;
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun May 28 22:30:58 EDT 2017 // this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon May 29 22:21:18 EDT 2017
public class Fields { public class Fields {
public static final int LE_COMMAND_LENGTH = 200; public static final int LE_COMMAND_LENGTH = 200;
public static final int FSIO_ADC_COUNT = 4; public static final int FSIO_ADC_COUNT = 4;
@ -249,8 +249,7 @@ public class Fields {
public static final int hip9011SpiDevice_offset_hex = 234; public static final int hip9011SpiDevice_offset_hex = 234;
public static final int globalFuelCorrection_offset = 568; public static final int globalFuelCorrection_offset = 568;
public static final int globalFuelCorrection_offset_hex = 238; public static final int globalFuelCorrection_offset_hex = 238;
public static final int pedalPositionMin_offset = 572; public static final int unusedAnother_offset = 572;
public static final int pedalPositionMax_offset = 574;
public static final int maxKnockSubDeg_offset = 576; public static final int maxKnockSubDeg_offset = 576;
public static final int maxKnockSubDeg_offset_hex = 240; public static final int maxKnockSubDeg_offset_hex = 240;
public static final int mafAdcChannel_offset = 580; public static final int mafAdcChannel_offset = 580;
@ -799,7 +798,9 @@ public class Fields {
public static final int consoleSerialRxPin_offset_hex = 798; public static final int consoleSerialRxPin_offset_hex = 798;
public static final int knockNoise_offset = 1948; public static final int knockNoise_offset = 1948;
public static final int knockNoiseRpmBins_offset = 1980; public static final int knockNoiseRpmBins_offset = 1980;
public static final int unusedetb_offset = 2012; public static final int throttlePedalUpVoltage_offset = 2012;
public static final int throttlePedalWOTVoltage_offset = 2016;
public static final int unusedetb_offset = 2020;
public static final int cltIdleRpmBins_offset = 2028; public static final int cltIdleRpmBins_offset = 2028;
public static final int cltIdleRpm_offset = 2092; public static final int cltIdleRpm_offset = 2092;
public static final int targetVBatt_offset = 2156; public static final int targetVBatt_offset = 2156;
@ -1207,8 +1208,7 @@ public class Fields {
public static final Field TRIGGER_UNUSEDCUSTOMUSERISEEDGE = Field.create("TRIGGER_UNUSEDCUSTOMUSERISEEDGE", 560, FieldType.INT); public static final Field TRIGGER_UNUSEDCUSTOMUSERISEEDGE = Field.create("TRIGGER_UNUSEDCUSTOMUSERISEEDGE", 560, FieldType.INT);
public static final Field HIP9011SPIDEVICE = Field.create("HIP9011SPIDEVICE", 564, FieldType.INT); public static final Field HIP9011SPIDEVICE = Field.create("HIP9011SPIDEVICE", 564, FieldType.INT);
public static final Field GLOBALFUELCORRECTION = Field.create("GLOBALFUELCORRECTION", 568, FieldType.FLOAT); public static final Field GLOBALFUELCORRECTION = Field.create("GLOBALFUELCORRECTION", 568, FieldType.FLOAT);
public static final Field PEDALPOSITIONMIN = Field.create("PEDALPOSITIONMIN", 572, FieldType.INT); public static final Field UNUSEDANOTHER = Field.create("UNUSEDANOTHER", 572, FieldType.INT);
public static final Field PEDALPOSITIONMAX = Field.create("PEDALPOSITIONMAX", 574, FieldType.INT);
public static final Field MAXKNOCKSUBDEG = Field.create("MAXKNOCKSUBDEG", 576, FieldType.FLOAT); public static final Field MAXKNOCKSUBDEG = Field.create("MAXKNOCKSUBDEG", 576, FieldType.FLOAT);
public static final Field MAFADCCHANNEL = Field.create("MAFADCCHANNEL", 580, FieldType.INT, adc_channel_e); public static final Field MAFADCCHANNEL = Field.create("MAFADCCHANNEL", 580, FieldType.INT, adc_channel_e);
public static final Field AFR_HWCHANNEL = Field.create("AFR_HWCHANNEL", 584, FieldType.INT, adc_channel_e); public static final Field AFR_HWCHANNEL = Field.create("AFR_HWCHANNEL", 584, FieldType.INT, adc_channel_e);
@ -1586,6 +1586,8 @@ public class Fields {
public static final Field BINARYSERIALRXPIN = Field.create("BINARYSERIALRXPIN", 1936, FieldType.INT, brain_pin_e); public static final Field BINARYSERIALRXPIN = Field.create("BINARYSERIALRXPIN", 1936, FieldType.INT, brain_pin_e);
public static final Field CONSOLESERIALTXPIN = Field.create("CONSOLESERIALTXPIN", 1940, FieldType.INT, brain_pin_e); public static final Field CONSOLESERIALTXPIN = Field.create("CONSOLESERIALTXPIN", 1940, FieldType.INT, brain_pin_e);
public static final Field CONSOLESERIALRXPIN = Field.create("CONSOLESERIALRXPIN", 1944, FieldType.INT, brain_pin_e); public static final Field CONSOLESERIALRXPIN = Field.create("CONSOLESERIALRXPIN", 1944, FieldType.INT, brain_pin_e);
public static final Field THROTTLEPEDALUPVOLTAGE = Field.create("THROTTLEPEDALUPVOLTAGE", 2012, FieldType.FLOAT);
public static final Field THROTTLEPEDALWOTVOLTAGE = Field.create("THROTTLEPEDALWOTVOLTAGE", 2016, FieldType.FLOAT);
public static final Field TARGETVBATT = Field.create("TARGETVBATT", 2156, FieldType.FLOAT); public static final Field TARGETVBATT = Field.create("TARGETVBATT", 2156, FieldType.FLOAT);
public static final Field ALTERNATOROFFABOVETPS = Field.create("ALTERNATOROFFABOVETPS", 2160, FieldType.FLOAT); public static final Field ALTERNATOROFFABOVETPS = Field.create("ALTERNATOROFFABOVETPS", 2160, FieldType.FLOAT);
public static final Field TPSACCELLENGTH = Field.create("TPSACCELLENGTH", 2184, FieldType.INT); public static final Field TPSACCELLENGTH = Field.create("TPSACCELLENGTH", 2184, FieldType.INT);

BIN
java_tools/bin2header.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,24 @@
<project default="jar">
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build/classes"/>
<javac destdir="build/classes" classpath="lib/junit.jar:lib/annotations.jar">
<src path="src"/>
</javac>
</target>
<target name="jar" depends="compile">
<mkdir dir="build/jar"/>
<jar destfile="../bin2header.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="rusefi.Bin2Header"/>
</manifest>
<zipfileset dir="build/classes" includes="**/*.class"/>
</jar>
</target>
</project>

View File

@ -0,0 +1,64 @@
package rusefi;
import java.io.*;
import java.nio.file.*;
import java.util.Date;
public class Bin2Header {
private static final String NL = "\n";//System.getProperty("line.separator");
private final static char[] hexChars = "0123456789abcdef".toCharArray();
private Bin2Header() {
}
public static void main(String[] args) throws IOException {
if (args.length < 3) {
System.out.println("This tool converts a binary file to C/C++ header file");
System.out.println("usage:");
System.out.println("Bin2Header in_file.bin out_file.h arrayVariableDecl");
return;
}
String binFile = args[0];
String hFile = args[1];
String arrayVariableDecl = args[2];
System.out.println("Converting " + binFile + " into " + hFile);
// This will reference one line at a time
String line = null;
BufferedWriter bw = new BufferedWriter(new FileWriter(hFile));
Path path = Paths.get(binFile);
byte[] data = Files.readAllBytes(path);
String headerTag = hFile;
int pos = headerTag.lastIndexOf("/");
if (pos >= 0)
headerTag = headerTag.substring(pos + 1);
headerTag = headerTag.toUpperCase().replace(".", "_") + "_";
bw.write("// This file was generated by Bin2Header" + NL);
bw.write("// " + new Date() + NL);
bw.write("#ifndef " + headerTag + NL);
bw.write("#define " + headerTag + NL + NL);
bw.write(arrayVariableDecl + " = {");
for (int i = 0; i < data.length; i++) {
if ((i & 0xf) == 0)
bw.write(NL + "\t");
int b = data[i] & 0xFF;
bw.write("0x");
bw.write(hexChars[b >>> 4]);
bw.write(hexChars[b & 0xf]);
bw.write(", ");
}
bw.write(NL + "};" + NL + NL);
bw.write("#endif /* " + headerTag + " */" + NL + NL);
bw.close();
}
}

View File

@ -19,8 +19,10 @@ void testPidController(void) {
pidS.iFactor = 0.5; pidS.iFactor = 0.5;
pidS.dFactor = 0; pidS.dFactor = 0;
pidS.offset = 0; pidS.offset = 0;
pidS.minValue = 10;
pidS.maxValue = 90;
Pid pid(&pidS, 10, 90); Pid pid(&pidS);
assertEqualsM("getValue#90", 90, pid.getValue(14, 12, 0.1)); assertEqualsM("getValue#90", 90, pid.getValue(14, 12, 0.1));