Skip to content

Commit 038c769

Browse files
authored
Merge pull request #60 from VektrexElectronicSystems:development
v1.10.0
2 parents 3491f0e + 79c5a8b commit 038c769

File tree

75 files changed

+1159
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1159
-339
lines changed

README.md

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,41 @@ Use these code samples to start learning how to communicate with your SpikeSafe
1616
## Usage
1717

1818
### Python
19-
Download and install [Python](https://www.python.org/downloads/), which will install:
19+
Download from the official [Python](https://www.python.org/downloads/) website.
20+
21+
During Python installation check the box Add Python to PATH when prompted.
22+
- Confirm Python PATH is set in **Command Prompt** by typing `py --version` to verify the Python version
23+
24+
Installing Python will install:
2025
- IDLE
2126
- Python Launcher
2227
- Python3 Interpreter
2328

24-
It is recommended to use a version of Python with the status key of bugfix or higher, see [Python Release Cycle](https://devguide.python.org/versions/#versions).
29+
After Python installation is complete, restart the computer to ensure packages under the [Packages](#packages) Section can be successfully installed.
30+
31+
Vektrex targets working support for versions of Python with the status key of bugfix or higher, see [Python Release Cycle](https://devguide.python.org/versions/#versions).
2532

2633
#### Windows Setup
2734

2835
##### Use the Standard Console Command Prompt
2936
To open Command Prompt press the key combination Windows + R to open a Run dialog, and then type cmd and hit Enter or click Ok.
3037

3138
##### Add Python to PATH
32-
It is recommended that the path of Python Interpreter is added for easy usage. There are two ways to add Python to Windows PATH.
33-
34-
1. During Python installation check the box Add Python to PATH when prompted.
35-
- Confirm Python PATH is set in **Command Prompt** by typing `py --version` to verify the Python version
36-
37-
2. Manually add Python to Windows Path:
38-
- Press the key combination **Windows + R** to open a Run dialog
39-
- Type `sysdm.cpl` to open the System Properties
40-
- Press **Advanced** tab and then press on **Environment Variables…** to open Environment Variables dialog
41-
- Under the **User variables** box, press on **New…** to add the `Path` variable (if your **Path** variable already exists, then press on **Edit…** instead):
42-
- Set the Path **Variable value** to the 1) `Python application path` and 2) `Python Scripts path`. To find these paths and set the value:
43-
- Type `Python` in the Windows Search Bar
44-
- Right-click on the **Python App**, and then press **Open file location**
45-
- Right-click on the **Python shortcut**, and then press **Open file location** (this is the `Python application path`)
46-
- Navigate to the **scripts** folder (this is the `Python Scripts path`)
47-
- Set the Path **Variable value** to `Python application path;Python Scripts path` (paths are separated by a semicolon)
48-
- Press **OK**
49-
- Confirm Python PATH is set in **Command Prompt** by typing `py --version` to verify the Python version
39+
It is recommended that the path of Python Interpreter is added for easy usage. If this was not done in as part of the [Python](#python) section, it can be manually done afterwards.
40+
41+
Manually add Python to Windows Path:
42+
- Press the key combination **Windows + R** to open a Run dialog
43+
- Type `sysdm.cpl` to open the System Properties
44+
- Press **Advanced** tab and then press on **Environment Variables…** to open Environment Variables dialog
45+
- Under the **User variables** box, press on **New…** to add the `Path` variable (if your **Path** variable already exists, then press on **Edit…** instead):
46+
- Set the Path **Variable value** to the 1) `Python application path` and 2) `Python Scripts path`. To find these paths and set the value:
47+
- Type `Python` in the Windows Search Bar
48+
- Right-click on the **Python App**, and then press **Open file location**
49+
- Right-click on the **Python shortcut**, and then press **Open file location** (this is the `Python application path`)
50+
- Navigate to the **scripts** folder (this is the `Python Scripts path`)
51+
- Set the Path **Variable value** to `Python application path;Python Scripts path` (paths are separated by a semicolon)
52+
- Press **OK**
53+
- Confirm Python PATH is set in **Command Prompt** by typing `py --version` to verify the Python version
5054

5155
#### Mac OS X Setup
5256

@@ -78,43 +82,43 @@ To run these sequences a light-weight IDE, or to target cross-platform developme
7882
To run these sequences in a more feature rich IDE, use the free [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/). See [Python In Visual Studio](https://docs.microsoft.com/en-us/visualstudio/python/tutorial-working-with-python-in-visual-studio-step-00-installation?view=vs-2022) to simply setup your IDE with Python. Optionall, using a [virtual environment](https://docs.microsoft.com/en-us/visualstudio/python/managing-python-environments-in-visual-studio?view=vs-2022) is recommended to successfully meet the installation requirements to run these sequences.
7983

8084
### Packages
85+
SpikeSafePythonSamples requires packages to run all scripts.
8186

82-
#### Managing Packages
83-
##### How to Install/Upgraded Packages
84-
Installing packages use pip. It is recommended that pip be updated to latest version.
87+
There are two ways to install these packages:
88+
1. See Section [Automatically Install Packages](#automatically-install-packages)
89+
2. See Section [Manually Install Packages](#manually-install-packages)
8590

86-
To install/upgrade pip, run command:
87-
| OS | Command |
88-
| - | - |
89-
| Windows | `py -m pip install --upgrade pip` |
90-
| macOS | `python3 -m pip install --upgrade pip` |
91+
After all packages are installed, refer to section [Package Helpers](#package-helpers) to verify package details.
9192

92-
To display the version of pip, run command:
93-
| OS | Command |
94-
| - | - |
95-
| Windows | `pip -V` |
96-
| macOS | `pip3 -V` |
93+
#### Automatically Install Packages
94+
All necessary SpikeSafePythonSamples packages may be installed automatically. See [Install SpikeSafePythonSamples Packages](/getting_started/install_spikesafe_python_samples_packages/) and run the python .py script in this directory.
9795

98-
##### How to View All Installed Packages
99-
A list of all installed packages can be displayed.
96+
#### Manually Install Packages
97+
All necessary SpikeSafePythonSamples packages may be installed manually. Perform all of the subsections below.
10098

101-
To view all installed packages, run command:
99+
##### Installing pip Package
100+
Installing packages use [pip](https://pypi.org/project/pip/). It is recommended that pip be updated to latest version.
101+
102+
First, check if your environment has pip installed, run command:
102103
| OS | Command |
103104
| - | - |
104-
| Windows | `pip freeze` |
105-
| macOS | `pip3 freeze` |
105+
| Windows | `py -m pip --version` |
106+
| macOS | `python3 -m pip --version` |
106107

107-
##### How to View Details of an Installed Package
108-
After a package is installed the details of a package can be displayed.
108+
If your environment does not have pip installed, run command:
109+
| OS | Command |
110+
| - | - |
111+
| Windows | `py -m ensurepip --upgrade` |
112+
| macOS | `python3 -m ensurepip --upgrade` |
109113

110-
To view details of a package, run command:
114+
To install/upgrade pip, run command:
111115
| OS | Command |
112116
| - | - |
113-
| Windows | `pip show <package name>` |
114-
| macOS | `pip3 show <package name>` |
117+
| Windows | `py -m pip install --upgrade pip` |
118+
| macOS | `python3 -m pip install --upgrade pip` |
115119

116120
##### Installing spikesafe-python Package
117-
The [spikesafe-python](https://pypi.org/project/spikesafe-python/) library will need to be installed. Vektrex recommends always having the latest version of spikesafe-python when running these sequences; the current version is 1.4.5.
121+
The [spikesafe-python](https://pypi.org/project/spikesafe-python/) library will need to be installed. Vektrex recommends always having the latest version of spikesafe-python when running these sequences; the current version is 1.5.15.
118122

119123
To install this package, run command:
120124
| OS | Command |
@@ -126,7 +130,7 @@ Once the spikesafe-python package is installed, each script in this repository c
126130

127131
Complete class documentation is available for spikesafe-python in [spikesafe-python API Overview](spikesafe_python_lib_docs).
128132

129-
#### Installing matplotlib Package
133+
##### Installing matplotlib Package
130134
Some sequences involve graphing measurement results. To properly graph results, the [matplotlib](https://matplotlib.org/) library is required (version 3.2.1 or greater). Once the matplotlib library is installed, each sequence that involves graphing can be run as a standalone Python file.
131135

132136
To install this package, run command:
@@ -135,7 +139,7 @@ To install this package, run command:
135139
| Windows | `py -m pip install matplotlib` |
136140
| macOS | `python3 -m pip install matplotlib` |
137141

138-
#### Installing PyCLibrary Package
142+
##### Installing PyCLibrary Package
139143
Some sequences require external C resources, and requires the [PyCLibrary](https://pyclibrary.readthedocs.io/en/latest/) library. Once the PyCLibrary library is installed, each sequence that involves external C resources can be run as a standalone Python file.
140144

141145
To install this package, run command:
@@ -144,7 +148,7 @@ To install this package, run command:
144148
| Windows | `py -m pip install pyclibrary` |
145149
| macOS | `python3 -m pip install pyclibrary` |
146150

147-
#### Installing pyserial Package
151+
##### Installing pyserial Package
148152
Some sequences involve connecting to a serial interface instrument and requires the [pyserial](https://pypi.org/project/pyserial/) library (version 3.5 or greater). Once the pyserial library is installed, each sequence that involves a serial interface can be run as a standalone Python file.
149153

150154
To install this package, run command:
@@ -153,6 +157,26 @@ To install this package, run command:
153157
| Windows | `py -m pip install pyserial` |
154158
| macOS | `python3 -m pip install pyserial` |
155159

160+
#### Package Helpers
161+
162+
##### How to View All Installed Packages
163+
A list of all installed packages can be displayed.
164+
165+
To view all installed packages, run command:
166+
| OS | Command |
167+
| - | - |
168+
| Windows | `pip freeze` |
169+
| macOS | `pip3 freeze` |
170+
171+
##### How to View Details of an Installed Package
172+
After a package is installed the details of a package can be displayed.
173+
174+
To view details of a package, run command:
175+
| OS | Command |
176+
| - | - |
177+
| Windows | `pip show <package name>` |
178+
| macOS | `pip3 show <package name>` |
179+
156180
### General Usage
157181
For most examples, you may need to modify the specified IP address within a sequence to match the IP address that is physically set on your SpikeSafe's DIP switch. In each sequence, the default IP address of 10.0.0.220 is set in the line `ip_address = '10.0.0.220'`.
158182

application_specific_examples/controlling_thermal_platform_temperature/ControllingThermalPlatformTemperature.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
try:
3131
log.info("ControllingThermalPlatformTemperature.py started.")
3232

33+
log.info("Python version: {}".format(sys.version))
34+
3335
TEC_controller = SerialInterfaceDll()
3436

3537
# Set the beep enable sound

application_specific_examples/fixed_pulse_count_using_software_timing/FixedPulseCountUsingSoftwareTimingExample.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import sys
55
import time
66
import logging
7+
from spikesafe_python.Compensation import get_optimum_compensation
8+
from spikesafe_python.Precision import get_precise_compliance_voltage_command_argument
9+
from spikesafe_python.Precision import get_precise_current_command_argument
10+
from spikesafe_python.Precision import get_precise_time_command_argument
711
from spikesafe_python.ReadAllEvents import log_all_events
812
from spikesafe_python.ReadAllEvents import read_until_event
913
from spikesafe_python.SpikeSafeEvents import SpikeSafeEvents
@@ -31,6 +35,8 @@
3135
### start of main program
3236
try:
3337
log.info("FixedPulseCountUsingSoftwareTimingExample.py started.")
38+
39+
log.info("Python version: {}".format(sys.version))
3440

3541
# instantiate new TcpSocket to connect to SpikeSafe
3642
tcp_socket = TcpSocket()
@@ -54,35 +60,38 @@
5460
log_all_events(tcp_socket)
5561

5662
# set Channel 1's Pulse On Time to 1us and check for all events
57-
tcp_socket.send_scpi_command('SOUR1:PULS:TON 0.000001')
63+
pulse_on_time = 0.000001
64+
tcp_socket.send_scpi_command(f'SOUR1:PULS:TON {get_precise_time_command_argument(pulse_on_time)}')
5865
log_all_events(tcp_socket)
5966

6067
# set Channel 1's Pulse Off Time 9us and check for all events
61-
tcp_socket.send_scpi_command('SOUR1:PULS:TOFF 0.000009')
68+
tcp_socket.send_scpi_command(f'SOUR1:PULS:TOFF {get_precise_time_command_argument(0.000009)}')
6269
log_all_events(tcp_socket)
6370

6471
# set Channel 1's Pulse Width adjustment to disabled and check for all events
6572
tcp_socket.send_scpi_command('SOUR1:PULS:AADJ 0')
6673
log_all_events(tcp_socket)
6774

6875
# set Channel 1's current to 100mA and check for all events
69-
tcp_socket.send_scpi_command('SOUR1:CURR 0.1')
76+
set_current = 0.1
77+
tcp_socket.send_scpi_command(f'SOUR1:CURR {get_precise_current_command_argument(set_current)}')
7078
log_all_events(tcp_socket)
7179

7280
# set Channel 1's voltage to 20V and check for all events
73-
tcp_socket.send_scpi_command('SOUR1:VOLT 20')
81+
tcp_socket.send_scpi_command(f'SOUR1:VOLT {get_precise_compliance_voltage_command_argument(20)}')
7482
log_all_events(tcp_socket)
7583

7684
# set Channel 1's Auto Range to On and check for all events
7785
tcp_socket.send_scpi_command('SOUR1:CURR:RANG:AUTO 1')
7886
log_all_events(tcp_socket)
7987

80-
# set Channel 1's Load Impedance to High and check for all events
81-
tcp_socket.send_scpi_command('SOUR1:PULS:CCOM 1')
88+
# set Channel 1's Load Impedance and Rise Time, and check for all events
89+
tcp_socket.send_scpi_command('SOUR1:CURR? MAX')
90+
spikesafe_model_max_current = float(tcp_socket.read_data())
91+
load_impedance, rise_time = get_optimum_compensation(spikesafe_model_max_current, set_current, pulse_on_time)
92+
tcp_socket.send_scpi_command(f'SOUR1:PULS:CCOM {load_impedance}')
8293
log_all_events(tcp_socket)
83-
84-
# set Channel 1's Rise Time to Fast and check for all events
85-
tcp_socket.send_scpi_command('SOUR1:PULS:RCOM 1')
94+
tcp_socket.send_scpi_command(f'SOUR1:PULS:RCOM {rise_time}')
8695
log_all_events(tcp_socket)
8796

8897
# set Channel 1's Ramp mode to Fast and check for all events

application_specific_examples/making_tj_measurements/TjMeasurement.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
import statistics
1515
from spikesafe_python.DigitizerDataFetch import wait_for_new_voltage_data
1616
from spikesafe_python.DigitizerDataFetch import fetch_voltage_data
17+
from spikesafe_python.Discharge import get_spikesafe_channel_discharge_time
1718
from spikesafe_python.MemoryTableReadData import log_memory_table_read
19+
from spikesafe_python.Precision import get_precise_compliance_voltage_command_argument
20+
from spikesafe_python.Precision import get_precise_current_command_argument
21+
from spikesafe_python.Precision import get_precise_time_command_argument
22+
from spikesafe_python.Precision import get_precise_time_microseconds_command_argument
1823
from spikesafe_python.ReadAllEvents import log_all_events
1924
from spikesafe_python.ReadAllEvents import read_until_event
2025
from spikesafe_python.SpikeSafeEvents import SpikeSafeEvents
@@ -86,23 +91,23 @@ def calculate_Vf0(start_point, end_point, digitizer_data_list):
8691
### start of main program
8792
try:
8893
log.info("TjMeasurement.py started.")
94+
95+
log.info("Python version: {}".format(sys.version))
8996

9097
# instantiate new TcpSocket to connect to SpikeSafe
9198
tcp_socket = TcpSocket()
9299
tcp_socket.open_socket(ip_address, port_number)
93100

94-
# reset to default state and check for all events,
101+
# reset to default state and check for all events, this will automatically abort digitizer in order get it into a known state. This is good practice when connecting to a SpikeSafe PSMU
95102
# it is best practice to check for errors after sending each command
96103
tcp_socket.send_scpi_command('*RST')
97104
log_all_events(tcp_socket)
98-
99-
# abort digitizer in order get it into a known state. This is good practice when connecting to a SpikeSafe PSMU
100-
tcp_socket.send_scpi_command('VOLT:ABOR')
101-
105+
102106
# set up Channel 1 for Bias Current output to determine the K-factor
103107
tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP BIAS')
104-
tcp_socket.send_scpi_command('SOUR0:CURR:BIAS 0.033')
105-
tcp_socket.send_scpi_command('SOUR1:VOLT 40')
108+
tcp_socket.send_scpi_command(f'SOUR0:CURR:BIAS {get_precise_current_command_argument(0.033)}')
109+
compliance_voltage = 40
110+
tcp_socket.send_scpi_command(f'SOUR1:VOLT {get_precise_compliance_voltage_command_argument(compliance_voltage)}')
106111
tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
107112
tcp_socket.send_scpi_command('OUTP1:RAMP FAST')
108113

@@ -135,27 +140,33 @@ def calculate_Vf0(start_point, end_point, digitizer_data_list):
135140

136141
# turn off Channel 1
137142
tcp_socket.send_scpi_command('OUTP1 0')
143+
wait_time = get_spikesafe_channel_discharge_time(compliance_voltage)
144+
wait(wait_time)
138145

139146
log_and_print_to_console('\nK-factor values obtained. Stopped bias current output. Configuring to perform Electrical Test Method measurement.')
140147

141148
# set up Channel 1 for CDBC output to make the junction temperature measurement
142149
tcp_socket.send_scpi_command('SOUR1:FUNC:SHAP BIASPULSEDDYNAMIC')
143-
tcp_socket.send_scpi_command('SOUR1:CURR 3.5')
144-
tcp_socket.send_scpi_command('SOUR0:CURR:BIAS 0.033')
145-
tcp_socket.send_scpi_command('SOUR1:VOLT 40')
146-
tcp_socket.send_scpi_command('SOUR1:PULS:TON 1')
147-
tcp_socket.send_scpi_command('SOUR1:PULS:TOFF 0.001')
150+
tcp_socket.send_scpi_command(f'SOUR1:CURR {get_precise_current_command_argument(3.5)}')
151+
tcp_socket.send_scpi_command(f'SOUR0:CURR:BIAS {get_precise_current_command_argument(0.033)}')
152+
tcp_socket.send_scpi_command(f'SOUR1:VOLT {get_precise_compliance_voltage_command_argument(40)}')
153+
tcp_socket.send_scpi_command(f'SOUR1:PULS:TON {get_precise_time_command_argument(1)}')
154+
tcp_socket.send_scpi_command(f'SOUR1:PULS:TOFF {get_precise_time_command_argument(0.001)}')
148155
tcp_socket.send_scpi_command('SOUR1:CURR:PROT 50')
149156
tcp_socket.send_scpi_command('OUTP1:RAMP FAST')
150157

151158
# set Digitizer settings to take a series of quick measurements during the Off Time of CDBC operation
152159
tcp_socket.send_scpi_command('VOLT:RANG 100')
153-
tcp_socket.send_scpi_command('VOLT:APER 2')
154-
tcp_socket.send_scpi_command('VOLT:TRIG:DEL 0')
160+
aperture = 2
161+
tcp_socket.send_scpi_command(f'VOLT:APER {get_precise_time_microseconds_command_argument(aperture)}')
162+
hardware_trigger_delay = 0
163+
tcp_socket.send_scpi_command(f'VOLT:TRIG:DEL {get_precise_time_microseconds_command_argument(hardware_trigger_delay)}')
155164
tcp_socket.send_scpi_command('VOLT:TRIG:SOUR HARDWARE')
156165
tcp_socket.send_scpi_command('VOLT:TRIG:EDGE FALLING')
157-
tcp_socket.send_scpi_command('VOLT:TRIG:COUN 1')
158-
tcp_socket.send_scpi_command('VOLT:READ:COUN 500')
166+
hardware_trigger_count = 1
167+
tcp_socket.send_scpi_command(f'VOLT:TRIG:COUN {hardware_trigger_count}')
168+
reading_count = 500
169+
tcp_socket.send_scpi_command(f'VOLT:READ:COUN {reading_count}')
159170

160171
# check all SpikeSafe event since all settings have been sent
161172
log_all_events(tcp_socket)
@@ -172,7 +183,7 @@ def calculate_Vf0(start_point, end_point, digitizer_data_list):
172183
# initialize the digitizer. Measurements will be taken once a current pulse is outputted
173184
tcp_socket.send_scpi_command('VOLT:INIT')
174185

175-
# wait for the Digitizer measurements to complete
186+
# wait for the Digitizer measurements to complete
176187
wait_for_new_voltage_data(tcp_socket, 0.5)
177188

178189
# fetch the Digitizer voltage readings using VOLT:FETC? query

0 commit comments

Comments
 (0)