Automated control of Logic2 software from LabVIEW. Supports Logic 8, Logic Pro 8, and Logic Pro 16
Demonstrates how to use Python to automate the Saleae Logic2 software.
LabVIEW 2021 or newer Python 3.8, 3.9 or 3.10 with the same bitness as LabVIEW.
- Install LabVIEW, and setup an Anaconda 3 instance using Python 3.8 https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000015C6tSAE&l=en-US
- Install the Saleae Python library using the instructions found here: https://saleae.github.io/logic2-automation/getting_started.html#installing-the-python-automation-api-package
- Be sure Automation is enabled in the Logic2 Software (Saleae link above)
- Load [Python_Logic2_Automation.vi]. The key parameters in the main VI are the Anaconda setings and the Saleae Logic 'Device ID' (F4241 is the default simulated Logic Pro 16)
Reproduction of the [saleae_example.py] shipping example.
- Highest level example VI that contains the user interface and all of the supporting subVIs
- Inputs: ip_address, selected_port
- Establishes a connection to the Logic 2 application using a specified IP address and port number.
- Inputs: enable_digital_channels, digital_sample_rate, digital_threshold_volts
- Configures the capturing device with settings like enabled digital channels, sample rate, and logic level threshold.
- Inputs: capture_duration
- Sets up the capture configuration, specifically the duration of the capture.
- Inputs: device_id
- Initiates a capture session using the provided device and configuration settings.
- Inputs: label, mosi, miso, clock, enable, bits_per_transfer
- Adds an SPI (Serial Peripheral Interface) analyzer to the capture session with specified settings for channels and transfer bits.
- Inputs: file path, digital channels to export
- Exports the captured raw digital data to a CSV file.
- Inputs: output_dir
- Exports data from an analyzer (in this case, the SPI analyzer) to a CSV file.
- Inputs: capture_filepath
- Saves the entire capture session to a file.
- Inputs: None
- Closes the connection to the Logic 2 application.
- Inputs: File Path, File Name Prefix, File Exension
- Adds the time and date stamp to a file name to ensure a unique file is created
To control Logic2 running on another computer, the Logic2 software must be run with the following command line arguments:
Mac: do shell script "open -a '/Applications/Logic2.app' --args --automation --automationHost 0.0.0.0 --automationPort 10430"
PC: start "" "C:\Path\To\Logic2.exe" --automation --automationHost 0.0.0.0 --automationPort 10430
Linux: /path/to/Logic2 --automation --automationHost 0.0.0.0 --automationPort 10430
Note: The "path to Logic2" should be replaced with the path to and name of the Logic2 executable.
- Global Variable Usage
- In order to preserve the state between LabVIEW calls, several session variables are estrablished as global variables. This is generally bad programming practice and I have not had enough time to find another way to accomplish this using classes or some other method. Feedback and suggestions welcome!
- Configurations VIs and funcations are application specific.
- Currently the configuration VIs and supporting Python functions are very specific to the example use case. This can be expanded to be more generic and thus handling more use cases. For example the 'Device Configuration' only exposes the digital parameters and not the Analog settings. Each named control and selection value in the Logic2 Graphical User Interface can be remotely controlled from the Automation software, so there is lots of room for the LabVIEW based automation library to grow!