Skip to content

Repository files navigation

SpikeSafe Python Samples

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:

Additional turn-key software solutions for advanced scenarios, such as LM-92 UV Measurement and Reliability/Burn-in Test, may be purchased. For a complete list, visit Vektrex Software Applications.

Directory

  • 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.

Downloading Files

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....

Project Setup

Setup Steps

  1. Install Python 3.11 to 3.15

    • Download Python from python.org.
    • Python 3.15 is recommended for a new environment.
    • During installation check Add Python to PATH.
  2. Verify Python

    • Open a terminal and run:
      OS Command
      Windows py --version
      macOS python3 --version
  3. Install pip

    • Run:
      OS Command
      Windows py -m pip install --upgrade pip
      macOS python3 -m pip install --upgrade pip
  4. Install Dependencies

    • Set terminal to the directory containing requirements.txt, run:

      cd <path to directory containing requirements.txt>
    • Run:

      OS Command
      Windows py -3.15 -m pip install --upgrade -r requirements.txt
      macOS python3.15 -m pip install --upgrade -r requirements.txt
    • These commands select Python 3.15 explicitly. If using another supported version, substitute that interpreter and select the same environment in your IDE.

    • Instrument and spectrometer examples still require their vendor drivers and DLLs. Python package installation alone does not verify those drivers on 3.15.

IDEs

Visual Studio Code

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.

Visual Studio Community

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.

Where Do I Start?

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: str = '10.0.0.220'.

Each file can be modified to include additional settings and commands to fit individual needs. Complete class documentation for the spikesafe-python package 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.

Built With

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

FAQ

I'm developing an application using C/C++, how do I get started?
See Wrapping C/C++ for Python

I'm developing an application using LabView, how do I get started?
See Integrating Python Code in LabVIEW

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.

I'm developing an application using NI-VISA, what is the recommended practice for handling termination characters?
See Termination Characters in NI-VISA

Why does my script's performance vary between different operating systems and machines?
See Remarks describing resolution of system timers between operating systems.

Does the library depend on the system locale?

SCPI numeric formatting and response parsing are independent of the application's locale. Command arguments use a period (.) as the decimal separator and no digit grouping; responses are parsed with Python's locale-independent float() and int(). Supply numeric values rather than localized strings such as "1,25".

Custom compensation JSON files must be UTF-8 encoded, with JSON numbers using a period as the decimal separator. TCP and serial text use UTF-8 as well. The library does not change the application's process-wide locale.

Support/Feedback

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.

Contributors

License

SpikeSafePythonSamples is licensed under the MIT license, which allows for non-commercial and commercial use.