From 1fafda7daa61b158a13bae3a6f948195df8d1326 Mon Sep 17 00:00:00 2001 From: shadowm60 Date: Fri, 18 Dec 2020 21:49:59 +0200 Subject: [PATCH] Test Idle PWM (#2103) * Create PwmHardwareTest.java Test idle pwm * Update PwmHardwareTest.java assert with +-1% --- .../src/com/rusefi/PwmHardwareTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 java_console/autotest/src/com/rusefi/PwmHardwareTest.java diff --git a/java_console/autotest/src/com/rusefi/PwmHardwareTest.java b/java_console/autotest/src/com/rusefi/PwmHardwareTest.java new file mode 100644 index 0000000000..0f49a13a9b --- /dev/null +++ b/java_console/autotest/src/com/rusefi/PwmHardwareTest.java @@ -0,0 +1,65 @@ +package com.rusefi; + +import com.rusefi.config.generated.Fields; +import com.rusefi.core.Sensor; +import com.rusefi.core.SensorCentral; +import com.rusefi.functional_tests.EcuTestHelper; +import org.junit.Test; + +import static com.rusefi.IoUtil.getDisableCommand; +import static com.rusefi.IoUtil.getEnableCommand; +import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; +import static com.rusefi.config.generated.Fields.*; + +/** + * This test relies on jumpers connecting physical pins on Discovery: + * PD1<>PC6 + * PD2<>PA5 + * + */ + +public class PwmHardwareTest { + + @Test + public void testIdlePin() { + EcuTestHelper ecu = EcuTestHelper.createInstance(true); + + ecu.setEngineType(ET_FRANKENSO_MIATA_NA6); + ecu.sendCommand(getDisableCommand(Fields.CMD_SELF_STIMULATION)); + ecu.changeRpm(1000); + + ecu.sendCommand(CMD_TRIGGER_SIMULATOR_PIN + " 0 none"); + ecu.sendCommand(CMD_TRIGGER_SIMULATOR_PIN + " 1 none"); + ecu.sendCommand(CMD_IDLE_PIN + " PD2"); + + /* wasted two wire, so we really need 1..3 to be none */ + ecu.sendCommand(CMD_IGNITION_PIN + " 1 none"); + ecu.sendCommand(CMD_IGNITION_PIN + " 2 none"); + ecu.sendCommand(CMD_IGNITION_PIN + " 3 none"); + + ecu.sendCommand(CMD_TRIGGER_PIN + " 1 PA8"); + + /* DBG_LOGIC_ANALYZER */ + ecu.sendCommand("set debug_mode 45"); + + /* 160 Hz */ + ecu.sendCommand("set idle_solenoid_freq 160"); + + /* save these for last to ensure logic is started */ + ecu.sendCommand(CMD_LOGIC_PIN + " 0 PA5"); + ecu.sendCommand(CMD_WRITECONFIG); + sleep(2 * Timeouts.SECOND); + ecu.sendCommand(getEnableCommand(Fields.CMD_SELF_STIMULATION)); + + sleep(2 * Timeouts.SECOND); + + /* +-1% is still acceptable */ + EcuTestHelper.assertEquals("Idle PWM freq", 160, SensorCentral.getInstance().getValue(Sensor.debugIntField1),0.01); + + + if (ControllerConnectorState.firmwareVersion == null) + throw new IllegalStateException("firmwareVersion has not arrived"); + + } + +} \ No newline at end of file