def single_acquisition_example(name, n_events, trigger, trigger_channel): """ Acquire a set of triggerred single acquisitions for two channels.""" tek_scope = scopes.Tektronix2000(scope_connections.VisaUSB()) # First setup the scope, lock the front panel tek_scope.lock() tek_scope.set_active_channel(1) tek_scope.set_active_channel(2) tek_scope.set_single_acquisition() # Single signal acquisition mode tek_scope.set_edge_trigger(trigger, trigger_channel, True) # Falling edge trigger tek_scope.set_data_mode(49500, 50500) tek_scope.begin() # Now create a HDF5 file and save the meta information file_name = name + "_" + str(datetime.date.today()) results = utils.HDF5File(file_name, 2) results.add_meta_data("trigger", trigger) results.add_meta_data("trigger_channel", trigger_channel) results.add_meta_data("ch1_timeform", tek_scope.get_timeform(1)) results.add_meta_data("ch2_timeform", tek_scope.get_timeform(2)) results.add_meta_dict(tek_scope.get_preamble(1), "ch1") results.add_meta_dict(tek_scope.get_preamble(2), "ch2") last_save_time = datetime.datetime.now() print "Starting data taking at time", last_save_time.strftime("%Y-%m-%d %H:%M:%S") for event in range(0, n_events): tek_scope.acquire() try: results.add_data(tek_scope.get_waveform(1), 1) results.add_data(tek_scope.get_waveform(2), 2) except visa_exceptions.VisaIOError, e: print "Serious death", e time.sleep(10) except Exception, e: print "Scope died, acquisition lost.", e time.sleep(10)
def measurement_example(name, n_events, trigger, trigger_channel, y_scale, cursor_low, cursor_high): """ Acquire a set of measurements for a triggerred single acquisition on one channel.""" tek_scope = scopes.Tektronix2000(scope_connections.VisaUSB()) # First setup the scope, lock the front panel tek_scope.lock() tek_scope.set_active_channel(1) tek_scope.set_single_acquisition() # Single signal acquisition mode tek_scope.set_channel_y(1, y_scale) tek_scope.set_edge_trigger(trigger, trigger_channel, True) # Falling edge trigger tek_scope.set_horizontal_scale(1e-8) tek_scope.set_cursors(cursor_low, cursor_high) tek_scope.set_measurement("area") tek_scope.begin() file_name = name + "_" + str(datetime.date.today()) results = utils.HDF5File(file_name, 1) results.add_meta_data("trigger", trigger) results.add_meta_data("trigger_channel", trigger_channel) results.add_meta_data("cursor_low", cursor_low) results.add_meta_data("cursor_high", cursor_high) results.add_meta_data("y_scale", y_scale) last_save_time = datetime.datetime.now() print "Starting data taking at time", last_save_time.strftime( "%Y-%m-%d %H:%M:%S") for event in range(0, n_events): tek_scope.acquire() try: print tek_scope.get_measurement(1) results.add_data(tek_scope.get_measurement(1), 1) except visa_exceptions.VisaIOError, e: print "Serious death", e time.sleep(10) except Exception, e: print "Scope died, acquisition lost.", e time.sleep(10)
(options, args) = parser.parse_args() #Set parameters box = int(options.box) channel = int(options.channel) #Fixed parameters delay = 1.0 # 1ms -> kHz cursor_low = -5e-9 # s cursor_high = 23e-9 # s trigger_level = 0.5 # half peak minimum falling_edge = True min_trigger = -0.005 # -5mV smallest allowed trigger #run the initial setup on the scope usb_conn = scope_connections.VisaUSB() scope = scopes.Tektronix3000(usb_conn) scope.set_cursor("x", 1, cursor_low) scope.set_cursor("x", 2, cursor_high) #Create a new, timestamped, summary file timestamp = time.strftime("%y%m%d_%H.%M.%S", time.gmtime()) widths = [0, 2000, 4000, 6000, 7000] last_scale = None last_trigger = None for width in widths: if width == 6000: last_scale = 0.2 last_trigger = -0.1 elif width == 7000: last_scale = 0.1
#!/usr/bin/env python # # interactive_example.py # # Simple script to gain interactive control over the scope. # # Author P G Jones - 2013-10-23 <*****@*****.**> : First revision ################################################################################## import scopes import scope_connections tek_scope = scopes.Tektronix2000(scope_connections.VisaUSB()) tek_scope.interactive()