Skip to content

Commit 473b95a

Browse files
committed
Updated test scripts
1 parent e1acf0c commit 473b95a

File tree

6 files changed

+85
-11
lines changed

6 files changed

+85
-11
lines changed

tests/atp.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from bs1200 import BS1200
2+
import time
3+
4+
u = [1]
5+
with BS1200(u, 'PCAN_USBBUS1', 1000000) as units:
6+
for unit in range(1,len(u)+1):
7+
print("Testing unit "+str(unit))
8+
units.set_V_all(unit, 0) # set all cells to 0V
9+
print("Setting all unit "+str(unit)+" cells to 0V")
10+
print("Setting current limits on unit "+str(unit)+" to 500mA src/sink")
11+
units.set_I_all(unit, 0.5, 0.5)
12+
print("Enabling all cells on unit "+str(unit))
13+
units.cell_enable_all(unit, True)
14+
for cell in range(1,13):
15+
units.set_cell_I_source(unit, cell, 0.5)
16+
units.set_cell_I_sink(unit, cell, 0.5)
17+
volts = units.readback_V_all(unit)
18+
amps = units.readback_I_all(unit)
19+
print(units.v_fmt_txt.format(*volts))
20+
print(units.i_fmt_txt.format(*amps))
21+
input("All units initialized-- enter to continue")
22+
23+
for unit in range(1,len(u)+1):
24+
for cell in range(1,13):
25+
print("\nUnit "+str(unit)+" cell "+str(cell))
26+
units.set_cell_V(unit, cell, 4.5)
27+
units.set_cell_I_source(unit, cell, 0.5)
28+
units.set_cell_I_sink(unit, cell, 0.5, wait=True) #wait set to True for 10 ms delay
29+
volts = units.readback_V_all(unit)
30+
amps = units.readback_I_all(unit)
31+
print("Cell voltages:\n"+units.v_fmt_txt.format(*volts))
32+
print("Cell currents:\n"+units.i_fmt_txt.format(*amps))
33+
input("Measure current w/dmm on cell "+str(cell)+" unit "+str(unit))
34+
units.set_cell_V(unit, cell, 0)
35+
input("Press enter to continue to next cell")

tests/configtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
with open('bs1200_cfg.json', 'w') as f:
99
json.dump({"Protocol": "CAN", "IP_Address": "192.168.1.102", "Ethernet_Settings":
1010
{"TCP_Cmd_Port": "12345", "TCP_Cmd_Interval_ms": "20", "UDP_Read_Port": "54321", "UDP_Read_Interval_ms": "10"},
11-
"CAN_Settings": {"Box_ID": 2, "Write_Period_ms": 5}, "Enable_SafetyInterlock" : True}, f)
11+
"CAN_Settings": {"Box_ID": 2, "Write_Period_ms": 5}, "Enable_SafetyInterlock" : False}, f)
1212

1313
test.apply_config_file('bs1200_cfg.json', False)
1414

tests/debugtest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from time import sleep
2+
from bs1200 import BS1200
3+
4+
box = 1
5+
with BS1200([box]) as bs:
6+
bs.query_system_status(box)
7+
#print(bs.rx_cache)
8+
bs.set_cell_V(1, 1, 4)
9+
bs.cell_enable(1,1, True)
10+
sleep(0.5)
11+
print(bs.readback_cell_V(1,1))
12+
bs.cell_enable_all(1, False)

tests/dio_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
bs.query_system_status(box)
99
bs.config_can_publishing(box, True, True, True)
1010
ai_v = bs.readback_ai_all(box)
11-
print(bs.ai_v_output_txt.format(*ai_v))
11+
print(bs.i_fmt_txt.format(*ai_v))
1212
bs.config_can_publishing(box, True, False, False)
1313
bs.hil_mode(box, False)
1414
dio_directions = 8*[1]

tests/readloop.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from time import sleep
2+
import bs1200
3+
4+
with bs1200.BS1200([1], 'PCAN_USBBUS1', 1000000) as bs:
5+
#sleep(0.01)
6+
bs.query_system_status(1)
7+
bs.set_V_all(1, 0.00)
8+
bs.set_I_all(1, 0.5, 0.5)
9+
bs.cell_enable_all(1, True, True)
10+
#sleep(0.05)
11+
volts = bs.readback_V_all(1)
12+
amps = bs.readback_I_all(1)
13+
print('Cell Voltages:\n' + bs.v_fmt_txt.format(*volts))
14+
print('Cell Currents:\n' + bs.i_fmt_txt.format(*amps))
15+
sp = 0.1
16+
while(sp <= 5.0):
17+
print("\n\nSettings all to " + str(sp) + " V")
18+
bs.set_V_all(1, sp, True)
19+
volts = bs.readback_V_all(1)
20+
print('Cell Voltages:\n' + bs.v_fmt_txt.format(*volts))
21+
sp += 0.1
22+
print("Resetting to 0 and disabling all cells")
23+
bs.set_V_all(1, 0.00)
24+
bs.set_I_all(1, 0.0, 0.0)
25+
bs.cell_enable_all(1, False)
26+
volts = bs.readback_V_all(1)
27+
amps = bs.readback_I_all(1)
28+
print('Cell Voltages:\n' + bs.v_fmt_txt.format(*volts))
29+
print('Cell Currents:\n' + bs.i_fmt_txt.format(*amps))

tests/write_volts_test.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
from time import sleep
2-
import sys
3-
sys.path.append('src')
42
import bs1200
53

64
loop = True
@@ -12,20 +10,20 @@
1210
bs.cell_enable_all(1, True)
1311
sleep(1)
1412
volts = bs.readback_V_all(1)
15-
print(bs.cell_v_output_txt.format(*volts))
13+
print(bs.v_fmt_txt.format(*volts))
1614
if loop:
1715
for i in range(1,13):
18-
print('---------------\nSetting Cell '+str(i)+' to 1 Volt')
19-
bs.set_cell_V(1, i, 1.00)
16+
print('---------------\nSetting Cell '+str(i)+' to 2.5 Volt')
17+
bs.set_cell_V(1, i, 2.50)
2018
sleep(1)
2119
volts = bs.readback_V_all(1)
2220
amps = bs.readback_I_all(1)
23-
print('Cell Voltages:\n' + bs.cell_v_output_txt.format(*volts))
24-
print('Cell Currents:\n' + bs.cell_i_output_txt.format(*amps))
21+
print('Cell Voltages:\n' + bs.v_fmt_txt.format(*volts))
22+
print('Cell Currents:\n' + bs.i_fmt_txt.format(*amps))
2523
else:
2624
if bs.set_V_all(1, 4.00): print("Setting all cells to 4.00 V")
2725
sleep(1)
2826
volts = bs.readback_V_all(1)
2927
amps = bs.readback_I_all(1)
30-
print('Cell Voltages:\n' + bs.cell_v_output_txt.format(*volts))
31-
print('Cell Currents:\n' + bs.cell_i_output_txt.format(*amps))
28+
print('Cell Voltages:\n' + bs.v_fmt_txt.format(*volts))
29+
print('Cell Currents:\n' + bs.i_fmt_txt.format(*amps))

0 commit comments

Comments
 (0)