auto-sync

This commit is contained in:
rusEfi 2015-11-09 19:03:32 -05:00
parent cb1d166ab5
commit 153151acb1
17 changed files with 72 additions and 46 deletions

View File

@ -274,10 +274,6 @@
// todo: this should be detected automatically based on pin selection
#define EFI_CONSOLE_AF 7
#define TS_SERIAL_TX_PORT GPIOC
#define TS_SERIAL_TX_PIN 10
#define TS_SERIAL_RX_PORT GPIOC
#define TS_SERIAL_RX_PIN 11
// todo: this should be detected automatically based on pin selection
#define TS_SERIAL_AF 7

View File

@ -146,8 +146,10 @@ static void printErrorCounters(void) {
void printTsStats(void) {
#if EFI_PROD_CODE
if (!isSerialOverUart()) {
scheduleMsg(&tsLogger, "TS RX on %s%d/TX on %s%d @%d", portname(TS_SERIAL_RX_PORT), TS_SERIAL_RX_PIN,
portname(TS_SERIAL_TX_PORT), TS_SERIAL_TX_PIN, boardConfiguration->tunerStudioSerialSpeed);
scheduleMsg(&tsLogger, "TS RX on %s", hwPortname(engineConfiguration->binarySerialRxPin));
scheduleMsg(&tsLogger, "TS TX on %s @%d", hwPortname(engineConfiguration->binarySerialTxPin),
boardConfiguration->tunerStudioSerialSpeed);
}
#endif /* EFI_PROD_CODE */

View File

@ -41,14 +41,14 @@ void startTsPort(void) {
{
if (boardConfiguration->useSerialPort) {
print("TunerStudio over USART");
mySetPadMode("tunerstudio rx", TS_SERIAL_RX_PORT, TS_SERIAL_RX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
mySetPadMode("tunerstudio tx", TS_SERIAL_TX_PORT, TS_SERIAL_TX_PIN, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
print("TunerStudio over USART");
mySetPadMode2("tunerstudio rx", engineConfiguration->binarySerialRxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
mySetPadMode2("tunerstudio tx", engineConfiguration->binarySerialTxPin, PAL_MODE_ALTERNATE(TS_SERIAL_AF));
tsSerialConfig.speed = boardConfiguration->tunerStudioSerialSpeed;
tsSerialConfig.speed = boardConfiguration->tunerStudioSerialSpeed;
sdStart(TS_SERIAL_UART_DEVICE, &tsSerialConfig);
}
sdStart(TS_SERIAL_UART_DEVICE, &tsSerialConfig);
}
}
}

View File

@ -74,7 +74,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
return engineConfiguration->step1timing;
}
float iatCorrection = iatAdvanceCorrectionMap.getValue(engine->engineState.clt, (float) rpm);
float iatCorrection = iatAdvanceCorrectionMap.getValue(engine->engineState.iat, (float) rpm);
float result = advanceMap.getValue(engineLoad, (float) rpm) + iatCorrection
// todo: uncomment once we get useable knock - engine->knockCount

View File

@ -1,4 +1,4 @@
// this section was generated by config_definition.jar on Thu Oct 22 12:50:05 EDT 2015
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Nov 08 18:16:16 EST 2015
// begin
#include "rusefi_types.h"
typedef struct {
@ -1468,6 +1468,7 @@ typedef struct {
*/
float crankingCycleBins[CRANKING_CURVE_SIZE];
/**
* CLT-based adjustment for simple manual idle controller
* offset 6200
*/
float cltIdleCorrBins[CLT_CURVE_SIZE];
@ -1562,4 +1563,4 @@ typedef struct {
} persistent_config_s;
// end
// this section was generated by config_definition.jar on Thu Oct 22 12:50:05 EDT 2015
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Nov 08 18:16:16 EST 2015

View File

@ -236,7 +236,18 @@ typedef enum {
} log_format_e;
typedef enum {
IM_AUTO = 0, IM_MANUAL = 1, Force_4b_idle_mode = ENUM_32_BITS,
/**
* In auto mode we currently have some pid-like-but-not really PID logic which is trying
* to get idle RPM to desired value by dynamically adjusting idle valve position.
* TODO: convert to PID
*/
IM_AUTO = 0,
/**
* Manual idle control is extremely simple: user just specifies desired idle valve position
* which could be adjusted according to current CLT
*/
IM_MANUAL = 1,
Force_4b_idle_mode = ENUM_32_BITS,
} idle_mode_e;
typedef enum {

View File

@ -21,6 +21,7 @@
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "main.h"
@ -41,6 +42,7 @@ static Logging *logger;
EXTERN_ENGINE
;
// todo: extract interface for idle valve hardware, with solenoid and stepper implementations?
static OutputPin idleSolenoidPin;
static SimplePwm idleSolenoid;
@ -53,8 +55,9 @@ static float actualIdlePosition = -100.0f;
/**
* Idle level calculation algorithm lives in idle_controller.cpp
* todo: replace this with a PID regulator?
*/
static IdleValveState idleMath;
static IdleValveState idlePositionController;
void idleDebug(const char *msg, percent_t value) {
scheduleMsg(logger, "idle debug: %s%f", msg, value);
@ -93,7 +96,7 @@ static void setIdleValvePwm(percent_t value) {
idleSolenoid.setSimplePwmDutyCycle(value / 100);
}
static void doSetIdleValvePosition(int positionPercent) {
static void manualIdleController(int positionPercent) {
// todo: this is not great that we have to write into configuration here
boardConfiguration->manIdlePosition = positionPercent;
@ -121,7 +124,7 @@ static void setIdleValvePosition(int positionPercent) {
return;
scheduleMsg(logger, "setting idle valve position %d", positionPercent);
showIdleInfo();
doSetIdleValvePosition(positionPercent);
manualIdleController(positionPercent);
}
static int idlePositionBeforeBlip;
@ -131,6 +134,7 @@ static efitimeus_t timeToStopBlip = 0;
* I use this questionable feature to tune acceleration enrichment
*/
static void blipIdle(int idlePosition, int durationMs) {
// todo: add 'blip' feature for automatic target control
if (timeToStopBlip != 0) {
return; // already in idle blip
}
@ -177,13 +181,13 @@ static msg_t ivThread(int param) {
if (engineConfiguration->idleMode != IM_AUTO) {
// let's re-apply CLT correction
doSetIdleValvePosition(boardConfiguration->manIdlePosition);
manualIdleController(boardConfiguration->manIdlePosition);
continue;
}
efitimems_t now = currentTimeMillis();
percent_t newValue = idleMath.getIdle(getRpm(), now PASS_ENGINE_PARAMETER);
percent_t newValue = idlePositionController.getIdle(getRpm(), now PASS_ENGINE_PARAMETER);
if (currentIdleValve != newValue) {
currentIdleValve = newValue;
@ -198,10 +202,11 @@ static msg_t ivThread(int param) {
#endif
}
static void setIdleRpmAction(int value) {
idleMath.setTargetRpm(value);
static void setTargetRpm(int value) {
idlePositionController.setTargetRpm(value);
scheduleMsg(logger, "target idle RPM %d", value);
}
static void apply(void) {
// idleMath.updateFactors(engineConfiguration->idlePFactor, engineConfiguration->idleIFactor, engineConfiguration->idleDFactor, engineConfiguration->idleDT);
}
@ -246,9 +251,7 @@ static void applyIdleSolenoidPinState(PwmConfig *state, int stateIndex) {
output->setValue(value);
}
void startIdleThread(Logging*sharedLogger, Engine *engine) {
logger = sharedLogger;
static void initIdleHardware() {
if (boardConfiguration->useStepperIdle) {
iacMotor.initialize(boardConfiguration->idle.stepperStepPin, boardConfiguration->idle.stepperDirectionPin,
engineConfiguration->idleStepperReactionTime, engineConfiguration->idleStepperTotalSteps,
@ -261,9 +264,16 @@ void startIdleThread(Logging*sharedLogger, Engine *engine) {
boardConfiguration->idle.solenoidFrequency, boardConfiguration->manIdlePosition / 100,
applyIdleSolenoidPinState);
}
}
idleMath.init();
scheduleMsg(logger, "initial idle %d", idleMath.value);
void startIdleThread(Logging*sharedLogger, Engine *engine) {
logger = sharedLogger;
// todo: re-initialize idle pins on the fly
initIdleHardware();
idlePositionController.init();
scheduleMsg(logger, "initial idle %d", idlePositionController.value);
chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL);
@ -278,7 +288,6 @@ void startIdleThread(Logging*sharedLogger, Engine *engine) {
getInputMode(boardConfiguration->clutchUpPinMode));
addConsoleAction("idleinfo", showIdleInfo);
addConsoleActionI("set_idle_rpm", setIdleRpmAction);
addConsoleActionI("set_idle_position", setIdleValvePosition);
@ -286,6 +295,9 @@ void startIdleThread(Logging*sharedLogger, Engine *engine) {
addConsoleActionII("blipidle", blipIdle);
// split this whole file into manual controller and auto controller? move these commands into the file
// which would be dedicated to just auto-controller?
addConsoleActionI("set_idle_rpm", setTargetRpm);
addConsoleActionF("set_idle_p", setIdlePFactor);
addConsoleActionF("set_idle_i", setIdleIFactor);
addConsoleActionF("set_idle_d", setIdleDFactor);

View File

@ -636,7 +636,7 @@ float[IAT_CURVE_SIZE] iatFuelCorr;;"%", 1, 0, 0.0, 500.0, 2
float[CRANKING_CURVE_SIZE] crankingCycleCoef;;"%", 1, 0, 0.0, 500.0, 2
float[CRANKING_CURVE_SIZE] crankingCycleBins;;"C", 1, 0, -80.0, 170.0, 2
float[CLT_CURVE_SIZE] cltIdleCorrBins;;"C", 1, 0, -100.0, 250.0, 2
float[CLT_CURVE_SIZE] cltIdleCorrBins;CLT-based adjustment for simple manual idle controller;"C", 1, 0, -100.0, 250.0, 2
float[CLT_CURVE_SIZE] cltIdleCorr;;"%", 1, 0, 0.0, 500.0, 2
float[MAF_DECODING_COUNT] mafDecoding;kg/hour value.\nBy the way 2.081989116 kg/h = 1 ft³/m;"kg/hour", 1, 0, -500.0, 4000.0, 2

View File

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

View File

@ -1,5 +1,5 @@
// This file was generated by Version2Header
// Sat Oct 31 07:46:34 EDT 2015
// Thu Nov 05 15:22:06 EST 2015
#ifndef VCS_VERSION
#define VCS_VERSION "8950"
#define VCS_VERSION "8961"
#endif

View File

@ -40,7 +40,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated by ConfigDefinition.jar on Thu Oct 22 12:50:06 EDT 2015
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Nov 08 18:16:16 EST 2015
pageSize = 15288
page = 1
@ -813,7 +813,7 @@ fileVersion = { 20150625 }
table = ignitionIatCorrTableTbl, ignitionIatCorrTableMap, "Ignition Iat Corr Table", 1
; constant, variable
xBins = ignitionIatCorrRpmBins, rpm
yBins = ignitionIatCorrLoadBins, coolant
yBins = ignitionIatCorrLoadBins, intake
zBins = ignitionIatCorrTable
; gridHeight = 2.0
gridOrient = 250, 0, 340 ; Space 123 rotation of grid in degrees.

View File

@ -7,6 +7,7 @@
<module fileurl="file://$PROJECT_DIR$/logging/logging.iml" filepath="$PROJECT_DIR$/logging/logging.iml" />
<module fileurl="file://$PROJECT_DIR$/models/models.iml" filepath="$PROJECT_DIR$/models/models.iml" />
<module fileurl="file://$PROJECT_DIR$/romraider/romraider.iml" filepath="$PROJECT_DIR$/romraider/romraider.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/tools.iml" filepath="$PROJECT_DIR$/tools/tools.iml" />
<module fileurl="file://$PROJECT_DIR$/ui/ui.iml" filepath="$PROJECT_DIR$/ui/ui.iml" />
</modules>
</component>

View File

@ -15,6 +15,8 @@
<src path="ui/src"/>
<src path="romraider/src"/>
<src path="logging/src"/>
<!-- not really used at the moment but let's compile for the sake of Eclipse users -->
<src path="tools/src"/>
</javac>
<junit fork="no"

View File

@ -11,7 +11,7 @@ import java.util.List;
* (c) Andrey Belomutskiy
*/
public class FileUtils {
static void readFile(String filename, EngineState.EngineStateListener listener) {
public static void readFile(String filename, EngineState.EngineStateListener listener) {
readFile2(filename, new EngineState(listener));
}

View File

@ -1,7 +1,7 @@
package com.irnems;
import com.irnems.core.EngineState;
import com.irnems.file.FileUtils;
import com.rusefi.core.EngineState;
import com.rusefi.file.FileUtils;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,6 +1,7 @@
package com.irnems.file;
import com.irnems.core.EngineState;
import com.rusefi.core.EngineState;
import com.rusefi.file.FileUtils;
import java.io.FileOutputStream;
import java.io.IOException;

View File

@ -350,8 +350,8 @@ static void testRpmCalculator(void) {
assertEqualsM("queue size 3", 6, schedulingQueue.size());
assertEqualsM("ev 3", 258333, schedulingQueue.getForUnitText(0)->momentX);
assertEqualsM("ev 4", 258333, schedulingQueue.getForUnitText(1)->momentX);
assertEqualsM2("ev 5", 259892, schedulingQueue.getForUnitText(2)->momentX, 2);
assertEqualsM("3/3", 260392, schedulingQueue.getForUnitText(3)->momentX);
assertEqualsM2("ev 5", 259277, schedulingQueue.getForUnitText(2)->momentX, 2);
assertEqualsM("3/3", 259777, schedulingQueue.getForUnitText(3)->momentX);
schedulingQueue.clear();
timeNow += 5000;
@ -376,7 +376,7 @@ static void testRpmCalculator(void) {
assertEqualsM("queue size 6", 6, schedulingQueue.size());
assertEqualsM("6/0", 285000, schedulingQueue.getForUnitText(0)->momentX);
assertEqualsM("6/1", 285000, schedulingQueue.getForUnitText(1)->momentX);
assertEqualsM2("6/2", 286559, schedulingQueue.getForUnitText(2)->momentX, 1);
assertEqualsM2("6/2", 285944, schedulingQueue.getForUnitText(2)->momentX, 1);
schedulingQueue.clear();
timeNow += 5000;
@ -386,16 +386,16 @@ static void testRpmCalculator(void) {
timeNow += 5000; // 5ms
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
assertEqualsM("queue size 8", 5, schedulingQueue.size());
assertEqualsM("queue size 8", 6, schedulingQueue.size());
assertEqualsM("8/0", 298333, schedulingQueue.getForUnitText(0)->momentX);
assertEqualsM("8/1", 298333, schedulingQueue.getForUnitText(1)->momentX);
assertEqualsM2("8/2", 299892, schedulingQueue.getForUnitText(2)->momentX, 0);
assertEqualsM2("8/3", 301363, schedulingQueue.getForUnitText(3)->momentX, 0);
assertEqualsM2("8/2", 299277, schedulingQueue.getForUnitText(2)->momentX, 0);
assertEqualsM2("8/3", 299777, schedulingQueue.getForUnitText(3)->momentX, 0);
schedulingQueue.clear();
timeNow += 5000;
eth.engine.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_DOWN PASS_ENGINE_PARAMETER);
assertEqualsM("queue size 9", 1, schedulingQueue.size());
assertEqualsM("queue size 9", 0, schedulingQueue.size());
schedulingQueue.clear();
timeNow += 5000; // 5ms