<jupyter_start><jupyter_text>QCoDeS Example with Tektronix TPS2012<jupyter_code>%matplotlib nbagg
import binascii
import logging

import matplotlib.pyplot as plt
import qcodes as qc
import numpy as np
import qcodes.instrument_drivers.tektronix.TPS2012 as tektps

from time import time, sleep

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
tps = tektps.TPS2012('TPS1', 'ASRL1::INSTR')
# For good measures, one may clear out old messages
tps.clear_message_queue()<jupyter_output><empty_output><jupyter_text>SETTING UP AN ACQUISITIONThe driver supports basic setting of scales and triggers.In this example, we want to look at a 10 kHz sine, 100 mVpp with a -50 mV offset.The sine is on channel **1**, while the sync (0 V to 3 V square wave) signal from the function generator is on channel **2**.<jupyter_code># we don't want to see the ref. signal, only the sine
tps.ch1_state('ON')
tps.ch2_state('OFF')

# horizontal
tps.horizontal_scale.set(10e-6)
# channel 1
tps.ch1_scale.set(50e-3)  # V/div
tps.ch1_position.set(2)  # divisions
# channel 2
tps.ch2_scale.set(1)
tps.ch2_position.set(-3)
# trigger
tps.trigger_type.set('EDGE')
tps.trigger_source.set('CH2')
tps.trigger_level.set(1.5)<jupyter_output><empty_output><jupyter_text>ACQUIRING THE CURVES FROM THE OSCILLOSCOPEThere is a simple command to get two arrays for the horizontal and vertical data. Because this is early beta version you must currently call `set_set_points` on each channel just before reading a trace from the channel. This is a limitation in the current dataset/loop of qcodes. You should also ensure that the scope has been triggered at these settings before calling set_set_points or you will get inconsitent data. In this example notebook we use force_trigger to ensure that we always have data when setting the set_points<jupyter_code>tps.force_trigger()
sleep(10*tps.horizontal_scale.get_latest())
tps.ch1_curvedata.prepare_curvedata()
tps.ch2_curvedata.prepare_curvedata()
data = qc.Measure(tps.ch1_curvedata, tps.ch2_curvedata).run()
plot = qc.MatPlot(subplots=(2, 1))
plot.add(data.TPS1_scope_measurement_0)
plot.add(data.TPS1_scope_measurement_1, subplot=2)<jupyter_output><empty_output><jupyter_text>Change horisontal scale and remember to call `prepare_curvedata` to update the setpoint array<jupyter_code>tps.horizontal_scale.set(25e-6)
tps.force_trigger()
sleep(11*tps.horizontal_scale.get_latest())
tps.ch1_curvedata.prepare_curvedata()
tps.ch2_curvedata.prepare_curvedata()
data2 = qc.Measure(tps.ch1_curvedata, tps.ch2_curvedata).run()
plot = qc.MatPlot(subplots=(2, 1))
plot.add(data2.TPS1_scope_measurement_0)
plot.add(data2.TPS1_scope_measurement_1, subplot=2)
tps.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09272257111193202, 'fraction_numerical': 0.028444772811230146, 'mean_word_length': 6.628169014084507, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '130676', 'license': 'MIT', 'n_tokens_mistral': 1007, 'n_tokens_neox': 963, 'n_words': 258, 'path': 'docs/examples/driver_examples/Qcodes example with Tektronix TPS2012.ipynb', 'repo_name': 'ThorvaldLarsen/Qcodes', 'size': '2707'}