Skip to content

Commit 96fdb50

Browse files
authored
Merge pull request #66 from VektrexElectronicSystems/development
Development v1.12.0
2 parents f7c871f + 2989534 commit 96fdb50

File tree

28 files changed

+551
-16
lines changed

28 files changed

+551
-16
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ See [System Requirements for MATLAB Engine API for Python](https://www.mathworks
214214
Why does my script's performance vary between different operating systems and machines?
215215
See [Remarks](/spikesafe_python_lib_docs/Threading/wait/README.md#remarks) describing resolution of system timers between operating systems.
216216

217+
How does Python handle locale?
218+
The [locale](https://docs.python.org/3/library/locale.html#module-locale) module is implemented on top of the _locale module, which in turn uses an ANSI [C locale](https://docs.oracle.com/cd/E19253-01/817-2521/overview-1002/index.html) (also called the "POSIX locale") implementation if available. The C locale is often described as "culture-neutral" because it doesn't apply any regional or language-specific rules for formatting data. It is a basic, system-independent locale that follows standardized rules for formatting data such as numbers, dates, and currency. The C locale uses U.S.-style conventions by default, such as:
219+
- Period (.) as the decimal point for numbers
220+
- Simple ASCII character classification and sorting
221+
- English-style date and time formats
222+
217223
## Support/Feedback
218224

219225
If any further assistance is needed beyond the information provided within this repository, email [email protected].

spikesafe_python_lib_docs/Compensation/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ Provides a collection of helper functions you can use to help with SpikeSafe com
88
### Functions
99
| Name | Description |
1010
| - | - |
11-
| [get_optimum_compensation(spikesafe_model_max_current_amps, set_current_amps, pulse_on_time_seconds: None)](/spikesafe_python_lib_docs/Compensation/get_optimum_compensation/README.md) | Returns the optimum compensation for a given set current. |
11+
| [get_custom_compensation(spikesafe_model_max_current_amps, set_current_amps, device_type, custom_compensation_table, pulse_on_time_seconds=None)](/spikesafe_python_lib_docs/Compensation/get_custom_compensation/README.md) | Returns the custom compensation values for a given set_current_amps and device_type based on a custom_compensation_table, and optionally a given pulse on time. |
12+
| [get_optimum_compensation(spikesafe_model_max_current_amps, set_current_amps, pulse_on_time_seconds: None)](/spikesafe_python_lib_docs/Compensation/get_optimum_compensation/README.md) | Returns the optimum compensation for a given set current, and optionally a given pulse on time. |
13+
| [load_custom_compensation_table(file_path)](/spikesafe_python_lib_docs/Compensation/load_custom_compensation_table/README.md) | Returns a custom compensation table from a JSON file. |
14+
| [load_custom_compensation_unique_device_types(custom_compensation_table)](/spikesafe_python_lib_docs/Compensation/load_custom_compensation_unique_device_types/README.md) | Returns the unique device types from a custom compensation table. |
15+
16+
### Schemas
17+
| Name | Description |
18+
| - | - |
19+
| [custom_compensation_table_schema](/spikesafe_python_lib_docs/Compensation/custom_compensation_table_schema/README.md) | This schema defines the structure of the data required for custom compensation in the system. It is a list of objects, where each object contains details about compensation settings for a specific device. Below are the fields and their descriptions. |
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# [spikesafe-python API Overview](/spikesafe_python_lib_docs/README.md) | [Compensation](/spikesafe_python_lib_docs/Compensation/README.md) | custom_compensation_table_schema
2+
3+
## custom_compensation_table_schema
4+
5+
### Definition
6+
This schema defines the structure of the data required for custom compensation in the system. It is a list of objects, where each object contains details about compensation settings for a specific device. Below are the fields and their descriptions.
7+
8+
### Schema Overview
9+
- Type: [list([])](https://docs.python.org/3/library/stdtypes.html#list) of objects
10+
- Minimum items: 1 (at least one compensation setting is required)
11+
12+
### Object Fields
13+
Each object in the array must contain the following fields:
14+
15+
spikesafe_model_max_current_amps [number](https://json-schema.org/understanding-json-schema/reference/numeric#number)
16+
- The maximum current supported by the SpikeSafe model in amps.
17+
- Constraints: The value must be a number greater than or equal to 0.
18+
19+
device_type [string](https://docs.python.org/3/library/string.html)
20+
- The type of device the compensation setting applies to.
21+
22+
is_default [bool](https://docs.python.org/3/library/stdtypes.html#boolean-values)
23+
- Indicates whether this is the default compensation setting for the device_type.
24+
- Constraints: The value must be true for one object per spikesafe_model_max_current_amps and device_type combination.
25+
26+
set_current_amps_start_range [number](https://json-schema.org/understanding-json-schema/reference/numeric#number)
27+
- The starting range of the current set point in amps.
28+
- Constraints:
29+
- The value must be a number greater than or equal to 0.
30+
- The value must be less than set_current_amps_end_range.
31+
32+
set_current_amps_end_range [number](https://json-schema.org/understanding-json-schema/reference/numeric#number)
33+
- The ending range of the current set point in amps.
34+
- Constraints:
35+
- The value must be a number greater than or equal to 0.
36+
- The value must be greater than set_current_amps_start_range.
37+
38+
load_impedance [string](https://docs.python.org/3/library/string.html)
39+
- The impedance load setting for the compensation configuration.
40+
- Constraints: Must be equal to the name of an enum in [LoadImpedance](/spikesafe_python_lib_docs/SpikeSafeEnums/LoadImpedance/README.md).
41+
42+
rise_time [string](https://docs.python.org/3/library/string.html)
43+
- The rise time setting for the compensation configuration.
44+
- Constraints: Must be equal to the name of an enum in [RiseTime](/spikesafe_python_lib_docs/SpikeSafeEnums/RiseTime/README.md).
45+
46+
### Example JSON
47+
Here is an example of a valid JSON object that conforms to the schema:
48+
49+
```
50+
[
51+
{
52+
"spikesafe_model_max_current_amps": 0.5,
53+
"device_type": "laser_red",
54+
"is_default": true,
55+
"set_current_amps_start_range": 0,
56+
"set_current_amps_end_range": 0.0075,
57+
"load_impedance": "HIGH",
58+
"rise_time": "FAST"
59+
},
60+
{
61+
"spikesafe_model_max_current_amps": 0.5,
62+
"device_type": "laser_red",
63+
"is_default": false,
64+
"set_current_amps_start_range": 0.0075,
65+
"set_current_amps_end_range": 0.125,
66+
"load_impedance": "MEDIUM",
67+
"rise_time": "FAST"
68+
}
69+
{
70+
"spikesafe_model_max_current_amps": 0.5,
71+
"device_type": "laser_red",
72+
"is_default": false,
73+
"set_current_amps_start_range": 0.375,
74+
"set_current_amps_end_range": 0.5,
75+
"load_impedance": "MEDIUM",
76+
"rise_time": "FAST"
77+
}
78+
]
79+
```
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# [spikesafe-python API Overview](/spikesafe_python_lib_docs/README.md) | [Compensation](/spikesafe_python_lib_docs/Compensation/README.md) | get_custom_compensation(spikesafe_model_max_current_amps, set_current_amps, device_type, custom_compensation_table, pulse_on_time_seconds=None)
2+
3+
## get_custom_compensation(spikesafe_model_max_current_amps, set_current_amps, device_type, custom_compensation_table, pulse_on_time_seconds=None)
4+
5+
### Definition
6+
Returns the custom compensation values for a given set_current_amps and device_type based on a custom_compensation_table, and optionally a given pulse on time.
7+
8+
### Parameters
9+
spikesafe_model_max_current_amps [float](https://docs.python.org/3/library/functions.html#float)
10+
Maximum current of the SpikeSafe model
11+
12+
set_current_amps [float](https://docs.python.org/3/library/functions.html#float)
13+
Current to be set on SpikeSafe
14+
15+
device_type [string](https://docs.python.org/3/library/string.html)
16+
Device type of the DUT
17+
18+
custom_compensation_table [list([])](https://docs.python.org/3/library/stdtypes.html#list)
19+
Custom compensation table to be used for compensation. This should be the result of calling the [load_custom_compensation_table(file_path)](/spikesafe_python_lib_docs/Compensation/load_custom_compensation_table/README.md) function conforming to the [custom_compensation_table_schema](/spikesafe_python_lib_docs/Compensation/custom_compensation_table_schema/README.md)
20+
21+
pulse_on_time_seconds [float](https://docs.python.org/3/library/functions.html#float) [optional](https://docs.python.org/3/library/typing.html#typing.Optional)
22+
Pulse On Time to be set on SpikeSafe
23+
24+
### Returns
25+
LoadImpedance [LoadImpedance](/spikesafe_python_lib_docs/SpikeSafeEnums/LoadImpedance/README.md)
26+
Load Impedance compensation value. This should be an instance of the LoadImpedance [IntEnum](https://docs.python.org/3/library/enum.html#enum.IntEnum) from SpikeSafeEnums
27+
28+
RiseTime [RiseTime](/spikesafe_python_lib_docs/SpikeSafeEnums/RiseTime/README.md)
29+
Rise Time compensation value. This should be an instance of the RiseTime [IntEnum](https://docs.python.org/3/library/enum.html#enum.IntEnum) from SpikeSafeEnums
30+
31+
### Raises
32+
[ValueError](https://docs.python.org/3/library/exceptions.html#ValueError)
33+
If set_current_amps is greater than spikesafe_model_max_current_amps
34+
35+
### Remarks
36+
This function assumes the set current is operating on the optimized current range. If operating on the high range with a set current normally programmed on the low range, the compensation values will not be optimal. See online specifications.
37+
- [Source Measure Unit Precision Pulsed Current Performance Series Specifications](https://www.vektrex.com/downloads/vektrex-spikesafe-smu-specifications.pdf)
38+
- [High Current Performance Series Precision Pulsed Current Source Measure Unit Specifications](https://www.vektrex.com/downloads/High-Current-SpikeSafe-Performance-Series-Precision-Pulsed-Source-Measure-Unit-Specifications.pdf)
39+
- [SpikeSafe™ Performance Series Precision Pulsed Current Source Specifications](https://www.vektrex.com/downloads/vektrex-spikesafe-performance-series-precision-pulsed-current-source-specifications.pdf)
40+
41+
If Load Impedance is returned as Medium or High, it is best practice to increase the Compliance Voltage setting by 5V to 30V. This helps the current amplifier to overcome inductance. If Compliance Voltage is not increased, then a Low Side Over Current or an Unstable Waveform error may occur.
42+
43+
If an Operating Mode is used to sweep through steps of currents where the compensation settings are the same across the sweep, such as Pulse Sweep or Multiple Pulse Burst, it is recommended use the custom compensation settings targeting the Stop Current.
44+
45+
### Examples
46+
The following example demonstrates the `get_custom_compensation()` function. It determines the custom compensation settings to use based off the SpikeSafe's set current setting, maximum settable current, and pulse on time.
47+
```
48+
# set Channel 1's Pulse On Time to 1ms and check for all events
49+
pulse_on_time = 0.001
50+
tcp_socket.send_scpi_command(f'SOUR1:PULS:TON {get_precise_time_command_argument(pulse_on_time)}')
51+
log_all_events(tcp_socket)
52+
53+
# set Channel 1's current to 100 mA and check for all events
54+
set_current = 0.1
55+
tcp_socket.send_scpi_command(f'SOUR1:CURR {get_precise_current_command_argument(set_current)}')
56+
log_all_events(tcp_socket)
57+
58+
# set Channel 1's compensation settings to their default values and check for all events
59+
# For higher power loads or shorter pulses, these settings may have to be adjusted to obtain ideal pulse shape
60+
tcp_socket.send_scpi_command('SOUR1:CURR? MAX')
61+
spikesafe_model_max_current = float(tcp_socket.read_data())
62+
63+
# load custom_compensation_table from /test_compensation_files/valid.json
64+
custom_compensation_table = load_custom_compensation_table(os.path.join(os.path.dirname(__file__), 'test_compensation_files', 'valid.json')
65+
device_types = load_custom_compensation_unique_device_types(custom_compensation_table)
66+
load_impedance, rise_time = get_custom_compensation(spikesafe_model_max_current, set_current, device_types[0], pulse_on_time)
67+
tcp_socket.send_scpi_command(f'SOUR1:PULS:CCOM {load_impedance}')
68+
log_all_events(tcp_socket)
69+
tcp_socket.send_scpi_command(f'SOUR1:PULS:RCOM {rise_time}')
70+
log_all_events(tcp_socket)
71+
```
72+
73+
### Examples In Action

spikesafe_python_lib_docs/Compensation/get_optimum_compensation/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ pulse_on_time_seconds [float](https://docs.python.org/3/library/functions.html#f
1616
Pulse On Time to be set on SpikeSafe
1717

1818
### Returns
19-
[int](https://docs.python.org/3/library/functions.html#int)
20-
Load impedance command argument with optimum compensation
21-
22-
[int](https://docs.python.org/3/library/functions.html#int)
23-
Rise time command argument with optimum compensation
19+
LoadImpedance [LoadImpedance](/spikesafe_python_lib_docs/SpikeSafeEnums/LoadImpedance/README.md)
20+
Load Impedance compensation value. This should be an instance of the LoadImpedance [IntEnum](https://docs.python.org/3/library/enum.html#enum.IntEnum) from SpikeSafeEnums
21+
22+
RiseTime [RiseTime](/spikesafe_python_lib_docs/SpikeSafeEnums/RiseTime/README.md)
23+
Rise Time compensation value. This should be an instance of the RiseTime [IntEnum](https://docs.python.org/3/library/enum.html#enum.IntEnum) from SpikeSafeEnums
2424

2525
### Raises
2626
[ValueError](https://docs.python.org/3/library/exceptions.html#ValueError)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# [spikesafe-python API Overview](/spikesafe_python_lib_docs/README.md) | [Compensation](/spikesafe_python_lib_docs/Compensation/README.md) | load_custom_compensation_table(file_path)
2+
3+
## load_custom_compensation_table(file_path)
4+
5+
### Definition
6+
Returns a custom compensation table from a JSON file.
7+
8+
### Parameters
9+
file_path [string](https://docs.python.org/3/library/string.html)
10+
Path to the JSON file containing the custom compensation table
11+
12+
### Returns
13+
list [list([])](https://docs.python.org/3/library/stdtypes.html#list)
14+
Custom compensation table as a list of dictionaries conforming to the [custom_compensation_table_schema](/spikesafe_python_lib_docs/Compensation/custom_compensation_table_schema/README.md)
15+
16+
### Raises
17+
[FileNotFoundError](https://docs.python.org/3/library/exceptions.html#FileNotFoundError)
18+
If the file does not exist
19+
20+
[IOError](https://docs.python.org/3/library/exceptions.html#IOError)
21+
If an error occurs while loading the file
22+
23+
[ValueError](https://docs.python.org/3/library/exceptions.html#ValueError)
24+
If the file contains invalid JSON, schema validation error, or custom compensation table validation error
25+
26+
### Examples
27+
The following example demonstrates the `load_custom_compensation_table()` function. It determines the custom compensation settings to use based off the SpikeSafe's set current setting, maximum settable current, and pulse on time.
28+
```
29+
# set Channel 1's Pulse On Time to 1ms and check for all events
30+
pulse_on_time = 0.001
31+
tcp_socket.send_scpi_command(f'SOUR1:PULS:TON {get_precise_time_command_argument(pulse_on_time)}')
32+
log_all_events(tcp_socket)
33+
34+
# set Channel 1's current to 100 mA and check for all events
35+
set_current = 0.1
36+
tcp_socket.send_scpi_command(f'SOUR1:CURR {get_precise_current_command_argument(set_current)}')
37+
log_all_events(tcp_socket)
38+
39+
# set Channel 1's compensation settings to their default values and check for all events
40+
# For higher power loads or shorter pulses, these settings may have to be adjusted to obtain ideal pulse shape
41+
tcp_socket.send_scpi_command('SOUR1:CURR? MAX')
42+
spikesafe_model_max_current = float(tcp_socket.read_data())
43+
44+
# load custom_compensation_table from /test_compensation_files/valid.json
45+
custom_compensation_table = load_custom_compensation_table(os.path.join(os.path.dirname(__file__), 'test_compensation_files', 'valid.json')
46+
device_types = load_custom_compensation_unique_device_types(custom_compensation_table)
47+
load_impedance, rise_time = get_custom_compensation(spikesafe_model_max_current, set_current, device_types[0], pulse_on_time)
48+
tcp_socket.send_scpi_command(f'SOUR1:PULS:CCOM {load_impedance}')
49+
log_all_events(tcp_socket)
50+
tcp_socket.send_scpi_command(f'SOUR1:PULS:RCOM {rise_time}')
51+
log_all_events(tcp_socket)
52+
```
53+
54+
### Examples In Action
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# [spikesafe-python API Overview](/spikesafe_python_lib_docs/README.md) | [Compensation](/spikesafe_python_lib_docs/Compensation/README.md) | load_custom_compensation_unique_device_types(custom_compensation_table)
2+
3+
## load_custom_compensation_unique_device_types(custom_compensation_table)
4+
5+
### Definition
6+
Returns the unique device types from a custom compensation table.
7+
8+
### Parameters
9+
custom_compensation_table [list([])](https://docs.python.org/3/library/stdtypes.html#list)
10+
Custom compensation table to be used for compensation. This should be the result of calling the [load_custom_compensation_table(file_path)](/spikesafe_python_lib_docs/Compensation/load_custom_compensation_table/README.md) function conforming to the [custom_compensation_table_schema](/spikesafe_python_lib_docs/Compensation/custom_compensation_table_schema/README.md)
11+
12+
### Returns
13+
[list([])](https://docs.python.org/3/library/stdtypes.html#list)
14+
List of unique device types in the custom compensation table
15+
16+
### Examples
17+
The following example demonstrates the `load_custom_compensation_unique_device_types()` function. It determines the custom compensation settings to use based off the SpikeSafe's set current setting, maximum settable current, and pulse on time.
18+
```
19+
# set Channel 1's Pulse On Time to 1ms and check for all events
20+
pulse_on_time = 0.001
21+
tcp_socket.send_scpi_command(f'SOUR1:PULS:TON {get_precise_time_command_argument(pulse_on_time)}')
22+
log_all_events(tcp_socket)
23+
24+
# set Channel 1's current to 100 mA and check for all events
25+
set_current = 0.1
26+
tcp_socket.send_scpi_command(f'SOUR1:CURR {get_precise_current_command_argument(set_current)}')
27+
log_all_events(tcp_socket)
28+
29+
# set Channel 1's compensation settings to their default values and check for all events
30+
# For higher power loads or shorter pulses, these settings may have to be adjusted to obtain ideal pulse shape
31+
tcp_socket.send_scpi_command('SOUR1:CURR? MAX')
32+
spikesafe_model_max_current = float(tcp_socket.read_data())
33+
34+
# load custom_compensation_table from /test_compensation_files/valid.json
35+
custom_compensation_table = load_custom_compensation_table(os.path.join(os.path.dirname(__file__), 'test_compensation_files', 'valid.json')
36+
device_types = load_custom_compensation_unique_device_types(custom_compensation_table)
37+
load_impedance, rise_time = get_custom_compensation(spikesafe_model_max_current, set_current, device_types[0], pulse_on_time)
38+
tcp_socket.send_scpi_command(f'SOUR1:PULS:CCOM {load_impedance}')
39+
log_all_events(tcp_socket)
40+
tcp_socket.send_scpi_command(f'SOUR1:PULS:RCOM {rise_time}')
41+
log_all_events(tcp_socket)
42+
```
43+
44+
### Examples In Action

spikesafe_python_lib_docs/DigitizerData/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ A class used to store data in a simple accessible object from a digitizer fetch
99
| Name | Description |
1010
| - | - |
1111
| [sample_number](/spikesafe_python_lib_docs/DigitizerData/sample_number/README.md) | Sample number of the voltage reading. |
12+
| [time_since_start_seconds](/spikesafe_python_lib_docs/DigitizerData/time_since_start_seconds/README.md) | Time since the start of the sampling in seconds. |
1213
| [voltage_reading](/spikesafe_python_lib_docs/DigitizerData/voltage_reading/README.md) | Digitizer voltage reading. |

0 commit comments

Comments
 (0)