Channel Colors and Waveform Labels
This Python example displays 16 waveforms on FlexDCA each in a different color. The color is selected using the waveform color arguments strings use in many waveform commands. A waveform label is used to label the color argument above each waveform. You'll learn about the available colors and how to use waveform labels in the :CHANnel:COLor
and :CHANnel:UNAMe
commands.
Example Script
Copy
waveform-colors-and-labels.py
# -*- coding: utf-8 -*-
""" Installs four simulated modules. Sixteen waveforms are
displayed showing the SCPI color arguments used to identify
the color of waveforms.
"""
import pyvisa as visa # import VISA library
ADDRESS = 'TCPIP0::localhost::hislip0,4880::INSTR'
TIMEOUT = 10000
def open_flexdca_connection(address):
""" Opens visa connection to FlexFlexDCA. """
try:
rm = visa.ResourceManager()
connection = rm.open_resource(address)
connection.timeout = TIMEOUT
connection.read_termination = '\n'
connection.write_termination = '\n'
inst_id = connection.query('*IDN?')
print('\nFlexDCA connection established to:\n' + inst_id, flush=True)
connection.write(':SYSTem:DEFault')
connection.query('*OPC?')
except (visa.VisaIOError, visa.InvalidSession):
print('\nVISA ERROR: Cannot open instrument address.\n', flush=True)
return None
except Exception as other:
print('\nVISA ERROR: Cannot connect to instrument:', other, flush=True)
print('\n')
return None
return connection
def all_channels_off(flexdca):
""" Turns all available channels off. """
for slot in '12345678':
for letter in 'ABCD':
channel = slot + letter
flexdca.write(':CHANnel' + channel + ':DISPlay OFF')
def install_simulated_module(flexdca, channel, model, signal='NRZ'):
""" Simplified installation of a simulated FlexDCA module.
model
Type of simulated module. "DEM" is a dual-electrical module.
"QEM" is a quad-electrical module. "DOM" is a dual-optical
module. "QEM" is a electrical-optical module.
signal
Format of signal. NRZ or PAM4.
"""
slot = channel[0]
flexdca.write(':EMODules:SLOT' + slot + ':SELection ' + model)
if signal in 'NRZ':
flexdca.write(':SOURce' + channel + ':FORMat NRZ')
else:
flexdca.write(':SOURce' + channel + ':FORMat PAM4')
flexdca.write(':SOURce' + channel + ':DRATe 9.95328E+9')
flexdca.write(':SOURce' + channel + ':WTYPe DATA')
flexdca.write(':SOURce' + channel + ':PLENgth 127')
flexdca.write(':SOURce' + channel + ':AMPLitude 90E-3')
flexdca.write(':SOURce' + channel + ':NOISe:RN 3.0E-6')
flexdca.write(':SOURce' + channel + ':JITTer:RJ 4.0E-12')
flexdca.write(':CHANnel' + channel + ':DISPlay ON')
def waveform_acquisition(flexdca):
""" Performs waveform acquisition limit test. """
flexdca.query(':SYSTEM:AUToscale;*OPC?')
flexdca.write(':ACQuire:SINGle') # single acquisition mode
flexdca.write(':ACQuire:CDISplay') # Clear display
flexdca.write(':LTESt:ACQuire:CTYPe:WAVeforms 150')
flexdca.write(':LTESt:ACQuire:STATe ON')
print('\nAcquiring 150 waveforms. Please wait...', flush=True)
flexdca.query(':ACQuire:RUN;*OPC?')
flexdca.write(':LTESt:ACQuire:STATe OFF')
FlexDCA = open_flexdca_connection(ADDRESS)
FlexDCA.query(':SYSTem:DEFault;*OPC?')
all_channels_off(FlexDCA)
install_simulated_module(FlexDCA, '1A', 'QEM')
install_simulated_module(FlexDCA, '2A', 'QEM')
install_simulated_module(FlexDCA, '3A', 'QEM')
install_simulated_module(FlexDCA, '4A', 'QEM')
slots = '1234'
letters = 'ABCD'
channels = [(slot + letter) for slot in slots for letter in letters]
n = 0
for channel in channels:
FlexDCA.write(':SOUR' + channel + ':JITTer:STATe ON')
FlexDCA.write(':SOUR' + channel + ':JITTer:RJ 4.0E-12')
FlexDCA.write(':SOUR' + channel + ':NOISe:STATe ON')
FlexDCA.write(':SOUR' + channel + ':NOISe:RN 3.0E-6')
FlexDCA.write(':CHANnel' + channel + ':COLor TCOLor' + str(n+1))
# display color name for waveform on instrument
FlexDCA.write(':CHANnel' + channel + ':UNAMe "Ch' + channel + ' = TCOLor' + str(n+1) + '"')
FlexDCA.write(':CHANnel' + channel + ':DISPlay ON')
n += 1
FlexDCA.write(':SYSTem:MODE EYE')
FlexDCA.query(':SYSTem:AUToscale;*OPC?')
FlexDCA.write(':DISP:WIND:TIME1:DMODe TILed')
FlexDCA.write(':SYSTem:GTLocal')
FlexDCA.close()
print('\nChannel labels show names of channel color constants.')