From 6aaebb76d5bb121597bc72423681649a321c002f Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 27 Feb 2025 20:22:54 -0500 Subject: [PATCH 1/4] Maybe the main logic for the discharge test highkey don't really know what I am doing when there is no pre-written config, but it seems like this is kinda what I should be doing???????? --- .../node_specific/scripts/test_discharge.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scripts/node_specific/scripts/test_discharge.py diff --git a/scripts/node_specific/scripts/test_discharge.py b/scripts/node_specific/scripts/test_discharge.py new file mode 100644 index 0000000..b8f79ae --- /dev/null +++ b/scripts/node_specific/scripts/test_discharge.py @@ -0,0 +1,53 @@ +from os import sys, path +# adds "./HIL-Testing" to the path, basically making it so these scripts were run one folder level higher +sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) + +from hil.hil import HIL +import hil.utils as utils +import time +from scripts.common.constants.rules_constants import * +from scripts.common.constants.vehicle_constants import * + +import pytest_check as check +import pytest + + +# ---------------------------------------------------------------------------- # +@pytest.fixture(scope="session") +def hil(): + hil_instance = HIL() + + # TODO: new config file + hil_instance.load_config("config_system_hil_attached.json") + hil_instance.load_pin_map("per_24_net_map.csv", "stm32f407_pin_map.csv") + + hil_instance.init_can() + + yield hil_instance + + hil_instance.shutdown() +# ---------------------------------------------------------------------------- # + + +# ---------------------------------------------------------------------------- # +@pytest.mark.parametrize("tsms_set, hv_plus_set, discharge_plus_expected", [ + (0, 0, 0), # TSMS low, HV+ low -> discharge disconnected (0) + (1, 0, 0), # TSMS high, HV+ low -> discharge connected but no voltage (0) + (0, 1, 0), # TSMS low, HV+ high -> discharge disconnected (0) + (1, 1, 1), # TSMS high, HV+ high -> discharge connected with voltage (1) +]) +def test_main_relay(hil, tsms_set, hv_plus_set, discharge_plus_expected): + # HIL outputs (hil writes) + tsms = hil.dout("Discharge", "SDC15 - TSMS") + hv_plus = hil.dout("Discharge", "HV+") + + # HIL inputs (hil reads) + discharge_plus = hil.din("Discharge", "discharge+") + + tsms.state = tsms_set + hv_plus.state = hv_plus_set + time.sleep(0.1) + + message = f"TSMS: {tsms_set}, HV+: {hv_plus_set} -> Discharge+: {discharge_plus_expected}" + check.equal(discharge_plus.state, discharge_plus_expected, message) +# ---------------------------------------------------------------------------- # From 48ba761dc5b5bf1caaa28e77a977339037c17bf3 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 27 Feb 2025 20:30:11 -0500 Subject: [PATCH 2/4] Trying to do the config for Discharge --- configurations/config_system_hil_attached.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configurations/config_system_hil_attached.json b/configurations/config_system_hil_attached.json index a32921f..3fa53b8 100644 --- a/configurations/config_system_hil_attached.json +++ b/configurations/config_system_hil_attached.json @@ -17,6 +17,11 @@ {"dut":{"connector":"J1","pin":10}, "hil":{"device":"FrontTester", "port":"DAC2"}}, {"dut":{"connector":"J1","pin":11}, "hil":{"device":"FrontTester", "port":"POT1"}}, {"dut":{"connector":"J1","pin":12}, "hil":{"device":"FrontTester", "port":"POT2"}} + ]}, + {"board":"Discharge", "harness_connections":[ + {"dut":{"connector":"P7","pin":3}, "hil":{"device":"RearTester", "port":"DI3"}}, + {"dut":{"connector":"P1","pin":1}, "hil":{"device":"RearTester", "port":"AI1"}}, + {"dut":{"connector":"P2","pin":10}, "hil":{"device":"RearTester", "port":"AI2"}} ]} ], "hil_devices":[ From 37f6915145afe1793b5b0cd860f830b8272fa297 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 27 Feb 2025 20:34:26 -0500 Subject: [PATCH 3/4] SDC15 - TSMS is inverted --- scripts/node_specific/scripts/test_discharge.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/node_specific/scripts/test_discharge.py b/scripts/node_specific/scripts/test_discharge.py index b8f79ae..72a99fa 100644 --- a/scripts/node_specific/scripts/test_discharge.py +++ b/scripts/node_specific/scripts/test_discharge.py @@ -31,10 +31,10 @@ def hil(): # ---------------------------------------------------------------------------- # @pytest.mark.parametrize("tsms_set, hv_plus_set, discharge_plus_expected", [ - (0, 0, 0), # TSMS low, HV+ low -> discharge disconnected (0) - (1, 0, 0), # TSMS high, HV+ low -> discharge connected but no voltage (0) - (0, 1, 0), # TSMS low, HV+ high -> discharge disconnected (0) - (1, 1, 1), # TSMS high, HV+ high -> discharge connected with voltage (1) + (1, 0, 0), # TSMS low = relay open, HV+ low -> discharge disconnected (0) + (0, 0, 0), # TSMS high = relay closed, HV+ low -> discharge connected but no voltage (0) + (1, 1, 0), # TSMS low = relay open, HV+ high -> discharge disconnected (0) + (0, 1, 1), # TSMS high = relay closed, HV+ high -> discharge connected with voltage (1) ]) def test_main_relay(hil, tsms_set, hv_plus_set, discharge_plus_expected): # HIL outputs (hil writes) From 61b35b82e892cd6734610db9a3d8a0257ddc6070 Mon Sep 17 00:00:00 2001 From: Millan Kumar Date: Thu, 27 Feb 2025 20:37:16 -0500 Subject: [PATCH 4/4] Have to use HIL RLY because SDC15 - TSMS is 24V logic --- configurations/config_system_hil_attached.json | 2 +- scripts/node_specific/scripts/test_discharge.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/configurations/config_system_hil_attached.json b/configurations/config_system_hil_attached.json index 3fa53b8..9cf63f9 100644 --- a/configurations/config_system_hil_attached.json +++ b/configurations/config_system_hil_attached.json @@ -21,7 +21,7 @@ {"board":"Discharge", "harness_connections":[ {"dut":{"connector":"P7","pin":3}, "hil":{"device":"RearTester", "port":"DI3"}}, {"dut":{"connector":"P1","pin":1}, "hil":{"device":"RearTester", "port":"AI1"}}, - {"dut":{"connector":"P2","pin":10}, "hil":{"device":"RearTester", "port":"AI2"}} + {"dut":{"connector":"P2","pin":10}, "hil":{"device":"RearTester", "port":"RLY1"}} ]} ], "hil_devices":[ diff --git a/scripts/node_specific/scripts/test_discharge.py b/scripts/node_specific/scripts/test_discharge.py index 72a99fa..34ab3ed 100644 --- a/scripts/node_specific/scripts/test_discharge.py +++ b/scripts/node_specific/scripts/test_discharge.py @@ -38,15 +38,18 @@ def hil(): ]) def test_main_relay(hil, tsms_set, hv_plus_set, discharge_plus_expected): # HIL outputs (hil writes) - tsms = hil.dout("Discharge", "SDC15 - TSMS") + + # WIRING NOTE: SDC15 - TSMS is 24V logic, Arudino max voltage is 5V + # So instead, HIL will control the relay and 24V will be wired through the relay + tsms_hil_relay = hil.dout("Discharge", "SDC15 - TSMS") hv_plus = hil.dout("Discharge", "HV+") # HIL inputs (hil reads) discharge_plus = hil.din("Discharge", "discharge+") - tsms.state = tsms_set + tsms_hil_relay.state = not tsms_set # HIL relay is inverted hv_plus.state = hv_plus_set - time.sleep(0.1) + time.sleep(0.2) message = f"TSMS: {tsms_set}, HV+: {hv_plus_set} -> Discharge+: {discharge_plus_expected}" check.equal(discharge_plus.state, discharge_plus_expected, message)