### Flojoy Block Example Documentation (example.md) Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/contribution/docs/01-blocks-section.md The `example.md` file provides a detailed breakdown and explanation of the associated `app.json` example. It should be updated to guide users through the example application's purpose and steps. ```Markdown # Example for MY_BLOCK This document explains the example application defined in `app.json` for `MY_BLOCK`. ## Purpose This example demonstrates how to integrate `MY_BLOCK` into a simple Flojoy workflow. ## Workflow Steps 1. **Input**: Data is prepared. 2. **Process**: `MY_BLOCK` performs its operation on the data. 3. **Output**: The result is displayed. ``` -------------------------------- ### Starlight Project Management CLI Commands Source: https://github.com/flojoy-ai/studio/blob/main/docs/README.md A comprehensive guide to command-line interface commands used for developing and managing an Astro + Starlight project, covering dependency installation, local development, site building, and previewing. ```APIDOC npm install - Action: Installs project dependencies. npm run dev - Action: Starts local development server at `localhost:4321`. npm run build - Action: Builds your production site to `./dist/` directory. npm run preview - Action: Previews your built site locally, before deploying. npm run astro ... - Action: Runs Astro CLI commands (e.g., `astro add`, `astro check`). npm run astro -- --help - Action: Displays help information for the Astro CLI. ``` -------------------------------- ### Flojoy Block Example Application (app.json) Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/contribution/docs/01-blocks-section.md An `app.json` file defines an example Flojoy application that uses the block. This file should be placed in the same directory as the block's Python code and updated to reflect the desired example workflow. ```JSON { "app_name": "MyBlockExample", "description": "An example demonstrating the use of MY_BLOCK.", "nodes": [ { "id": "start_node", "block_name": "MY_BLOCK", "inputs": {}, "outputs": ["output_data"] } ], "connections": [] } ``` -------------------------------- ### Initialize Starlight Project with npm Source: https://github.com/flojoy-ai/studio/blob/main/docs/README.md This command uses npm to create a new Astro project, pre-configured with the Starlight template, providing a quick start for building documentation sites. ```bash npm create astro@latest -- --template starlight ``` -------------------------------- ### Prologix GPIB-USB Adapter and VISA Instrument Communication Commands Source: https://github.com/flojoy-ai/studio/blob/main/blocks/HARDWARE/PROTOCOLS/GPIB/PROLOGIX/PROLOGIX_AUTO/example.md This section outlines the essential commands and parameters for configuring the Prologix GPIB-USB adapter and interacting with a VISA instrument. It covers initial setup commands, GPIB addressing, sending SCPI queries, and handling responses, including considerations for automatic response retrieval. The setup commands (AUTO, MODE, EOI) should be run before connecting the adapter to the instrument. ```APIDOC Prologix GPIB-USB Adapter Configuration and SCPI Commands: PROLOGIX AUTO: auto = off - Description: Controls automatic response retrieval after each command. - Parameters: - auto: 'off' to disable automatic response (recommended for some VISA instruments). - Note: Setting 'auto' to 'on' enables receiving a response upon every command, but may cause errors with certain VISA instruments. PROLOGIX MODE: mode = CONTROLLER - Description: Sets the Prologix adapter's operational mode. - Parameters: - mode: 'CONTROLLER' to configure the adapter as a GPIB controller. PROLOGIX EOI: EOI = true, EOS = None (instrument dependent) - Description: Configures the End-Or-Identify (EOI) signal and End-Of-String (EOS) character for GPIB communication. - Parameters: - EOI: 'true' to assert EOI with the last byte of data. - EOS: Optional, instrument-dependent end-of-string character. Set to 'None' if not required. GPIB Address Configuration: - Description: Specifies the GPIB address for the target VISA instrument. - Parameters: - address: The GPIB address of the instrument. This value must match the instrument's configured address (refer to the instrument's manual). OPEN SERIAL: writing "*IDN?" with bytes encoding and a LF terminator - Description: Initiates serial communication to send a SCPI command to the instrument. - Parameters: - command: The SCPI command string to send (e.g., "*IDN?"). - encoding: The byte encoding for the command string (e.g., 'bytes'). - terminator: The line terminator character to append to the command (e.g., 'LF' for Line Feed). - Usage: Typically used for sending identification queries or other SCPI commands. PROLOGIX READ: - Description: Command to explicitly retrieve a response from the instrument. - Usage: Essential for receiving data from the instrument when 'PROLOGIX AUTO' mode is disabled. This command should be used after sending a query that expects a response. ``` -------------------------------- ### Publishing Python Package to PyPI using Twine Source: https://github.com/flojoy-ai/studio/blob/main/pkgs/flojoy/README.md This section provides a step-by-step guide for publishing a Python package to PyPI using the `twine` utility. It covers installing `twine`, updating the package version in `setup.py`, creating a distribution file, and finally uploading the package to PyPI, noting the requirement for authentication credentials. ```shell pip install twine python3 setup.py sdist twine upload dist/* ``` -------------------------------- ### Flojoy Data Generation - Sample Images Blocks Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/blocks/DATA/overview.mdx Documentation for Flojoy blocks that load example images from image processing libraries. ```APIDOC SKIMAGE: Load an example image from scikit-image, such as an astronaut, the moon, a horse, etc. ``` -------------------------------- ### Example Usage of FSL Class for Spectrum Analyzer Control Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Spectrum Analyzers/Rohdes And Schwarz/fsl.mdx Demonstrates how to initialize the `FSL` class with a VISA adapter, connect to a Rohde&Schwarz FSL spectrum analyzer, and perform basic operations like setting center frequency, attenuation, and reading trace data. Note: Some methods used in this example (e.g., `freq_center`, `attenuation`, `read_trace`) are not explicitly defined in the provided `FSL` class snippet but are assumed to be available through the Pymeasure `Instrument` base class or other extensions. ```python from pymeasure.adapters import VISAAdapter adapter = VISAAdapter("TCPIP::192.168.1.1::INSTR") # Replace with the actual IP address of your spectrum analyzer fsl = FSL(adapter) # Now you can use the methods and properties of the FSL class to control the spectrum analyzer fsl.freq_center = "1 GHz" # Set the center frequency to 1 GHz fsl.attenuation = 10 # Set the attenuation to 10 dB trace_data = fsl.read_trace() # Read the trace data from the spectrum analyzer print(trace_data) ``` -------------------------------- ### Connect to the Qdac 2 Power Supply Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Power Supplies/Qdevil/qdac-2-array.mdx Instantiates the `QDac2` class with a given name and TCP/IP address, then establishes a connection to the physical instrument. The provided IP address is an example and should be replaced with the actual device IP. ```python qdac = QDac2("qdac", "TCPIP::192.168.1.1::INSTR") qdac.connect() ``` -------------------------------- ### Connect to Teledyne HDO4000A Oscilloscope with InstrumentKit Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Oscilloscopes/Teledyne/hdo4000a.mdx This code demonstrates how to connect to a Teledyne HDO4000A Oscilloscope using the InstrumentKit Python library. It establishes a VISA connection to the oscilloscope via its IP address, performs a basic operation (starting the trigger and printing its state), and then closes the connection. Users should replace the example IP address with their oscilloscope's actual IP. This snippet assumes InstrumentKit and a compatible VISA backend are already installed. ```python import instrumentkit as ik # Connect to the oscilloscope oscilloscope = ik.teledyne.MAUI.open_visa("TCPIP0::192.168.0.10::INSTR") # Perform operations on the oscilloscope oscilloscope.run() print(oscilloscope.trigger_state) # Close the connection oscilloscope.close() ``` -------------------------------- ### Sync Flojoy Block Documentation Changes Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/contribution/docs/01-blocks-section.md This command regenerates the documentation for Flojoy Blocks after modifications to their components (docstrings, Python code, example markdown files). It can be executed using `poetry` or `just`. ```Shell poetry run python3 fjblock.py sync ``` ```Shell just sync ``` -------------------------------- ### Starlight Project Directory Structure Source: https://github.com/flojoy-ai/studio/blob/main/docs/README.md Illustrates the standard file and folder layout for an Astro + Starlight project, detailing the purpose of key directories like `public/`, `src/`, and configuration files such as `astro.config.mjs`. ```plaintext .\n├── public/\n├── src/\n│ ├── assets/\n│ ├── content/\n│ │ ├── docs/\n│ │ └── config.ts\n│ └── env.d.ts\n├── astro.config.mjs\n├── package.json\n└── tsconfig.json ``` -------------------------------- ### TypeScript: Example of `any` usage for function signature retention Source: https://github.com/flojoy-ai/studio/blob/main/style-guide.md This snippet illustrates a rare, specific scenario where `any` can be used in TypeScript: to wrap a function while preserving its original signature. It demonstrates how to correctly infer and pass parameters using `Parameters`. ```typescript function void>( innerFn: S, ): ((...args: Parameters) => void) { const fn = function (...args: Parameters) { // do something }; return fn; }, ``` -------------------------------- ### Connect to Singlequantum Photon Counting System using QCodes Community in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Photon Counting Systems/Singlequantum/singlequantum.mdx This script demonstrates how to establish a connection to a Singlequantum Photon Counting System using the `WebSQControlqcode` class from the QCodes Community. It shows how to create a `Station` object, add the instrument, configure parameters such as bias current, enable detectors, set measurement period, acquire counts, and properly close the connection. This example facilitates basic interaction and data acquisition from the device. ```python from qcodes import Station from qcodes.instrument_drivers.singlequantum.WebSQControlqcode import WebSQControlqcode # Create a station to hold the instrument station = Station() # Connect to the Singlequantum Photon Counting System instrument = WebSQControlqcode('singlequantum', address='localhost', port=12000) station.add_component(instrument) # Set the bias current to 10 uA instrument.bias_current(10) # Enable the detectors instrument.detectors(True) # Set the measurement period to 100 ms instrument.measurement_periode(100) # Acquire 5 points instrument.npts(5) counts = instrument.counters() # Print the acquired counts print(counts) # Disconnect from the instrument instrument.close() ``` -------------------------------- ### TypeScript: Demonstrating unsafe `as` type assertion Source: https://github.com/flojoy-ai/studio/blob/main/style-guide.md This example highlights the dangers of using `as` for type assertion in TypeScript. It shows how `as` can subvert the type system, leading to runtime errors where a property appears defined at compile-time but is actually undefined at runtime. ```typescript type Foo = { bar: string; baz: number; }; const a = { bar: "asdf" }; const b = a as Foo; // Somewhere later b.baz; // LSP says it's defined, but it actually isn't when you try to use it ``` -------------------------------- ### Access and Control Qdac 2 Channels Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Digital Analog Converters/Qdevil/qdac-2-array.mdx This example shows how to access a specific channel of the connected Qdac 2 instrument. It demonstrates setting a voltage value using `set()` and retrieving the current voltage using `get()`, then printing the result. ```python channel1 = qdac.channels[0] channel1.set(1.0) voltage = channel1.get() print(voltage) ``` -------------------------------- ### razorbillRP100 Instrument Properties and Initialization Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Power Supplies/Razorbill/razorbill-rp100.mdx This section provides a detailed overview of the measurement properties available on the `razorbillRP100` instrument and describes its constructor (`__init__` method). It outlines how to retrieve instantaneous and contact voltage/current readings for different channels and the parameters required for instrument setup. ```APIDOC razorbillRP100 Class: Properties: instant_voltage_2: float - Description: Instantaneous voltage reading for source two. contact_voltage_1: float (Volts) - Description: Measurement property returning the voltage present at the front panel output of channel 1. contact_voltage_2: float (Volts) - Description: Measurement property returning the voltage present at the front panel output of channel 2. contact_current_1: float (Amps) - Description: Measurement property returning the current present at the front panel output of channel 1. contact_current_2: float (Amps) - Description: Measurement property returning the current present at the front panel output of channel 2. Methods: __init__(adapter: object) - Description: Initializes the razorbillRP100 instrument with the provided adapter. - Parameters: - adapter: The instrument adapter object to use for communication. - Behavior: Sets a communication timeout of 20 seconds upon initialization. ``` -------------------------------- ### National Instruments CompactDAQ Commands Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/blocks/HARDWARE/overview.mdx Comprehensive API commands for configuring and interacting with National Instruments CompactDAQ devices, covering various analog input measurements, stream configuration, task management, and data reading operations. ```APIDOC ATTACH_ANALOG_INPUT_ACCELEROMETER - Description: Attach channel(s) to a task to measure acceleration using an accelerometer. ATTACH_ANALOG_INPUT_CURRENT - Description: Attach channel(s) to a task to measure current. ATTACH_ANALOG_INPUT_STRAIN_GAGE - Description: Attach channel(s) to a task measure strain. ATTACH_ANALOG_INPUT_THERMOCOUPLE - Description: Attach channel(s) to a task to measure temperature using a thermocouple. ATTACH_ANALOG_INPUT_VOLTAGE - Description: Attach channel(s) to a task to measure voltage. CONFIG_INPUT_STREAM - Description: Configure the properties of an input stream. CONFIG_TASK_SAMPLE_CLOCK_TIMING - Description: Configures the timing for the sample clock of a task. CREATE_TASK - Description: Creates a task READ_INPUT_STREAM - Description: Reads raw samples from the specified task or virtual channels. READ_INPUT_STREAM_INTO_BUFFER - Description: Reads raw samples from the specified task or virtual channels into the provided buffer. READ_TASK - Description: Reads one or more current samples from a National Instruments compactDAQ device. TASK_WAIT_UNTIL_DONE - Description: Waits for the measurement or generation to complete. ``` -------------------------------- ### Connect to Keithley 2000 Multimeter using PyMeasure in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Multimeters/Keithley/keithley-2000.mdx This Python script demonstrates how to establish a connection with a Keithley 2000 Multimeter using the PyMeasure library and a VISA adapter. It shows how to perform basic measurements for voltage, current, and resistance, and then properly disconnect from the instrument. This example is suitable for initial instrument setup and data acquisition. ```python from pymeasure.adapters import VISAAdapter from pymeasure.instruments.keithley import Keithley2000 # Create a VISA adapter for the instrument adapter = VISAAdapter("GPIB::1") # Connect to the Keithley 2000 Multimeter meter = Keithley2000(adapter) # Perform measurements or configure the instrument as needed meter.measure_voltage() print("Voltage:", meter.voltage) meter.measure_current() print("Current:", meter.current) meter.measure_resistance() print("Resistance:", meter.resistance) # Disconnect from the instrument meter.disconnect() ``` -------------------------------- ### Connect to Keysight N9000A Spectrum Analyzer using QCodes Community in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Spectrum Analyzers/Agilent/keysight-n9000a.mdx This Python script demonstrates how to connect to and control a Keysight N9000A Spectrum Analyzer using the QCodes Community library. It shows how to establish a connection, add the instrument to a station, read parameters like RF center frequency and power, and set parameters like video bandwidth. Remember to replace the placeholder IP address with your instrument's actual address. ```python from qcodes import Station, Instrument from qcodes.instrument_drivers.Keysight.Keysight_N9000A import Keysight_N9000A # Create a station to hold the instrument station = Station() # Connect to the Keysight N9000A Spectrum Analyzer n9000a = Keysight_N9000A('n9000a', 'TCPIP0::192.168.1.1::inst0::INSTR') station.add_component(n9000a) # Print the RF center frequency print(n9000a.rf_center_frequency()) # Set the video bandwidth to 10 MHz n9000a.video_bandwidth(10) # Print the power print(n9000a.power()) # Close the connection n9000a.close() ``` -------------------------------- ### Prologix GPIB-USB Adapter Configuration and SCPI Commands Source: https://github.com/flojoy-ai/studio/blob/main/blocks/HARDWARE/PROTOCOLS/GPIB/PROLOGIX/PROLOGIX_ADDR/example.md Details the commands and parameters used to configure the Prologix GPIB-USB adapter and interact with VISA instruments, including setup and data transfer operations. This covers setting adapter modes, EOI/EOS behavior, and sending/receiving SCPI commands. ```APIDOC Prologix GPIB-USB Adapter Commands: PROLOGIX AUTO [on|off] - Description: Controls the automatic response reception mode of the adapter. - Parameters: - on: Enables automatic response reception after every command. Note: Can cause errors with some VISA instruments. - off: Disables automatic response reception (used by this app's setup). PROLOGIX MODE [CONTROLLER|DEVICE] - Description: Sets the operating mode of the Prologix adapter. - Parameters: - CONTROLLER: Adapter acts as a GPIB controller (required for this app). - DEVICE: Adapter acts as a GPIB device. PROLOGIX EOI [true|false] [EOS ] - Description: Configures End-or-Identify (EOI) and End-of-String (EOS) behavior for data transfer. - Parameters: - true: EOI asserted with the last byte of data (required for this app). - false: EOI not asserted. - EOS : Specifies the End-of-String character (instrument dependent; None for this app). GPIB Address Configuration: - Description: Sets the GPIB address for communication with the instrument. - Parameters: - address: The GPIB address (must match the instrument's manual setting). OPEN SERIAL Command (Example: *IDN?): - Description: Sends a SCPI command over the serial connection to the instrument. - Parameters: - command: The SCPI command string (e.g., "*IDN?"). - encoding: Encoding for the command (e.g., bytes). - terminator: Line terminator (e.g., LF). PROLOGIX READ Command: - Description: Used to explicitly receive a response from the connected VISA instrument when AUTO mode is off. ``` -------------------------------- ### Connect to NI PXIe-2597 using QCodes Community in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Multiplexer Switch Modules/National Instruments/ni-pxie-2597.mdx This Python script demonstrates how to define a custom QCodes instrument class for the NI PXIe-2597 Multiplexer Switch Module. It includes methods for setting and getting the active channel, allowing connection and disconnection from specific channels. The example shows how to instantiate the instrument and set a channel. ```python from qcodes.instrument.base import Instrument from qcodes.utils.validators import Enum class NI_PXIe_2597(Instrument): def __init__(self, name, resource, **kwargs): super().__init__(name, **kwargs) self.add_parameter(name="channel", get_cmd=self._get_channel, set_cmd=self._set_channel, vals=Enum(*tuple(["ch1", "ch2", "ch3", "ch4", "ch5", "ch6", None])), post_delay=1, docstring='Name of the channel where the common "com" port is connected to', label=f"{self.short_name} active channel") def _set_channel(self, name_to_connect): if name_to_connect is None: print("Disconnecting from all channels") else: print(f"Connecting to channel {name_to_connect}") def _get_channel(): return "ch1" # Connect to the NI PXIe-2597 Multiplexer Switch Module switch = NI_PXIe_2597(name="switch", resource="PXI0::0::INSTR") # Set the active channel switch.channel("ch2") ``` -------------------------------- ### Prologix GPIB-USB Adapter Communication Protocol Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/studio/Hardware/prologix-gpib.md Outlines the specific rules and conventions for sending commands and reading responses from the Prologix GPIB-USB adapter. This includes details on command prefixes, line endings, GPIB address matching, and recommended Flojoy blocks for interaction, such as using PROLOGIX_READ for queries and the behavior of PROLOGIX_AUTO. ```APIDOC Prologix GPIB-USB Adapter Communication Rules: Command Prefix: - Any command without a "++" prefix will be sent directly to the connected instrument. SERIAL WRITE Commands: - Commands sent via SERIAL WRITE should be appended by LF (line-feed, AKA new line). GPIB Address Matching: - Ensure the GPIB addresses configured for the Prologix adapter and the instrument match. Reading Responses: - Use the PROLOGIX_READ block after sending a query (e.g., "*IDN?") instead of SERIAL_READ. Automatic Query Response (PROLOGIX_AUTO): - Setting PROLOGIX_AUTO expects a query response after every command. - Note: This can cause errors in some instruments. ``` -------------------------------- ### Connect to Lakeshore 370 AC Resistance Bridge using InstrumentKit in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Power Meters/Lakeshore/lakeshore-370.mdx This Python script demonstrates how to establish a connection to a Lakeshore 370 AC resistance bridge via GPIB-USB using the `instrumentkit` library. It then queries and prints the resistance value from the first channel. Users should ensure the `instrumentkit` package is installed and verify the correct device path and GPIB address for their setup. ```Python import instrumentkit as ik # Connect to the Lakeshore 370 AC resistance bridge bridge = ik.lakeshore.Lakeshore370.open_gpibusb('/dev/ttyUSB0', 1) # Query the resistance of the first channel resistance = bridge.channel[0].resistance # Print the resistance value print(resistance) ``` -------------------------------- ### QCodes Python Driver and Usage for Keysight J7211/A/B/C-Series Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Lockin Amplifiers/Keysight/keysight-j7211-a-b-c-series.mdx This snippet provides a Python class `Keysight_J7211` that acts as a QCodes driver for the Keysight J7211 Attenuation Control Unit. It handles instrument initialization, model-specific validation for attenuation ranges (0-120dB for A/B, 0-100dB for C), and parameter definition for attenuation control. It also includes examples for instrument instantiation, getting, and setting attenuation levels. ```Python from qcodes.instrument.visa import VisaInstrument from qcodes.utils.validators import Ints from typing import Optional class Keysight_J7211(VisaInstrument): r""" Qcodes driver for the Keysight J7211 Attenuation Control Unit. Tested with J7211B. Args: name: Instrument name address: Address or VISA alias of instrument attenuation: Optional attenuation level (in dB) to set on startup terminator: Termination character in VISA communication. """ def __init__(self, name: str, address: str, attenuation: Optional[int] = None, terminator="\r", **kwargs): super().__init__(name=name, address=address, terminator=terminator, **kwargs) model = self.IDN()['model'] if model in ["J7211A", "J7211B"]: vals = Ints(0, 120) elif model in ["J7211C"]: vals = Ints(0, 100) else: raise RuntimeError(f"Model {model} is not supported.") self.add_parameter('attenuation', unit='dB', set_cmd='ATT {:03.0f}', get_cmd='ATT?', get_parser=int, vals=vals, initial_value=attenuation) self.connect_message() ``` ```Python instrument = Keysight_J7211(name='my_instrument', address='GPIB0::1::INSTR', attenuation=50) ``` ```Python attenuation = instrument.attenuation() ``` ```Python instrument.attenuation(60) ``` -------------------------------- ### Connect to Keysight M960x Power Meter using QCodes in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Power Supplies/Keysight/keysight-m960x-defs.mdx This Python script demonstrates how to connect to a Keysight M960x power meter using the QCodes library. It initializes the instrument via TCP/IP, prints its identification, configures it to measure power, reads the measurement, and then closes the connection. It showcases basic instrument control and data acquisition. ```python import qcodes as qc from qcodes.instrument_drivers.Keysight.Keysight_M960x import Keysight_M960x # Connect to the power meter power_meter = Keysight_M960x("power_meter", "TCPIP0::192.168.1.1::inst0::INSTR") # Print the power meter identification print(power_meter.idn()) # Set the power meter to measure power power_meter.measurement_function("POWER") # Set the power meter range power_meter.range_auto(True) # Read the power measurement power = power_meter.power() # Print the power measurement print(f"Power: {power} dBm") # Close the connection to the power meter power_meter.close() ``` -------------------------------- ### Control Newport AG-UC8 with QCodes in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Motor Controllers/Newport/ag-uc-8.mdx This Python code snippet demonstrates how to initialize, connect to, and control the Newport AG-UC8 Agilis Controller using the `qcodes.instrument_drivers.newport.ag_uc8` driver. It includes examples for getting identification, resetting the controller, and moving specific axes (absolute and relative movements), as well as stopping movement and disconnecting. Users must replace `'ASRL3'` with their instrument's VISA address. ```python from qcodes.instrument_drivers.newport.ag_uc8 import Newport_AG_UC8 # Create an instance of the Newport_AG_UC8 driver controller = Newport_AG_UC8('controller', 'ASRL3') # Connect to the instrument controller.connect() # Get the identification information of the instrument idn = controller.get_idn() print(idn) # Reset the controller controller.reset() # Select channel 1 channel1 = controller.channels.channel_1 # Move the axis 1 of channel 1 to absolute position 500 channel1.axis1.move_abs(500) # Move the axis 2 of channel 1 to relative position -100 channel1.axis2.move_rel(-100) # Stop the movement of axis 1 of channel 1 channel1.axis1.stop() # Disconnect from the instrument controller.disconnect() ``` -------------------------------- ### Connect to Keysight Infiniium Oscilloscope using QCodes in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Oscilloscopes/Keysight/infiniium-oscilloscopes-series.mdx This Python script demonstrates how to establish a connection to a Keysight Infiniium oscilloscope using the QCodes library. It covers essential steps such as instrument initialization, reading device identification, configuring acquisition parameters (e.g., run mode, points, sample rate), performing a single acquisition, and retrieving waveform data from a specified channel. Replace the placeholder VISA address with your oscilloscope's actual address. ```python import qcodes as qc from qcodes.instrument_drivers.Keysight.KeysightInfiniium import KeysightInfiniium # Connect to the oscilloscope oscilloscope = KeysightInfiniium("oscilloscope", "TCPIP0::192.168.1.1::INSTR") # Print the IDN of the oscilloscope print(oscilloscope.IDN()) # Set up the oscilloscope parameters oscilloscope.run_mode("STOP") oscilloscope.acquire_points(1000) oscilloscope.sample_rate(1e9) # Take a single acquisition oscilloscope.single() # Read the waveform data from channel 1 channel1 = oscilloscope.channels[0] waveform_data = channel1.trace() # Print the waveform data print(waveform_data) # Disconnect from the oscilloscope oscilloscope.close() ``` -------------------------------- ### Connect to DS345 Function Generator using InstrumentKit in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Function Generators/Srs/ds345.mdx This Python script demonstrates how to establish a connection with a Stanford Research Systems DS345 Function Generator via GPIB using the InstrumentKit library. It shows examples of setting the output frequency, retrieving the offset voltage, and configuring the output waveform function (e.g., triangle). The script requires the InstrumentKit library and a GPIB connection setup. ```python import instrumentkit as ik import instrumentkit.devices.srs as srs import instrumentkit.units as u # Connect to the DS345 Function Generator srs345 = srs.SRS345.open_gpib('/dev/ttyUSB0', 1) # Set the output frequency to 1 MHz srs345.frequency = 1 * u.MHz # Get the offset voltage offset_voltage = srs345.offset # Set the output function to triangle srs345.function = srs345.Function.triangle ``` -------------------------------- ### Connect and Control NI PXIe-5654 RF Signal Generator with QCodes in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/RF Signal Generators/National Instruments/ni-pxie-5654.mdx This Python script demonstrates how to connect to, configure, and disconnect from a National Instruments PXIe-5654 RF Signal Generator using the `qcodes_contrib_drivers` library. It shows how to create an instrument instance, connect to it, set frequency and power level, and then disconnect. Ensure `qcodes_contrib_drivers` is installed and replace the resource name with your specific setup. ```python import qcodes as qc from qcodes_contrib_drivers.drivers.NationalInstruments.NI_PXIe_5654 import NI_PXIe_5654 # Create an instance of the instrument signal_generator = NI_PXIe_5654('signal_generator', 'PXI1Slot2') # Connect to the instrument signal_generator.connect() # Perform operations with the instrument frequency = 1e6 # Set the frequency to 1 MHz signal_generator.frequency(frequency) power_level = 0 # Set the power level to 0 dBm signal_generator.power_level(power_level) # Disconnect from the instrument signal_generator.disconnect() ``` -------------------------------- ### Prologix USB-to-GPIB Adapter API Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/blocks/HARDWARE/overview.mdx API for configuring and interacting with the Prologix USB-to-GPIB adapter. Provides functions for setting GPIB addresses, controlling read/write modes, managing EOI/EOS settings, querying firmware, and reading instrument responses. ```APIDOC PROLOGIX_ADDR: Set the GPIB address of the Prologix USB-to-GPIB adapter. PROLOGIX_AUTO: Toggle "Read-After-Write" mode on or off for the USB-to-GPIB adapter. PROLOGIX_EOI: Sets the EOI and EOS settings for the Prologix GPIB-USB adapter. PROLOGIX_HELP: Return a list of available Prologix USB-to-GPIB firmware commands. PROLOGIX_MODE: Set the control mode of the Prologix USB-to-GPIB controller. PROLOGIX_READ: Returns the response from the GPIB instrument. PROLOGIX_VER: Query the Prologix USB-to-GPIB firmware version. ``` -------------------------------- ### Connect to Standa 10MWA168 using QCodes Community in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Lockin Amplifiers/Standa/standa-10mwa168.mdx This Python script demonstrates how to connect to a Standa 10MWA168 Lockin Amplifier using the QCodes Community library. It initializes the instrument, adds it to a station, establishes a connection, and shows examples of reading and setting instrument parameters like position and transmittance. ```python from qcodes import Station, Instrument from qcodes.instrument_drivers.standa.standa_10mwa168 import Standa_10MWA168 # Create a station to hold the instrument station = Station() # Create an instance of the Standa_10MWA168 instrument standa = Standa_10MWA168('standa', serial_number='your_serial_number') # Add the instrument to the station station.add_component(standa) # Connect to the instrument standa.connect() # Now you can use the instrument's parameters and methods # For example, to get the current position: position = standa.position.get() print(f"Current position: {position}") # To set the transmittance: standa.transmittance.set(2) # Set transmittance to 0.9 ``` -------------------------------- ### Connect and Control Rigol DS1000-Series Oscilloscope with InstrumentKit in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Oscilloscopes/Rigol/rigol-ds1000-series.mdx This code snippet demonstrates how to establish a connection to a Rigol DS1000-Series oscilloscope using the InstrumentKit library in Python. It includes examples for configuring acquisition settings (type, averages), triggering the device, starting and stopping measurements, releasing local panel control, and properly disconnecting from the instrument. Users must replace the placeholder IP address with the actual IP of their oscilloscope. ```python from instrumentkit import RigolDS1000Series # Connect to the oscilloscope oscilloscope = RigolDS1000Series("192.168.1.1") # Replace with the IP address of your oscilloscope # Set the acquisition type to normal oscilloscope.acquire_type = RigolDS1000Series.AcquisitionType.normal # Set the number of averages to 8 oscilloscope.acquire_averages = 8 # Trigger the oscilloscope oscilloscope.force_trigger() # Start running the oscilloscope trigger oscilloscope.run() # Stop the oscilloscope trigger oscilloscope.stop() # Release any lockout of the local control panel oscilloscope.release_panel() # Disconnect from the oscilloscope oscilloscope.disconnect() ``` -------------------------------- ### Connect to Teledyne WaveSurfer 3000z Oscilloscope with InstrumentKit in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Oscilloscopes/Teledyne/wavesurfer-3000z.mdx This code demonstrates how to establish a connection to a Teledyne WaveSurfer 3000z oscilloscope using the `instrumentkit` library. It shows how to open a VISA connection, perform basic operations like starting the oscilloscope's trigger and reading its state, and then properly close the connection. Users must replace the placeholder VISA address with their instrument's actual address and ensure `instrumentkit` is installed. ```python import instrumentkit as ik # Connect to the oscilloscope oscilloscope = ik.teledyne.WaveSurfer3000z.open_visa("TCPIP0::192.168.0.10::INSTR") # Perform operations on the oscilloscope oscilloscope.run() print(oscilloscope.trigger_state) # Close the connection oscilloscope.close() ``` -------------------------------- ### Control Keysight N7776C Laser Source Output and Sweep Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Lasers/Keysight/keysight-n7776c.mdx This Python example demonstrates how to instantiate the `KeysightN7776C` class, connect to the laser source, enable its output, set an initial wavelength, configure and initiate a wavelength sweep, monitor the sweep's progress, and finally disable the output and close the connection. It showcases basic control flow for automated laser operations. ```python laser = KeysightN7776C(address) laser.output_enabled = True laser.wavelength = 1550 laser.sweep_wl_start = 1550 laser.sweep_wl_stop = 1560 laser.sweep_speed = 1 laser.sweep_mode = 'CONT' while laser.sweep_state == 1: log.info('Sweep in progress.') laser.output_enabled = False laser.close() ``` -------------------------------- ### Connect to Aimtti PL068-P Power Supply using QCodes in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Power Supplies/Aimtti/pl068-p.mdx This Python script demonstrates how to create a custom QCodes instrument driver for the Aimtti PL068-P DC Power Supply. It defines classes for instrument channels and the main instrument, allowing control over output state and voltage. The example shows instrument initialization, reading identification, and setting voltage and output parameters. ```python from qcodes.instrument.visa import VisaInstrument from qcodes.instrument.channel import ChannelList from qcodes.instrument.parameter import Parameter from qcodes import validators as vals class AimTTiChannel(Parameter): def __init__(self, parent, name, channel): super().__init__(name, label=name, unit='', get_cmd=None, set_cmd=None) self.parent = parent self.channel = channel def get_raw(self): return self.parent.ask(f"V{self.channel}?") def set_raw(self, value): self.parent.write(f"V{self.channel} {value}") class AimTTi(VisaInstrument): def __init__(self, name, address): super().__init__(name, address) self.channels = ChannelList(self, "Channels", AimTTiChannel, snapshotable=False) self.add_submodule("channels", self.channels) self.add_parameter( "output", get_cmd="OP?", set_cmd="OP {}", val_mapping={0: 'off', 1: 'on'} ) self.add_parameter( "voltage", get_cmd="V?", set_cmd="V {}", get_parser=float, set_parser=float, unit="V", vals=vals.Numbers(0, 30) ) self.connect_message() def get_idn(self): return {'vendor': 'Aim', 'model': 'PL068-P', 'serial': '1234', 'firmware': '1.0'} def get_address(self): return 1 aim_tti = AimTTi("aim_tti", "TCPIP::192.168.1.1::INSTR") print(aim_tti.get_idn()) print(aim_tti.get_address()) print(aim_tti.channels) print(aim_tti.voltage()) aim_tti.voltage(10) print(aim_tti.voltage()) aim_tti.output('on') print(aim_tti.output()) ``` -------------------------------- ### Connect to Qutech D4 Power Meter using QCodes Community in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/Power Meters/Qutech/d4.mdx This Python script provides a QCodes driver for the Qutech D4 ADC SPI-rack module. It defines a `D4` class that encapsulates the instrument's parameters like mode, filter value, buffer status, and ADC readings. The example demonstrates how to instantiate the driver and access its measurement parameters. Users need to replace `spi_rack` and `module` with their specific setup values. ```python from qcodes.instrument.base import Instrument try: from spirack import D4_module except ImportError: raise ImportError(('The D4_module class could not be found. ' 'Try installing it using pip install spirack')) from functools import partial class D4(Instrument): """ Qcodes driver for the D4 ADC SPI-rack module. Requires installation of the 'spirack' package using pip. Args: name (str): name of the instrument. spi_rack (SPI_rack): instance of the SPI_rack class as defined in the spirack package. This class manages communication with the individual modules. module (int): module number as set on the hardware. """ def __init__(self, name, spi_rack, module, **kwargs): super().__init__(name, **kwargs) self.d4 = D4_module(spi_rack, module) self.add_parameter('mode', label='Mode', get_cmd=self.get_mode) self.add_parameter('filter_value', label='Filter value', get_cmd=self.get_filter_value) self.add_parameter('buffers_enabled', label='Buffers enabled', get_cmd=self.get_buffers_enabled) for i in range(2): self.add_parameter('adc{}'.format(i + 1), label='ADC {}'.format(i + 1), get_cmd=partial(self.d4.singleConversion, i), units='V') def get_mode(self): return self.d4.mode def get_filter_value(self): return self.d4.filter_val def get_buffers_enabled(self): return self.d4.buf_en # Create an instance of the D4 class d4_power_meter = D4('d4_power_meter', spi_rack, module) # Access the parameters of the D4 power meter mode = d4_power_meter.mode() filter_value = d4_power_meter.filter_value() buffers_enabled = d4_power_meter.buffers_enabled() adc1_value = d4_power_meter.adc1() adc2_value = d4_power_meter.adc2() ``` -------------------------------- ### Flojoy Data Generation - Sample Datasets Blocks Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/blocks/DATA/overview.mdx Documentation for Flojoy blocks that retrieve sample datasets from common data science libraries. ```APIDOC PLOTLY_DATASET: Retrieve a pandas DataFrame from one of Plotly Express's built-in datasets. SCIKIT_LEARN_DATASET: Retrieve a pandas DataFrame from the scikit-learn sample datasets. TEXT_DATASET: Load one of the 20 newsgroup sample datasets from scikit-learn. ``` -------------------------------- ### Flojoy Blocks for Tektronix MSO24 Oscilloscope Setup Configuration Source: https://github.com/flojoy-ai/studio/blob/main/blocks/HARDWARE/OSCILLOSCOPES/TEKTRONIX/MSO2X/VERTICAL_SCALE_MSO2X/example.md This documentation outlines the Flojoy blocks and their configurations required to generate a setup file for a Tektronix MSO24 oscilloscope using the `tm_measure` library. It details the purpose and key parameters for each block, including connection, channel, and filename settings. ```APIDOC Flojoy Blocks for Tektronix MSO24 Oscilloscope Setup: CONNECT_MSO2X - Purpose: Connects to the MSO2X oscilloscope. - Parameters: - connection: The instrument connection (required). AFG_MSO2X - Purpose: Configures the Arbitrary Function Generator (AFG) settings for MSO2X. - Note: AFG settings are not loaded from the setup file. CHANNEL_DISPLAY_MSO2X - Purpose: Controls the display of oscilloscope channels. - Parameters: - channel: The channel number (e.g., 1, 2, 3) to enable display. EDGE_TRIGGER_MSO2X - Purpose: Configures edge trigger settings for the MSO2X. - Parameters: - connection: The instrument connection (required). HORIZONTAL_SCALE_MSO2X - Purpose: Sets the horizontal scale (time base) for the MSO2X. - Parameters: - connection: The instrument connection (required). VERTICAL_SCALE_MSO2X (Multiple Instances) - Purpose: Sets the vertical scale for individual channels. - Parameters: - connection: The instrument connection (required). - channel: The channel number (1, 2, or 3) for which to set the vertical scale. PROBE_ATTENUATION_MSO2X (Multiple Instances) - Purpose: Configures probe attenuation for individual channels. - Parameters: - connection: The instrument connection (required). - channel: The channel number (1, 2, or 3) for which to set probe attenuation. SETUP_FILE_MSO2X - Purpose: Saves the oscilloscope settings to a setup file. - Parameters: - connection: The instrument connection (required). - filename: The desired filename (e.g., "flojoy" saves to c:/flojoy.set). ``` -------------------------------- ### Connect and Control Keysight KtMAwg IVI-C with QCodes in Python Source: https://github.com/flojoy-ai/studio/blob/main/docs/src/content/docs/instruments-database/RF Signal Generators/Keysight/ktmawg-ivi-c.mdx This Python script demonstrates how to establish a connection with a Keysight KtMAwg IVI-C RF Signal Generator using the QCodes library. It initializes the `KtMAwg` instrument, connects to it via TCP/IP, retrieves its identification, configures channel output, loads and plays a waveform file, and finally disconnects. This example showcases fundamental operations for instrument control and waveform management. ```Python from qcodes.instrument_drivers.Keysight.KtMAwg import KtMAwg # Create an instance of the KtMAwg instrument awg = KtMAwg('awg', 'TCPIP0::192.168.1.1::inst0::INSTR') # Connect to the instrument awg.connect() # Print the instrument IDN print(awg.get_idn()) # Set the output terminal configuration of channel 1 to differential awg.ch1.output_term_config('differential') # Enable the output of channel 1 awg.ch1.output(True) # Load a waveform file to channel 1 awg.ch1.load_waveform('waveform.dat') # Play the waveform on channel 1 awg.ch1.play_waveform() # Stop the waveform on channel 1 awg.ch1.stop_waveform() # Disconnect from the instrument awg.disconnect() ```