diff --git a/firmware/ChibiOS-Contrib b/firmware/ChibiOS-Contrib
index fe95e90b80..b5321c7e0e 160000
--- a/firmware/ChibiOS-Contrib
+++ b/firmware/ChibiOS-Contrib
@@ -1 +1 @@
-Subproject commit fe95e90b80a28dd2f40bfee1ad90822b99519c6a
+Subproject commit b5321c7e0ef470ed2dbb50dc1322c1252dea2d50
diff --git a/firmware/controllers/electronic_throttle.cpp b/firmware/controllers/electronic_throttle.cpp
index 81dd78c36f..83255ffba1 100644
--- a/firmware/controllers/electronic_throttle.cpp
+++ b/firmware/controllers/electronic_throttle.cpp
@@ -75,6 +75,7 @@ static THD_WORKING_AREA(etbTreadStack, UTILITY_THREAD_STACK_SIZE);
* @brief Pulse-Width Modulation state
*/
static SimplePwm etbPwmUp CCM_OPTIONAL;
+static float valueOverride = NAN;
/*
static SimplePwm etbPwmDown CCM_OPTIONAL;
static OutputPin outputDirectionOpen CCM_OPTIONAL;
@@ -85,8 +86,6 @@ EXTERN_ENGINE;
static Pid pid(&engineConfiguration->etb);
-//static float prevTps;
-
static percent_t currentEtbDuty;
static bool wasEtbBraking = false;
@@ -94,12 +93,23 @@ static bool wasEtbBraking = false;
static msg_t etbThread(void *arg) {
UNUSED(arg);
while (true) {
+ if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) {
+ pid.postState(&tsOutputChannels);
+ } else if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_EXTRA) {
+ tsOutputChannels.debugFloatField1 = valueOverride;
+ }
+
if (shouldResetPid) {
pid.reset();
-// alternatorPidResetCounter++;
shouldResetPid = false;
}
+ if (!cisnan(valueOverride)) {
+ etbPwmUp.setSimplePwmDutyCycle(valueOverride);
+ pid.sleep();
+ continue;
+ }
+
if (engine->etbAutoTune) {
autoTune.Runtime(&logger);
@@ -127,19 +137,11 @@ static msg_t etbThread(void *arg) {
outputDirectionClose.setValue(needEtbBraking);
}
- if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) {
- pid.postState(&tsOutputChannels);
- }
if (engineConfiguration->isVerboseETB) {
pid.showPidStatus(&logger, "ETB");
}
-// if (tps != prevTps) {
-// prevTps = tps;
-// scheduleMsg(&logger, "tps=%d", (int) tps);
-// }
-
// this thread is activated 10 times per second
pid.sleep();
}
@@ -149,12 +151,14 @@ static msg_t etbThread(void *arg) {
}
/**
- * manual duty cycle control without PID
+ * manual duty cycle control without PID. Percent value from 0 to 100
*/
-static void setThrottleDutyCycle(int level) {
- scheduleMsg(&logger, "setting throttle=%d", level);
+static void setThrottleDutyCycle(float level) {
+ scheduleMsg(&logger, "setting ETB duty=%f", level);
- float dc = 0.01 + (minI(level, 98)) / 100.0;
+ float dc = (minI(level, 98)) / 100.0;
+ dc = maxF(dc, 0.00001); // todo: need to fix PWM so that it supports zero duty cycle
+ valueOverride = dc;
etbPwmUp.setSimplePwmDutyCycle(dc);
print("etb duty = %.2f\r\n", dc);
}
@@ -276,7 +280,7 @@ void initElectronicThrottle(void) {
startETBPins();
//
- addConsoleActionI("set_etb", setThrottleDutyCycle);
+ addConsoleActionF("set_etb", setThrottleDutyCycle);
addConsoleActionF("set_etb_output", setTempOutput);
addConsoleActionF("set_etb_step", setTempStep);
diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp
index 0ada70b286..65d8cf6131 100644
--- a/firmware/controllers/system/pwm_generator_logic.cpp
+++ b/firmware/controllers/system/pwm_generator_logic.cpp
@@ -53,8 +53,10 @@ void PwmConfig::init(float *st, single_wave_s *waves) {
*/
void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
if (dutyCycle < 0 || dutyCycle > 1) {
- firmwareError(CUSTOM_ERR_6579, "spwd:dutyCycle %.2f", dutyCycle);
+ warning(CUSTOM_ERR_6579, "spwd:dutyCycle %.2f", dutyCycle);
+ return;
}
+ // todo: need to fix PWM so that it supports zero duty cycle
multiWave.setSwitchTime(0, dutyCycle);
}
diff --git a/java_console/.idea/runConfigurations/Launcher.xml b/java_console/.idea/runConfigurations/Launcher.xml
index 8daa03a849..489f5348da 100644
--- a/java_console/.idea/runConfigurations/Launcher.xml
+++ b/java_console/.idea/runConfigurations/Launcher.xml
@@ -6,7 +6,7 @@
-
+
diff --git a/java_console/.idea/runConfigurations/Launcher_COM112.xml b/java_console/.idea/runConfigurations/Launcher_COM112.xml
new file mode 100644
index 0000000000..f1c368f3ee
--- /dev/null
+++ b/java_console/.idea/runConfigurations/Launcher_COM112.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java_console/.idea/workspace.xml b/java_console/.idea/workspace.xml
index 24eb8aa4e6..4f640edc7f 100644
--- a/java_console/.idea/workspace.xml
+++ b/java_console/.idea/workspace.xml
@@ -1,39 +1,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
-
-
-
-
-
+
@@ -69,94 +53,127 @@
-
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -164,79 +181,59 @@
+
+
+
+
+
+ pedal
+ int
+ debugin
+ excepti
+ excep
+ .inf
+ .info
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-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
-
-
-
-
-
+
+
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
@@ -1833,5 +1805,4 @@
-
-
+
\ No newline at end of file
diff --git a/java_console/io/src/com/rusefi/io/CommandQueue.java b/java_console/io/src/com/rusefi/io/CommandQueue.java
index 9562f320f9..172bb11ebc 100644
--- a/java_console/io/src/com/rusefi/io/CommandQueue.java
+++ b/java_console/io/src/com/rusefi/io/CommandQueue.java
@@ -150,6 +150,10 @@ public class CommandQueue {
write(command, timeout, InvocationConfirmationListener.VOID);
}
+ public void write(String command, InvocationConfirmationListener listener) {
+ write(command, DEFAULT_TIMEOUT, listener, true);
+ }
+
public void write(String command, int timeoutMs, InvocationConfirmationListener listener) {
write(command, timeoutMs, listener, true);
}
diff --git a/java_console/ui/src/com/rusefi/BenchTestPane.java b/java_console/ui/src/com/rusefi/BenchTestPane.java
index a00653c22b..9c2fc48e3b 100644
--- a/java_console/ui/src/com/rusefi/BenchTestPane.java
+++ b/java_console/ui/src/com/rusefi/BenchTestPane.java
@@ -3,6 +3,7 @@ package com.rusefi;
import com.rusefi.io.CommandQueue;
import com.rusefi.ui.MessagesView;
import com.rusefi.ui.util.UiUtils;
+import com.rusefi.ui.widgets.EtbResearch;
import com.rusefi.ui.widgets.EtbTestSequence;
import org.jetbrains.annotations.NotNull;
import org.putgemin.VerticalFlowLayout;
@@ -26,6 +27,7 @@ public class BenchTestPane {
content.add(createIdleTest());
content.add(createDizzyTest());
content.add(UiUtils.wrap(new EtbTestSequence().getButton()));
+ content.add(UiUtils.wrap(new EtbResearch().getButton()));
content.add(new MessagesView().messagesScroll);
}
diff --git a/java_console/ui/src/com/rusefi/ui/widgets/EtbResearch.java b/java_console/ui/src/com/rusefi/ui/widgets/EtbResearch.java
new file mode 100644
index 0000000000..ceee09e18d
--- /dev/null
+++ b/java_console/ui/src/com/rusefi/ui/widgets/EtbResearch.java
@@ -0,0 +1,105 @@
+package com.rusefi.ui.widgets;
+
+import com.opensr5.Logger;
+import com.rusefi.FileLog;
+import com.rusefi.core.Sensor;
+import com.rusefi.core.SensorCentral;
+import com.rusefi.io.CommandQueue;
+import com.rusefi.io.InvocationConfirmationListener;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * (c) Andrey Belomutskiy
+ * 10/21/2018
+ */
+public class EtbResearch {
+ private static final long SLEEP = 1000;
+ private final JButton button = new JButton("ETB R");
+ private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
+ // close to zero but not really zero so that we can validate this value
+ private final static double LOW_VALUE = 0.5;
+// private boolean isStarted;
+
+
+ State state;
+ private double currentValue;
+
+ InvocationConfirmationListener goingUp = new InvocationConfirmationListener() {
+ @Override
+ public void onCommandConfirmation() {
+ state = State.GOING_UP;
+
+
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(SLEEP);
+ } catch (InterruptedException unexpected) {
+ unexpected.printStackTrace();
+ return;
+ }
+
+ double tpsPosition = SensorCentral.getInstance().getValue(Sensor.TPS);
+ FileLog.MAIN.logLine("ETB duty " + currentValue + ": tps=" + tpsPosition);
+
+ if (tpsPosition == 0) {
+ currentValue += 1.0;
+ CommandQueue.getInstance().write("set_etb " + currentValue, goingUp);
+ }
+ }
+ });
+
+ }
+ };
+
+ InvocationConfirmationListener setDebugModeConfiguration = new InvocationConfirmationListener() {
+ @Override
+ public void onCommandConfirmation() {
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ state = State.START;
+
+ currentValue = LOW_VALUE;
+ CommandQueue.getInstance().write("set_etb " + currentValue, goingUp);
+ }
+ });
+ }
+ };
+
+ public EtbResearch() {
+ button.addActionListener(new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+// if (!isStarted) {
+//// metric.start();
+// isStarted = true;
+// }
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ // magic constant for DBG_ELECTRONIC_THROTTLE_EXTRA
+ state = State.DEBUG_MODE;
+ CommandQueue.getInstance().write("set debug_mode " + 29, setDebugModeConfiguration);
+ }
+ });
+
+ }
+ });
+ }
+
+ public JComponent getButton() {
+ return button;
+ }
+
+ enum State {
+ DEBUG_MODE,
+ START,
+ GOING_UP,
+ }
+}