hitl_tester.test_cases.bms.test_impedance
Measure impedance by triggering a pulse (0-1A) for 0.25 seconds and measuring the voltage. Impedance = delta V / delta I
Run with python3 hitl_tester.py devel_test.plan -c
Used in these test plans:
- devel_test ⠀⠀⠀(bms/devel_test.plan)
- devel_test ⠀⠀⠀(bms/devel_test.plan)
Example Command (warning: test plan may run other test cases):
./hitl_tester.py devel_test
1""" 2Measure impedance by triggering a pulse (0-1A) for 0.25 seconds and measuring the voltage. 3Impedance = delta V / delta I 4 5Run with `python3 hitl_tester.py devel_test.plan -c` 6""" 7 8import math 9 10import pytest 11 12from hitl_tester.modules.bms.bms_hw import BMSHardware 13 14bms_hardware = BMSHardware(pytest.flags) # type: ignore[arg-type] 15bms_hardware.init() 16 17 18def calculate_impedance(data: list[float]) -> float: 19 """Calculate the impedance from the raw voltages.""" 20 for i, voltage in enumerate(data): 21 if i > 0 and data[i - 1] - voltage > 0.001: 22 for j in range(8): 23 print(data[i - 2 + j]) 24 return (data[i - 1] - data[i + 2]) * 1000 25 return math.nan 26 27 28def test_impedance(): 29 """Record the voltage drop with a current pulse.""" 30 bms_hardware.load.configure_pulse_trigger() 31 bms_hardware.dmm.configure_voltage_trigger() 32 bms_hardware.load.enable() 33 bms_hardware.dmm.send_trigger() # Begin voltage measurements 34 bms_hardware.load.send_trigger() # Pulse the current 35 bms_hardware.load.wait_for_pulse() # Wait for load pulse to complete 36 bms_hardware.load.disable() 37 data = bms_hardware.dmm.read_internal_memory() 38 bms_hardware.dmm.configure_voltage_normal() 39 print(data) 40 print(f"Impedance: {calculate_impedance(data)}")
bms_hardware =
<hitl_tester.modules.bms.bms_hw.BMSHardware object>
def
calculate_impedance(data: list[float]) -> float:
19def calculate_impedance(data: list[float]) -> float: 20 """Calculate the impedance from the raw voltages.""" 21 for i, voltage in enumerate(data): 22 if i > 0 and data[i - 1] - voltage > 0.001: 23 for j in range(8): 24 print(data[i - 2 + j]) 25 return (data[i - 1] - data[i + 2]) * 1000 26 return math.nan
Calculate the impedance from the raw voltages.
def
test_impedance():
29def test_impedance(): 30 """Record the voltage drop with a current pulse.""" 31 bms_hardware.load.configure_pulse_trigger() 32 bms_hardware.dmm.configure_voltage_trigger() 33 bms_hardware.load.enable() 34 bms_hardware.dmm.send_trigger() # Begin voltage measurements 35 bms_hardware.load.send_trigger() # Pulse the current 36 bms_hardware.load.wait_for_pulse() # Wait for load pulse to complete 37 bms_hardware.load.disable() 38 data = bms_hardware.dmm.read_internal_memory() 39 bms_hardware.dmm.configure_voltage_normal() 40 print(data) 41 print(f"Impedance: {calculate_impedance(data)}")
Record the voltage drop with a current pulse.