mirror of https://github.com/rusefi/rusefi-1.git
parent
16878487d5
commit
084685c747
|
@ -3,7 +3,7 @@
|
||||||
#include "FragmentEntry.h"
|
#include "FragmentEntry.h"
|
||||||
|
|
||||||
#include "tunerstudio.h"
|
#include "tunerstudio.h"
|
||||||
static FragmentEntry fragments[15];
|
static FragmentEntry fragments[16];
|
||||||
|
|
||||||
void initFragments() {
|
void initFragments() {
|
||||||
fragments[0].init((const uint8_t *)getStructAddr(LDS_high_pressure_fuel_pump), sizeof(high_pressure_fuel_pump_s));
|
fragments[0].init((const uint8_t *)getStructAddr(LDS_high_pressure_fuel_pump), sizeof(high_pressure_fuel_pump_s));
|
||||||
|
@ -21,4 +21,5 @@ void initFragments() {
|
||||||
fragments[12].init((const uint8_t *)getStructAddr(LDS_wall_fuel_state), sizeof(wall_fuel_state_s));
|
fragments[12].init((const uint8_t *)getStructAddr(LDS_wall_fuel_state), sizeof(wall_fuel_state_s));
|
||||||
fragments[13].init((const uint8_t *)getStructAddr(LDS_idle_state), sizeof(idle_state_s));
|
fragments[13].init((const uint8_t *)getStructAddr(LDS_idle_state), sizeof(idle_state_s));
|
||||||
fragments[14].init((const uint8_t *)getStructAddr(LDS_ignition_state), sizeof(ignition_state_s));
|
fragments[14].init((const uint8_t *)getStructAddr(LDS_ignition_state), sizeof(ignition_state_s));
|
||||||
|
fragments[15].init((const uint8_t *)getStructAddr(LDS_electronic_throttle), sizeof(electronic_throttle_s));
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,4 +17,5 @@ LDS_trigger_state,
|
||||||
LDS_wall_fuel_state,
|
LDS_wall_fuel_state,
|
||||||
LDS_idle_state,
|
LDS_idle_state,
|
||||||
LDS_ignition_state,
|
LDS_ignition_state,
|
||||||
|
LDS_electronic_throttle,
|
||||||
} live_data_e;
|
} live_data_e;
|
||||||
|
|
|
@ -218,6 +218,9 @@ const void * getStructAddr(live_data_e structId) {
|
||||||
return static_cast<idle_state_s*>(&engine->module<IdleController>().unmock());
|
return static_cast<idle_state_s*>(&engine->module<IdleController>().unmock());
|
||||||
case LDS_ignition_state:
|
case LDS_ignition_state:
|
||||||
return static_cast<ignition_state_s*>(&engine->ignitionState);
|
return static_cast<ignition_state_s*>(&engine->ignitionState);
|
||||||
|
case LDS_electronic_throttle:
|
||||||
|
// todo: figure out how to handle two units?
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
//#if EFI_ELECTRONIC_THROTTLE_BODY
|
//#if EFI_ELECTRONIC_THROTTLE_BODY
|
||||||
// case LDS_ETB_PID:
|
// case LDS_ETB_PID:
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "tunerstudio_io.h"
|
#include "tunerstudio_io.h"
|
||||||
|
#include "electronic_throttle_generated.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int queryCommandCounter;
|
int queryCommandCounter;
|
||||||
|
|
|
@ -275,7 +275,7 @@ expected<percent_t> EtbController::getSetpointWastegate() const {
|
||||||
return clampF(0, m_wastegatePosition, 100);
|
return clampF(0, m_wastegatePosition, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
expected<percent_t> EtbController::getSetpointEtb() const {
|
expected<percent_t> EtbController::getSetpointEtb() {
|
||||||
// Autotune runs with 50% target position
|
// Autotune runs with 50% target position
|
||||||
if (m_isAutotune) {
|
if (m_isAutotune) {
|
||||||
return 50.0f;
|
return 50.0f;
|
||||||
|
@ -313,14 +313,17 @@ expected<percent_t> EtbController::getSetpointEtb() const {
|
||||||
// [0, 100] -> [idle, 100]
|
// [0, 100] -> [idle, 100]
|
||||||
// 0% target from table -> idle position as target
|
// 0% target from table -> idle position as target
|
||||||
// 100% target from table -> 100% target position
|
// 100% target from table -> 100% target position
|
||||||
percent_t targetPosition = interpolateClamped(0, etbIdleAddition, 100, 100, targetFromTable);
|
idlePosition = interpolateClamped(0, etbIdleAddition, 100, 100, targetFromTable);
|
||||||
|
|
||||||
// Apply any adjustment from Lua
|
// Apply any adjustment from Lua
|
||||||
targetPosition += engine->engineState.luaAdjustments.etbTargetPositionAdd;
|
luaAdjustment = engine->engineState.luaAdjustments.etbTargetPositionAdd;
|
||||||
|
|
||||||
|
percent_t targetPosition = idlePosition + luaAdjustment;
|
||||||
|
|
||||||
// Apply any adjustment that this throttle alone needs
|
// Apply any adjustment that this throttle alone needs
|
||||||
// Clamped to +-10 to prevent anything too wild
|
// Clamped to +-10 to prevent anything too wild
|
||||||
targetPosition += clampF(-10, getThrottleTrim(rpm, targetPosition), 10);
|
trim = clampF(-10, getThrottleTrim(rpm, targetPosition), 10);
|
||||||
|
targetPosition += trim;
|
||||||
|
|
||||||
// Lastly, apply ETB rev limiter
|
// Lastly, apply ETB rev limiter
|
||||||
auto etbRpmLimit = engineConfiguration->etbRevLimitStart;
|
auto etbRpmLimit = engineConfiguration->etbRevLimitStart;
|
||||||
|
@ -334,6 +337,7 @@ expected<percent_t> EtbController::getSetpointEtb() const {
|
||||||
float maxPosition = engineConfiguration->etbMaximumPosition;
|
float maxPosition = engineConfiguration->etbMaximumPosition;
|
||||||
|
|
||||||
if (maxPosition < 70) {
|
if (maxPosition < 70) {
|
||||||
|
// compatibility with legacy tunes, todo: remove in Aug of 2022
|
||||||
maxPosition = 100;
|
maxPosition = 100;
|
||||||
} else {
|
} else {
|
||||||
// Don't allow max position over 100
|
// Don't allow max position over 100
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators\electronic_throttle.txt Thu Apr 14 14:39:06 EDT 2022
|
||||||
|
// by class com.rusefi.output.CHeaderConsumer
|
||||||
|
// begin
|
||||||
|
#pragma once
|
||||||
|
#include "rusefi_types.h"
|
||||||
|
// start of electronic_throttle_s
|
||||||
|
struct electronic_throttle_s {
|
||||||
|
/**
|
||||||
|
* offset 0
|
||||||
|
*/
|
||||||
|
float idlePosition = (float)0;
|
||||||
|
/**
|
||||||
|
* offset 4
|
||||||
|
*/
|
||||||
|
float trim = (float)0;
|
||||||
|
/**
|
||||||
|
* offset 8
|
||||||
|
*/
|
||||||
|
float luaAdjustment = (float)0;
|
||||||
|
/** total size 12*/
|
||||||
|
};
|
||||||
|
|
||||||
|
// end
|
||||||
|
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators\electronic_throttle.txt Thu Apr 14 14:39:06 EDT 2022
|
|
@ -13,6 +13,7 @@
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
#include "efi_pid.h"
|
#include "efi_pid.h"
|
||||||
#include "error_accumulator.h"
|
#include "error_accumulator.h"
|
||||||
|
#include "electronic_throttle_generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hard code ETB update speed.
|
* Hard code ETB update speed.
|
||||||
|
@ -23,7 +24,7 @@
|
||||||
#define ETB_LOOP_FREQUENCY 500
|
#define ETB_LOOP_FREQUENCY 500
|
||||||
#define DEFAULT_ETB_PWM_FREQUENCY 800
|
#define DEFAULT_ETB_PWM_FREQUENCY 800
|
||||||
|
|
||||||
class EtbController : public IEtbController {
|
class EtbController : public IEtbController, electronic_throttle_s {
|
||||||
public:
|
public:
|
||||||
bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override;
|
bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override;
|
||||||
void setIdlePosition(percent_t pos) override;
|
void setIdlePosition(percent_t pos) override;
|
||||||
|
@ -44,7 +45,7 @@ public:
|
||||||
expected<percent_t> observePlant() const override;
|
expected<percent_t> observePlant() const override;
|
||||||
|
|
||||||
expected<percent_t> getSetpoint() override;
|
expected<percent_t> getSetpoint() override;
|
||||||
expected<percent_t> getSetpointEtb() const;
|
expected<percent_t> getSetpointEtb();
|
||||||
expected<percent_t> getSetpointWastegate() const;
|
expected<percent_t> getSetpointWastegate() const;
|
||||||
expected<percent_t> getSetpointIdleValve() const;
|
expected<percent_t> getSetpointIdleValve() const;
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,5 @@ Usages:
|
||||||
wall_fuel_state: [ "WallFuelState.java", "controllers/algo" ]
|
wall_fuel_state: [ "WallFuelState.java", "controllers/algo" ]
|
||||||
idle_state: [ "IdleState.java", "controllers/actuators" ]
|
idle_state: [ "IdleState.java", "controllers/actuators" ]
|
||||||
ignition_state: [ "IgnitionState.java", "controllers/algo" ]
|
ignition_state: [ "IgnitionState.java", "controllers/algo" ]
|
||||||
|
electronic_throttle: [ "ElectronicThrottle.java", "controllers/actuators" ]
|
||||||
|
|
||||||
|
|
|
@ -19,4 +19,5 @@ public enum live_data_e {
|
||||||
LDS_wall_fuel_state,
|
LDS_wall_fuel_state,
|
||||||
LDS_idle_state,
|
LDS_idle_state,
|
||||||
LDS_ignition_state,
|
LDS_ignition_state,
|
||||||
|
LDS_electronic_throttle,
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ public enum StateDictionary {
|
||||||
register(live_data_e.LDS_launch_control_state, LaunchControl.VALUES, "launch_control");
|
register(live_data_e.LDS_launch_control_state, LaunchControl.VALUES, "launch_control");
|
||||||
register(live_data_e.LDS_high_pressure_fuel_pump, HighPressureFuelPump.VALUES, "high_pressure_fuel_pump");
|
register(live_data_e.LDS_high_pressure_fuel_pump, HighPressureFuelPump.VALUES, "high_pressure_fuel_pump");
|
||||||
register(live_data_e.LDS_ignition_state, IgnitionState.VALUES, "advance_map");
|
register(live_data_e.LDS_ignition_state, IgnitionState.VALUES, "advance_map");
|
||||||
|
register(live_data_e.LDS_electronic_throttle, ElectronicThrottle.VALUES, "electronic_throttle");
|
||||||
if (map.size() != live_data_e.values().length) {
|
if (map.size() != live_data_e.values().length) {
|
||||||
Set<live_data_e> missing = new HashSet<>(Arrays.asList(live_data_e.values()));
|
Set<live_data_e> missing = new HashSet<>(Arrays.asList(live_data_e.values()));
|
||||||
missing.removeAll(map.keySet());
|
missing.removeAll(map.keySet());
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.rusefi.config.generated;
|
||||||
|
|
||||||
|
// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) controllers/actuators\electronic_throttle.txt Thu Apr 14 14:39:06 EDT 2022
|
||||||
|
|
||||||
|
// by class com.rusefi.output.FileJavaFieldsConsumer
|
||||||
|
import com.rusefi.config.*;
|
||||||
|
|
||||||
|
public class ElectronicThrottle {
|
||||||
|
public static final Field IDLEPOSITION = Field.create("IDLEPOSITION", 0, FieldType.FLOAT);
|
||||||
|
public static final Field TRIM = Field.create("TRIM", 4, FieldType.FLOAT);
|
||||||
|
public static final Field LUAADJUSTMENT = Field.create("LUAADJUSTMENT", 8, FieldType.FLOAT);
|
||||||
|
public static final Field[] VALUES = {
|
||||||
|
IDLEPOSITION,
|
||||||
|
TRIM,
|
||||||
|
LUAADJUSTMENT,
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue