auto-sync

This commit is contained in:
rusEfi 2016-01-22 13:02:51 -05:00
parent d00c2ce819
commit 6d675d2794
8 changed files with 37 additions and 24 deletions

View File

@ -53,7 +53,7 @@ typedef struct {
* With all corrections. See also baseFuel * With all corrections. See also baseFuel
*/ */
float pulseWidthMs; // 64 float pulseWidthMs; // 64
float unused68; // 68 float debugFloatField; // 68
/** /**
* Yes, I do not really enjoy packing bits into integers but we simply have too many boolean flags and I cannot * Yes, I do not really enjoy packing bits into integers but we simply have too many boolean flags and I cannot
* water 4 bytes per traffic - I want gauges to work as fast as possible * water 4 bytes per traffic - I want gauges to work as fast as possible
@ -104,12 +104,13 @@ typedef struct {
float wallFuelAmount; // 160 float wallFuelAmount; // 160
float iatCorrection; // 164 float iatCorrection; // 164
floatms_t wallFuelCorrection; // 168 floatms_t wallFuelCorrection; // 168
float idlePosition; float idlePosition; // 172
float currentTargetAfr; float currentTargetAfr; // 176
float chargeAirMass; float chargeAirMass; // 180
float cltCorrection; float cltCorrection; // 184
float runningFuel; float runningFuel; // 188
int unused3[1]; int debugIntField; // 192
int unused3[20];
} TunerStudioOutputChannels; } TunerStudioOutputChannels;
#endif /* TUNERSTUDIO_CONFIGURATION_H_ */ #endif /* TUNERSTUDIO_CONFIGURATION_H_ */

View File

@ -105,6 +105,10 @@ static fuel_table_t alphaNfuel = {
static volatile int globalConfigurationVersion = 0; static volatile int globalConfigurationVersion = 0;
/**
* This counter is incremented every time user adjusts ECU parameters online (either via dev console or other
* tuning software)
*/
int getGlobalConfigurationVersion(void) { int getGlobalConfigurationVersion(void) {
return globalConfigurationVersion; return globalConfigurationVersion;
} }

View File

@ -1,5 +1,5 @@
#define LE_COMMAND_LENGTH 200 #define LE_COMMAND_LENGTH 200
#define TS_FILE_VERSION 20151201 #define TS_FILE_VERSION 20160122
#define MAP_ANGLE_SIZE 8 #define MAP_ANGLE_SIZE 8
#define MAP_WINDOW_SIZE 8 #define MAP_WINDOW_SIZE 8
#define CLT_CURVE_SIZE 16 #define CLT_CURVE_SIZE 16

View File

@ -15,6 +15,7 @@
#include "pin_repository.h" #include "pin_repository.h"
#include "voltage.h" #include "voltage.h"
#include "pid.h" #include "pid.h"
#include "LocalVersionHolder.h"
#if EFI_ALTERNATOR_CONTROL || defined(__DOXYGEN__) #if EFI_ALTERNATOR_CONTROL || defined(__DOXYGEN__)
@ -34,11 +35,21 @@ static THD_WORKING_AREA(alternatorControlThreadStack, UTILITY_THREAD_STACK_SIZE)
static float currentAltDuty; static float currentAltDuty;
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
static LocalVersionHolder parametersVersion;
extern TunerStudioOutputChannels tsOutputChannels;
#endif
static msg_t AltCtrlThread(int param) { static msg_t AltCtrlThread(int param) {
UNUSED(param); UNUSED(param);
chRegSetThreadName("AlternatorController"); chRegSetThreadName("AlternatorController");
while (true) { while (true) {
int dt = maxI(20, engineConfiguration->alternatorDT); #if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
if (parametersVersion.isOld())
altPid.reset();
#endif
int dt = maxI(10, engineConfiguration->alternatorDT);
chThdSleepMilliseconds(dt); chThdSleepMilliseconds(dt);
currentAltDuty = engineConfiguration->alternatorOffset + altPid.getValue(engineConfiguration->targetVBatt, getVBatt(PASS_ENGINE_PARAMETER_F), 1); currentAltDuty = engineConfiguration->alternatorOffset + altPid.getValue(engineConfiguration->targetVBatt, getVBatt(PASS_ENGINE_PARAMETER_F), 1);
@ -47,6 +58,10 @@ static msg_t AltCtrlThread(int param) {
altPid.getP(), altPid.getI(), altPid.getD(), altPid.getIntegration()); altPid.getP(), altPid.getI(), altPid.getD(), altPid.getIntegration());
} }
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
tsOutputChannels.debugFloatField = currentAltDuty;
#endif
alternatorControl.setSimplePwmDutyCycle(currentAltDuty / 100); alternatorControl.setSimplePwmDutyCycle(currentAltDuty / 100);
} }
#if defined __GNUC__ #if defined __GNUC__
@ -54,9 +69,6 @@ static msg_t AltCtrlThread(int param) {
#endif #endif
} }
static void applySettings(void) {
altPid.updateFactors(engineConfiguration->alternatorControl.pFactor, 0, 0);
}
void showAltInfo(void) { void showAltInfo(void) {
scheduleMsg(logger, "alt=%s @%s t=%dms", boolToString(engineConfiguration->isAlternatorControlEnabled), scheduleMsg(logger, "alt=%s @%s t=%dms", boolToString(engineConfiguration->isAlternatorControlEnabled),
@ -71,7 +83,7 @@ void showAltInfo(void) {
void setAltPFactor(float p) { void setAltPFactor(float p) {
engineConfiguration->alternatorControl.pFactor = p; engineConfiguration->alternatorControl.pFactor = p;
scheduleMsg(logger, "setAltPid: %f", p); scheduleMsg(logger, "setAltPid: %f", p);
applySettings(); altPid.reset();
showAltInfo(); showAltInfo();
} }
@ -107,10 +119,6 @@ void initAlternatorCtrl(Logging *sharedLogger) {
ALTERNATOR_VALVE_PWM_FREQUENCY, 0.1, applyAlternatorPinState); ALTERNATOR_VALVE_PWM_FREQUENCY, 0.1, applyAlternatorPinState);
chThdCreateStatic(alternatorControlThreadStack, sizeof(alternatorControlThreadStack), LOWPRIO, chThdCreateStatic(alternatorControlThreadStack, sizeof(alternatorControlThreadStack), LOWPRIO,
(tfunc_t) AltCtrlThread, NULL); (tfunc_t) AltCtrlThread, NULL);
addConsoleActionF("set_alt_p", setAltPFactor);
applySettings();
} }
#endif /* EFI_ALTERNATOR_CONTROL */ #endif /* EFI_ALTERNATOR_CONTROL */

View File

@ -20,7 +20,7 @@ struct_no_prefix engine_configuration_s
! !
! this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version ! this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version
! !
#define TS_FILE_VERSION 20151201 #define TS_FILE_VERSION 20160122
#define MAP_ANGLE_SIZE 8 #define MAP_ANGLE_SIZE 8

View File

@ -41,7 +41,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 Thu Jan 14 23:21:45 EST 2016 ; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 22 12:32:32 EST 2016
pageSize = 16088 pageSize = 16088
page = 1 page = 1
@ -619,7 +619,7 @@ fileVersion = { 20151201 }
ochGetCommand = "O" ochGetCommand = "O"
; see OUTPUT_CHANNELS_SIZE in console source code ; see OUTPUT_CHANNELS_SIZE in console source code
ochBlockSize = 196 ochBlockSize = 276
rpm = scalar, U32, 0, "RPM", 1, 0.00000 rpm = scalar, U32, 0, "RPM", 1, 0.00000
#if CELSIUS #if CELSIUS

View File

@ -34,7 +34,7 @@ import static com.rusefi.binaryprotocol.IoHelper.*;
*/ */
public class BinaryProtocol { public class BinaryProtocol {
// todo: is this auto-synched with rusefi.ini? // todo: is this auto-synched with rusefi.ini?
public static final int OUTPUT_CHANNELS_SIZE = 196; public static final int OUTPUT_CHANNELS_SIZE = 276;
private static final int BLOCKING_FACTOR = 256; private static final int BLOCKING_FACTOR = 256;
private static final byte RESPONSE_OK = 0; private static final byte RESPONSE_OK = 0;

View File

@ -1,9 +1,9 @@
package com.rusefi.config; package com.rusefi.config;
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jan 17 23:49:17 EST 2016 // this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Jan 22 12:32:32 EST 2016
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 TS_FILE_VERSION = 20151201; public static final int TS_FILE_VERSION = 20160122;
public static final int MAP_ANGLE_SIZE = 8; public static final int MAP_ANGLE_SIZE = 8;
public static final int MAP_WINDOW_SIZE = 8; public static final int MAP_WINDOW_SIZE = 8;
public static final int CLT_CURVE_SIZE = 16; public static final int CLT_CURVE_SIZE = 16;