You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-3Lines changed: 60 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,8 +38,46 @@ Requires Python version 3.6 or greater
38
38
* Ethernet (TCPIP/UDP) support
39
39
40
40
## Use Instructions
41
-
Once the package has been installed to the python environment, it may be used to communicate action statuses with target BS1200 units, or to configure settings for a BS1200 at a designated IP address.
42
-
### Driver
41
+
Once the package has been installed to the python environment, the `BS1200` driver class may be used to communicate action statuses with target BS1200 units over a PCAN adapter, or to configure settings for a BS1200 at a designated IP address using the `ConfigTools` class.
42
+
### BS1200 (driver)
43
+
To initialize the driver, simply create an instance with a integer list of the Box IDs of the BS1200 units connected to the PCAN bus, i.e.
44
+
```
45
+
from bs1200 import BS1200
46
+
47
+
test_unit = BS1200([0])
48
+
test_unit.query_system_status(0)
49
+
test_unit.close()
50
+
```
51
+
Or an equivalent statement using the Python 'with' structure can be used for the driver:
52
+
```
53
+
from bs1200 import BS1200
54
+
55
+
with BS1200([0]) as bs:
56
+
bs.query_system_status(0)
57
+
```
58
+
for a single BS1200 with the CAN Box ID set to 0.
59
+
Once the object is created, the PCAN bus is initialized and a communication session using the device channel PCAN_USBBUS1 has started. The following action status methods may then be used to interact with the BS1200 bus:
| query_system_status | boxid (int): Box ID of the queried unit | Returns printed statements for the unit's fan statuses and temperature sensor readings |
63
+
| hil_mode | boxid (int): Box ID of the target unitenable_HIL (bool): True to enable HIL Mode, False to disable | Enable or disable the BS1200 in HIL mode. Returns PCAN bus OK status. Once set, the Battery Simulator will execute only the commands defined as active in HIL mode. By default all auxiliary configuration channels are set to disabled during HIL mode. In order to change this option, the configuration frame must be used. Note, the Configure frame is not supported in HIL mode, so this must be sent while HIL mode is disabled. |
64
+
| config_can_publishing | boxid (int): Target BS1200 unitdio_en (bool): Enable/Disable (True/False) digital IO publishing in HIL modeao_en (bool): Enable/Disable (True/False) analog publishing in HIL modeai_en (bool): Enable/Disable (True/False) analog output publishing in HIL mode | Sends the configuration frame for CAN publishing in HIL Mode. The Configure frame is not supported in HIL mode, so this must be sent while HIL mode is disabled. |
65
+
| cell_enable | boxid (int): Target BS1200 unitchannel (int): BS1200 cell to change enabled status of | Enable or disable a cell channel on the target BS1200 unit. Enter 'true' to enable, 'false' to disable, valid channel values 1-12 |
66
+
| cell_enable_all | boxid (int): Target BS1200 unit | Enable or disable all channels for a target BS1200 unit. Enter 'true' to enable, 'false' to disable |
67
+
| set_cell_V | boxid (int): Target BS1200 unitchannel (int): Cell to set voltage forvoltage (float): voltage level to set the designated cell | Set an individual cell (1-12) to designated voltage value input range 0.00 to 5.00 Volts |
68
+
| set_V_all | boxid (int): Target BS1200 unittgt_volt (float): Target voltage to set all cell channels | Set the cell voltage for Cells 1-12, valid inputs from 0.00 to 5.00 Volts |
69
+
| readback_cell_V | boxid (int): Target BS1200 unitchannel (int): Cell to read voltage of | Readback voltage value of designated cell channel 1-12, returns float value. |
70
+
| readback_V_all | boxid (int): Target BS1200 unit | Return list of voltage values (V) for all cell channels. |
71
+
| set_cell_I_sink | boxid (int): Target BS1200 unitchannel (int): Cell to set sinking current limit ofsink_current (float): Target cell current sinking limit (valid values 0-0.5A) | Construct and send message to set an individual cell current sinking value |
72
+
| set_cell_I_source | boxid (int): Target BS1200 unitchannel (int): Cell to set sourcing current limit ofsource_current (float): Target cell current sinking limit (valid values 0-0.5A) | Construct and send message to set an individual cell current sourcing value |
73
+
| set_I_all | boxid (int): Target BS1200 unitsink_i (float): Sinking current for all cells, Valid in range 0-0.5 Asource_i (float): Sourcing current for all cells, Valid in range 0-0.5 A | Set the sink and sourcing current limits for all cells. Valid in range 0-0.5 A |
74
+
| readback_cell_I | boxid (int): Target BS1200 unitchannel (int): Target cell channel | Return the current readback (A) for the designated cell channel (1-12) |
75
+
| readback_I_all | boxid (int): Target BS1200 unit | Return current readbacks (A) for all cell channels 1-12 as a list of floats |
76
+
| readback_ai_v | boxid (int): Target BS1200 unitchannel (int): Target analog input channel | Returns the voltage level for the target Analog Input Channel (valid channels 1-8) |
77
+
| readback_ai_all | boxid (int): Target BS1200 unit | Returns the voltage levels for Analog Input Channels 1-8 as an array of float values |
78
+
| ao_set | boxid (int): BS1200 unit to set analog outputs forAO1_Voltage (float): voltage setpoint for AO 1 (0-5V)AO2_Voltage (float): voltage setpoint for AO 2 (0-5V) | Set the BS1200's Analog Output voltage setpoints. Valid range from 0-5 V. |
79
+
| dio_set | dio_dir (list[int]): List of Boolean values designating direction of each DIO Channel. Set 1 to configure as Output, 0 to configure as Input.dio_en (list[int]): Enables the DIO line when the direction is also set as output (True) | Set the direction of Digital IO Channels 1-8. |
80
+
| readback_dio | boxid (int): Box ID of unit to read DIO from | Returns state of Digital Input/Output Lines as a list of booleans |
43
81
44
82
### ConfigTools
45
83
The features of the configuration mode seen in the BS1200 Soft Front Panel are available as a module of the b1200 python driver.
@@ -52,4 +90,23 @@ To apply individual categories can be used by importing the dataclasses used for
52
90
```
53
91
from bs1200 import ConfigTools, Ethernet_Settings, CAN_Settings, Protocol
54
92
```
55
-
By just importing the ConfigTools configuration settings may be read as a json object (optionally to a .json file) using get_all_settings(ExportToFile: bool) and apply_config_file(cfg_file_path: str).
93
+
By just importing the ConfigTools configuration settings may be read as a json object (optionally to a .json file) using get_all_settings(ExportToFile: bool) and apply_config_file(cfg_file_path: str).
94
+
BS1200 Configuration JSON object example:
95
+
```
96
+
{
97
+
"Protocol": "CAN",
98
+
"IP_Address": "192.168.1.100",
99
+
"Ethernet_Settings": {
100
+
"TCP_Cmd_Port": "12345",
101
+
"TCP_Cmd_Interval_ms": "10",
102
+
"UDP_Read_Port": "54321",
103
+
"UDP_Read_Interval_ms": "5"
104
+
},
105
+
"CAN_Settings": {
106
+
"Box_ID": 1,
107
+
"Write_Period_ms": 5
108
+
}
109
+
}
110
+
```
111
+
By default the methods used to set configuration values will restart the connected target using the NI System Configuration API. It is highly reccomended to restart the unit whenever updating values to prevent a desynchronization between the target IP address saved to class properties and currently used IP address of the device.
112
+
When restarting the target BS1200, the console will output status messages while the module waits for the `nisyscfg` restart method to return, signalling that the target is back online. The `ConfigTools` object will update to the newly set IP address so that further configuration may take place without needing to recreate the object.
0 commit comments