Skip to content

Commit d0bbc51

Browse files
committed
feat: average cell measurements
ABS firmware 1.2.0 added averaged cell measurement commands. Add support for these commands, enabled by absscpi v1.1.0.
1 parent abff99a commit d0bbc51

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

absscpi/client.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,88 @@ def measure_all_cell_currents(self) -> list[float]:
10431043
self.__check_err(res)
10441044
return currents[:]
10451045

1046+
def measure_average_cell_voltage(self, cell: int) -> float:
1047+
"""Retrieve the rolling average of the last 10 voltage measurements for
1048+
a single cell.
1049+
1050+
At the default sample rate, this is a 10ms window. With filtering on,
1051+
the length of this window will change.
1052+
1053+
Args:
1054+
cell: Target cell index, 0-7.
1055+
1056+
Returns:
1057+
Average measured cell voltage.
1058+
1059+
Raises:
1060+
ScpiClientError: An error occurred while executing the query.
1061+
"""
1062+
voltage = c_float()
1063+
res = self.__dll.AbsScpiClient_MeasureAverageCellVoltage(
1064+
self.__handle, c_uint(cell), byref(voltage))
1065+
self.__check_err(res)
1066+
return voltage.value
1067+
1068+
def measure_all_average_cell_voltages(self) -> list[float]:
1069+
"""Retrieve the rolling average of the last 10 voltage measurements for
1070+
all cells.
1071+
1072+
At the default sample rate, this is a 10ms window. With filtering on,
1073+
the length of this window will change.
1074+
1075+
Returns:
1076+
Array of average voltages, one per cell.
1077+
1078+
Raises:
1079+
ScpiClientError: An error occurred while executing the query.
1080+
"""
1081+
voltages = (c_float * CELL_COUNT)()
1082+
res = self.__dll.AbsScpiClient_MeasureAllAverageCellVoltages(
1083+
self.__handle, byref(voltages), c_uint(CELL_COUNT))
1084+
self.__check_err(res)
1085+
return voltages[:]
1086+
1087+
def measure_average_cell_current(self, cell: int) -> float:
1088+
"""Retrieve the rolling average of the last 10 current measurements for
1089+
a single cell.
1090+
1091+
At the default sample rate, this is a 10ms window. With filtering on,
1092+
the length of this window will change.
1093+
1094+
Args:
1095+
cell: Target cell index, 0-7.
1096+
1097+
Returns:
1098+
Average measured cell current.
1099+
1100+
Raises:
1101+
ScpiClientError: An error occurred while executing the query.
1102+
"""
1103+
current = c_float()
1104+
res = self.__dll.AbsScpiClient_MeasureAverageCellCurrent(
1105+
self.__handle, c_uint(cell), byref(current))
1106+
self.__check_err(res)
1107+
return current.value
1108+
1109+
def measure_all_average_cell_currents(self) -> list[float]:
1110+
"""Retrieve the rolling average of the last 10 current measurements for
1111+
all cells.
1112+
1113+
At the default sample rate, this is a 10ms window. With filtering on,
1114+
the length of this window will change.
1115+
1116+
Returns:
1117+
Array of average currents, one per cell.
1118+
1119+
Raises:
1120+
ScpiClientError: An error occurred while executing the query.
1121+
"""
1122+
currents = (c_float * CELL_COUNT)()
1123+
res = self.__dll.AbsScpiClient_MeasureAllAverageCellCurrents(
1124+
self.__handle, byref(currents), c_uint(CELL_COUNT))
1125+
self.__check_err(res)
1126+
return currents[:]
1127+
10461128
def get_cell_operating_mode(self, cell: int) -> AbsCellMode:
10471129
"""Query a single cell's operating mode (constant voltage or current
10481130
limited).

0 commit comments

Comments
 (0)