#Number of cycles must be small otherwise generates a following error start = -10.0 end = -5.0 acc_distance = 1.0 def before(position, scan): time.sleep(0.1) def after(record, scan): global start, end if scan_y.position < start: record.invalidate() if scan_y.position > end: scan.abort() #setup_plotting(line_plots = [mca_1]) scan_y.move(start - acc_distance) scan_y.moveAsync(end + acc_distance) mscan(trigger, [scan_y.readback, keith_1], 1000, timeout = None, before_read = before, after_read = after)