Connecting to MS9740A by Anritsu in Python
Instrument Card
The MS9740A supports nine application measurement modes (DFBLD, FP-LD, LED, PMD, Opt. Amp, Opt. Amp (Multi-channel), WDM, LD Module, WDM Filter) for measurement targets
Device Specification: here
Manufacturer card: ANRITSU
Anritsu Has Testing Solutions for Automotive, Government, Data Center, & IoT Industries. Test Solutions for IoT Devices, Government Radar, Automotive, & Signal Integrity.
- Headquarters: JAPAN
- Yearly Revenue (millions, USD): 670
- Vendor Website: here
Connect to the MS9740A in Python
Read our guide for turning Python scripts into Flojoy nodes.
PROTOCOLS > SCPI
import loggingfrom pymeasure.instruments import Instrumentfrom pymeasure.instruments.anritsu import AnritsuMS9710Cfrom pymeasure.instruments.validators import ( strict_discrete_set, truncated_discrete_set, truncated_range,)
log = logging.getLogger(__name__)log.addHandler(logging.NullHandler())
class AnritsuMS9740A(AnritsuMS9710C): """Anritsu MS9740A Optical Spectrum Analyzer."""
def __init__(self, adapter, name="Anritsu MS9740A Optical Spectrum Analyzer", **kwargs): """Constructor.""" self.analysis_mode = None super().__init__( adapter, name, **kwargs)
#################################### # Spectrum Parameters - Wavelength # ####################################
resolution = Instrument.control( "RES?", "RES %s", "Resolution (nm)", validator=truncated_discrete_set, values=[0.03, 0.05, 0.07, 0.1, 0.2, 0.5, 1.0], )
resolution_vbw = Instrument.control( "VBW?", "VBW %s", "Video Bandwidth Resolution", validator=strict_discrete_set, values=["1MHz", "100kHz", "10kHz", "2kHz", "1kHz", "200Hz", "100Hz", "10Hz"] )
average_sweep = Instrument.control( "AVS?", "AVS %d", "Nr. of averages to make on a sweep (1-1000), with 1 being a single (non-averaged) sweep", validator=truncated_range, values=[1, 1000] )
sampling_points = Instrument.control( "MPT?", "MPT %d", "Number of sampling points", validator=truncated_discrete_set, values=[51, 101, 251, 501, 1001, 2001, 5001, 10001, 20001, 50001], get_process=lambda v: int(v) )
########################## # Data Memory Commands # ##########################
data_memory_select = Instrument.control( "TTP?", "TTP %s", "Memory Data Select.", validator=strict_discrete_set, values=["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] )
def repeat_sweep(self, n=20, delay=0.5): """Perform a single sweep and wait for completion.""" log.debug("Performing a repeat Spectrum Sweep") self.clear() self.write('SRT') self.wait_for_sweep(n=n, delay=delay)
This script defines a class AnritsuMS9740A
that inherits from AnritsuMS9710C
(which is another instrument class provided by Pymeasure). The AnritsuMS9740A
class adds additional control properties and methods specific to the Anritsu MS9740A Optical Spectrum Analyzer.
The control properties defined in the class, such as resolution
, resolution_vbw
, average_sweep
, sampling_points
, and data_memory_select
, allow you to interact with the instrument by reading and writing specific commands.
The repeat_sweep
method performs a single sweep and waits for completion. It sends the command ‘SRT’ to start the sweep and then waits for the sweep to complete using the wait_for_sweep
method.
Note that this script only defines the class and its properties/methods. To use it, you need to create an instance of the AnritsuMS9740A
class and connect it to your instrument using an appropriate adapter.