diff --git a/firmware/config/engines/mazda_miata_vvt.cpp b/firmware/config/engines/mazda_miata_vvt.cpp index d96d83305a..e43c239c43 100644 --- a/firmware/config/engines/mazda_miata_vvt.cpp +++ b/firmware/config/engines/mazda_miata_vvt.cpp @@ -509,7 +509,7 @@ void setMazdaMiata2003EngineConfigurationBoardTest(DECLARE_CONFIG_PARAMETER_SIGN */ void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - engineConfiguration->etb.pFactor = 22; + engineConfiguration->etb.pFactor = 12; // a bit lower p-factor seems to work better on TLE9201? MRE? engineConfiguration->etb.iFactor = 0; engineConfiguration->etb.dFactor = 0; engineConfiguration->etb.offset = 0; @@ -523,7 +523,7 @@ void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_7; // set tps_min 90 - engineConfiguration->tpsMin = 870; + engineConfiguration->tpsMin = 90; // set tps_max 540 engineConfiguration->tpsMax = 870; diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index ebd37fe3b6..d2b112b4fe 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -270,11 +270,16 @@ DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor)) DISPLAY_TEXT(eol); DISPLAY_STATE(ETB_pid) + DISPLAY_TEXT(input); + DISPLAY(DISPLAY_FIELD(input)); DISPLAY_TEXT(Output); DISPLAY(DISPLAY_FIELD(output)); DISPLAY_TEXT(iTerm); DISPLAY(DISPLAY_FIELD(iTerm)); DISPLAY_TEXT(eol); + DISPLAY(DISPLAY_FIELD(errorAmplificationCoef)); + DISPLAY(DISPLAY_FIELD(previousError)); + DISPLAY_TEXT(eol); DISPLAY_TEXT(Settings); DISPLAY(DISPLAY_CONFIG(ETB_PFACTOR)); @@ -283,6 +288,9 @@ DISPLAY(DISPLAY_IF(hasEtbPedalPositionSensor)) DISPLAY_TEXT(eol); DISPLAY(DISPLAY_CONFIG(ETB_OFFSET)); DISPLAY(DISPLAY_CONFIG(ETB_PERIODMS)); + DISPLAY_TEXT(eol); + DISPLAY(DISPLAY_CONFIG(ETB_MINVALUE)); + DISPLAY(DISPLAY_CONFIG(ETB_MAXVALUE)); /* DISPLAY_ELSE */ DISPLAY_TEXT(No_Pedal_Sensor); /* DISPLAY_ENDIF */ @@ -409,10 +417,6 @@ void setBoschVNH2SP30Curve(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->etbBiasValues[5] = 20; engineConfiguration->etbBiasValues[6] = 26; engineConfiguration->etbBiasValues[7] = 28; - - // values are above 100% since we have feedforward part of the total summation - engineConfiguration->etb.minValue = -200; - engineConfiguration->etb.maxValue = 200; } void setDefaultEtbParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) { @@ -438,6 +442,10 @@ void setDefaultEtbParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->etbFreq = DEFAULT_ETB_PWM_FREQUENCY; engineConfiguration->etb_iTermMin = -300; engineConfiguration->etb_iTermMax = 300; + + // values are above 100% since we have feedforward part of the total summation + engineConfiguration->etb.minValue = -200; + engineConfiguration->etb.maxValue = 200; } static bool isSamePins(etb_io *current, etb_io *active) { diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index f83aa26c54..bb4436a95d 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -628,9 +628,6 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->auxPid[0].minValue = 10; engineConfiguration->auxPid[0].maxValue = 90; - engineConfiguration->etb.minValue = 0; - engineConfiguration->etb.maxValue = 99; - engineConfiguration->alternatorControl.minValue = 10; engineConfiguration->alternatorControl.maxValue = 90; diff --git a/firmware/controllers/generated/pid_state_generated.h b/firmware/controllers/generated/pid_state_generated.h index 4654539cad..e9247d4a92 100644 --- a/firmware/controllers/generated/pid_state_generated.h +++ b/firmware/controllers/generated/pid_state_generated.h @@ -1,4 +1,4 @@ -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 11:57:50 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 19:07:42 EDT 2019 // by class com.rusefi.output.CHeaderConsumer // begin #ifndef CONTROLLERS_GENERATED_PID_STATE_GENERATED_H @@ -34,11 +34,15 @@ struct pid_state_s { * offset 20 */ float errorAmplificationCoef = (float)0; - /** total size 24*/ + /** + * offset 24 + */ + float previousError = (float)0; + /** total size 28*/ }; typedef struct pid_state_s pid_state_s; #endif // end -// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 11:57:50 EDT 2019 +// this section was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 19:07:42 EDT 2019 diff --git a/firmware/integration/pid_state.txt b/firmware/integration/pid_state.txt index 250fe3c94b..4eff0a8341 100644 --- a/firmware/integration/pid_state.txt +++ b/firmware/integration/pid_state.txt @@ -5,6 +5,7 @@ struct_no_prefix pid_state_s float input;only used for logging float output;only used for logging float errorAmplificationCoef; + float previousError end_struct diff --git a/firmware/util/math/pid.h b/firmware/util/math/pid.h index abe5d7b814..17c60f9ad2 100644 --- a/firmware/util/math/pid.h +++ b/firmware/util/math/pid.h @@ -70,9 +70,6 @@ public: private: pid_s *parameters; - float previousError; - - private: virtual void updateITerm(float value); }; diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index 5940013f9e..9538c0dec2 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -35,6 +35,7 @@ import static com.rusefi.binaryprotocol.IoHelper.*; public class BinaryProtocol implements BinaryProtocolCommands { private static final String USE_PLAIN_PROTOCOL_PROPERTY = "protocol.plain"; + private static final int TEXT_PULL_PERIOD = 100; /** * This properly allows to switch to non-CRC32 mode * todo: finish this feature, assuming we even need it. @@ -69,9 +70,9 @@ public class BinaryProtocol implements BinaryProtocolCommands { stream.setInputListener(incomingData::addData); } - private static void sleep() { + private static void sleep(int millis) { try { - Thread.sleep(100); + Thread.sleep(millis); } catch (InterruptedException e) { throw new IllegalStateException(e); } @@ -146,7 +147,7 @@ public class BinaryProtocol implements BinaryProtocolCommands { } }); } - sleep(); + sleep(TEXT_PULL_PERIOD); } FileLog.MAIN.logLine("Stopping text pull"); } diff --git a/java_console/io/src/com/rusefi/ui/livedocs/LiveDocHolder.java b/java_console/io/src/com/rusefi/ui/livedocs/LiveDocHolder.java index ec85ddc095..b77fb09bb6 100644 --- a/java_console/io/src/com/rusefi/ui/livedocs/LiveDocHolder.java +++ b/java_console/io/src/com/rusefi/ui/livedocs/LiveDocHolder.java @@ -2,6 +2,9 @@ package com.rusefi.ui.livedocs; import com.rusefi.binaryprotocol.BinaryProtocol; +/** + * (c) Andrey Belomutskiy 2013-2019 + */ public abstract class LiveDocHolder { private final LiveDataContext id; private final RefreshActionsMap actions; diff --git a/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java b/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java index c7bd2e0952..b5d08e2a33 100644 --- a/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java +++ b/java_console/io/src/com/rusefi/ui/livedocs/LiveDocsRegistry.java @@ -14,6 +14,7 @@ import static com.rusefi.binaryprotocol.IoHelper.swap16; /** * Singleton map of all live documentation entities. Using this registry we know all the entities to update periodically. + * (c) Andrey Belomutskiy 2013-2019 */ public enum LiveDocsRegistry { INSTANCE; @@ -41,7 +42,7 @@ public enum LiveDocsRegistry { Field[] values = StateDictionary.INSTANCE.getFields("refresh", context); int size = Field.getStructureSize(values); - byte packet[] = new byte[5]; + byte[] packet = new byte[5]; packet[0] = COMMAND_GET_STRUCT; putShort(packet, 1, swap16(liveDocRequestId)); // offset putShort(packet, 3, swap16(size)); diff --git a/java_console/models/src/com/rusefi/config/generated/PidState.java b/java_console/models/src/com/rusefi/config/generated/PidState.java index 6545de1ef4..f7510bdcaa 100644 --- a/java_console/models/src/com/rusefi/config/generated/PidState.java +++ b/java_console/models/src/com/rusefi/config/generated/PidState.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 11:57:50 EDT 2019 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration/pid_state.txt Sun Sep 01 19:07:42 EDT 2019 // by class com.rusefi.output.JavaFieldsConsumer import com.rusefi.config.*; @@ -12,6 +12,7 @@ public class PidState { public static final Field INPUT = Field.create("INPUT", 12, FieldType.FLOAT); public static final Field OUTPUT = Field.create("OUTPUT", 16, FieldType.FLOAT); public static final Field ERRORAMPLIFICATIONCOEF = Field.create("ERRORAMPLIFICATIONCOEF", 20, FieldType.FLOAT); + public static final Field PREVIOUSERROR = Field.create("PREVIOUSERROR", 24, FieldType.FLOAT); public static final Field[] VALUES = { ITERM, DTERM, @@ -19,5 +20,6 @@ public class PidState { INPUT, OUTPUT, ERRORAMPLIFICATIONCOEF, + PREVIOUSERROR, }; } diff --git a/java_console/ui/src/com/rusefi/ldmp/generated/ElectronicThrottleMeta.java b/java_console/ui/src/com/rusefi/ldmp/generated/ElectronicThrottleMeta.java index 36727ff36a..2c7f2a476f 100644 --- a/java_console/ui/src/com/rusefi/ldmp/generated/ElectronicThrottleMeta.java +++ b/java_console/ui/src/com/rusefi/ldmp/generated/ElectronicThrottleMeta.java @@ -16,11 +16,16 @@ public class ElectronicThrottleMeta { new TextRequest("Feed_forward"), new FieldRequest("Engine", "etbFeedForward"), new TextRequest("eol"), + new TextRequest("input"), + new FieldRequest("ETB_pid", "input"), new TextRequest("Output"), new FieldRequest("ETB_pid", "output"), new TextRequest("iTerm"), new FieldRequest("ETB_pid", "iTerm"), new TextRequest("eol"), + new FieldRequest("ETB_pid", "errorAmplificationCoef"), + new FieldRequest("ETB_pid", "previousError"), + new TextRequest("eol"), new TextRequest("Settings"), new ConfigRequest("ETB_PFACTOR"), new ConfigRequest("ETB_IFACTOR"), @@ -28,6 +33,9 @@ public class ElectronicThrottleMeta { new TextRequest("eol"), new ConfigRequest("ETB_OFFSET"), new ConfigRequest("ETB_PERIODMS"), + new TextRequest("eol"), + new ConfigRequest("ETB_MINVALUE"), + new ConfigRequest("ETB_MAXVALUE"), }, new Request[]{ new TextRequest("No_Pedal_Sensor"), diff --git a/java_console/ui/src/com/rusefi/ui/livedocs/LessJumpyJLabel.java b/java_console/ui/src/com/rusefi/ui/livedocs/LessJumpyJLabel.java new file mode 100644 index 0000000000..d03c672475 --- /dev/null +++ b/java_console/ui/src/com/rusefi/ui/livedocs/LessJumpyJLabel.java @@ -0,0 +1,23 @@ +package com.rusefi.ui.livedocs; + +import javax.swing.*; +import java.awt.*; + +/** + * (c) Andrey Belomutskiy 2013-2019 + */ +public class LessJumpyJLabel extends JLabel { + private int maxPreferredWidth = 0; + + public LessJumpyJLabel(String text) { + super(text); + } + + @Override + public Dimension getPreferredSize() { + Dimension preferredSize = super.getPreferredSize(); + // let's occupy maximum width we ever wanted to reduce layout jumpiness + maxPreferredWidth = Math.max(maxPreferredWidth, preferredSize.width); + return new Dimension(maxPreferredWidth, preferredSize.height); + } +} diff --git a/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java b/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java index ab0ee50602..66b38d27f0 100644 --- a/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java +++ b/java_console/ui/src/com/rusefi/ui/livedocs/LiveDocPanel.java @@ -77,7 +77,7 @@ public class LiveDocPanel { FieldRequest request = (FieldRequest) r; LiveDataContext context = getFieldContext(defaultContext, request.getStateContext()); Field field = getField(defaultContext, request); - JLabel label = new JLabel("*"); + JLabel label = new LessJumpyJLabel("*"); label.setIcon(UiUtils.loadIcon("livedocs/variable.png")); label.setToolTipText("Variable " + field.getName()); result.addControl(label); @@ -85,7 +85,7 @@ public class LiveDocPanel { @Override public void refresh(BinaryProtocol bp, byte[] response) { Number fieldValue = field.getValue(new ConfigurationImage(response)); - String value = niceToString(fieldValue); + String value = Field.niceToString(fieldValue, LIVE_DATA_PRECISION); label.setText(value); } }); @@ -93,7 +93,7 @@ public class LiveDocPanel { ConfigRequest request = (ConfigRequest) r; Field field = Field.findField(Fields.VALUES, settingsInstancePrefix, request.getField()); - JLabel label = new JLabel("*"); + JLabel label = new LessJumpyJLabel("*"); label.setIcon(UiUtils.loadIcon("livedocs/setting.png")); label.setToolTipText(getTooltipText(field.getName())); result.addControl(label); @@ -108,7 +108,7 @@ public class LiveDocPanel { } else if (r instanceof SensorRequest) { SensorRequest request = (SensorRequest) r; Sensor sensor = Sensor.find(request.getValue()); - JLabel label = new JLabel("*"); + JLabel label = new LessJumpyJLabel("*"); label.setIcon(UiUtils.loadIcon("livedocs/gauge.png")); label.setToolTipText("Sensor " + request.getValue()); label.addMouseListener(new MouseAdapter() { @@ -174,7 +174,7 @@ public class LiveDocPanel { JPanel result = new JPanel(new VerticalFlowLayout()); - JLabel conditionLabel = new JLabel(request.getField()); + JLabel conditionLabel = new LessJumpyJLabel(request.getField()); result.add(conditionLabel);