Use these code samples to start learning how to communicate with your SpikeSafe via TCP/IP using Python. Sequences can be run with the following Vektrex products:
- Getting Started - These sequences are primarily intended for first-time users of Vektrex products. They contain steps to perform the basic tasks that are necessary to run the sequences within the run_spikesafe_operating_modes folder.
- Run SpikeSafe Operating Modes - These folders contain examples to run specific SpikeSafe modes designed to test LEDs, Lasers, and electrical equipment. Basic settings will be sent to the SpikeSafe, and then one or more channels will be enabled to demonstrate the operation of each mode.
- Making Integrated Voltage Measurements - These folders contain examples to measure voltage using the SpikeSafe PSMU's integrated voltage Digitizer. The SpikeSafe outputs current to an LED, Laser, or electrical equipment, and then voltage measurements are read and displayed onscreen.
- Using the Force Sense Selector Switch - These folders contain examples to operate the optional integrated switch within the SpikeSafe PSMU. The SpikeSafe outputs to an LED, Laser, or electrical equipment as in the previous examples, and the switch is used to either disconnect the SpikeSafe from the test circuit or to operate an auxiliary source to power the DUT.
- Application-Specific Examples - These folders consist of more advanced sequences to address specific test scenarios, as well as some demonstrations to fine-tune your SpikeSafe current output. These sequences explain how to make light measurements using a SpikeSafe and a spectrometer, how to make in-situ junction temperature measurements on LEDs, and how to take full advantage of all SpikeSafe features.
- spikesafe-python API Overview. These folders contain complete class documentation for the spikesafe-python package used to power all of the aforementioned example directories.
On this page, press Clone or download to download all files in this repository. We recommend saving this repository to your working directory with all other GitHub repositories.
If only a specific sequence or folder is needed, right-click the desired file/folder and select Save link as....
-
Install Python 3.10 to 3.13
- Download Python from python.org.
- During installation check Add Python to PATH.
-
Verify Python
- Open a terminal and run:
OS Command Windows py --version
macOS python3 --version
- Open a terminal and run:
-
Install pip
- Run:
OS Command Windows py -m pip install --upgrade pip
macOS python3 -m pip install --upgrade pip
- Run:
-
Install Dependencies
- Set terminal to the directory containing
requirements.txt
, run:cd <path to directory containing requirements.txt>
- Run:
OS Command Windows py -m pip install --force-reinstall -r requirements.txt
macOS python3 -m pip install --force-reinstall -r requirements.txt
- Set terminal to the directory containing
To run these sequences a light-weight IDE, or to target cross-platform development, use the free Visual Studio Code. See Getting Started with Python in VS Code to simply setup your IDE with Python. Optionally, using a virtual environment is recommended to successfully meet the installation requirements to run these sequences.
To run these sequences in a more feature rich IDE, use the free Visual Studio Community. See Python In Visual Studio to simply setup your IDE with Python. Optionally, using a virtual environment is recommended.
Start with TCP Socket Sample to learn how setup a simple socket to communicate with your SpikeSafe. Then check out the rest of the samples under Getting Started.
You will 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'
.
Each file can be modified to include additional settings and commands to fit individual needs. Complete class documentation is available in spikesafe-python API Overview.
Most examples will log messages to the SpikeSafePythonSamples.log file under your local SpikeSafePythonSamples\ directory. Please refer to this file to ensure your sequence is running correctly.
We use SemVer for versioning. For the versions available, see the tags on this repository.
I'm developing an application using NI-VISA, what is the recommended practice for handling termination characters?
See Termination Characters in NI-VISA
I'm developing an application using MATLAB, how do I get started?
See System Requirements for MATLAB Engine API for Python to ensure your system can support Python. Then see Call Python from MATLAB on how to access Python libraries in MATLAB.
Why does my script's performance vary between different operating systems and machines?
See Remarks describing resolution of system timers between operating systems.
How does Python handle locale?
The locale module is implemented on top of the _locale module, which in turn uses an ANSI C locale (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:
- Period (.) as the decimal point for numbers
- Simple ASCII character classification and sorting
- English-style date and time formats
If any further assistance is needed beyond the information provided within this repository, email support@vektrex.com.
Feature requests and bug reports can be submitted to the Vektrex website's support page. Select Other as the Product/System and enter SpikeSafePythonSamples GitHub Repository as the Subject.
SpikeSafePythonSamples is licensed under the MIT license, which allows for non-commercial and commercial use.