diff --git a/artiq/devices/pdq2.py b/artiq/devices/pdq2com.py old mode 100755 new mode 100644 similarity index 64% rename from artiq/devices/pdq2.py rename to artiq/devices/pdq2com.py index 98c9d8da6..9d2ff2d3d --- a/artiq/devices/pdq2.py +++ b/artiq/devices/pdq2com.py @@ -1,16 +1,15 @@ -#!/usr/bin/python -# -*- coding: utf8 -*- -# # Robert Jordens , 2012 -import logging, struct -import numpy as np -from scipy import interpolate +import logging +import struct import warnings -logger = logging.getLogger("Pdq2") +from scipy import interpolate +import numpy as np +logger = logging.getLogger("Pdq2") + Ftdi = None @@ -302,129 +301,3 @@ class Pdq2: board, dac = divmod(channel, self.num_dacs) data = self.add_mem_header(board, dac, data) return data - - -def _main(): - import argparse - import time - - parser = argparse.ArgumentParser(description="""PDQ2 frontend. - Evaluates times and voltages, interpolates and uploads - them.""") - parser.add_argument("-s", "--serial", default=None, - help="device (FT245R) serial string [first]") - parser.add_argument("-c", "--channel", default=0, type=int, - help="channel: 3*board_num+dac_num [%(default)s]") - parser.add_argument("-f", "--frame", default=0, type=int, - help="frame [%(default)s]") - parser.add_argument("-e", "--free", default=False, - action="store_true", - help="software trigger [%(default)s]") - parser.add_argument("-n", "--disarm", default=False, - action="store_true", - help="disarm group [%(default)s]") - parser.add_argument("-t", "--times", - default="np.arange(5)*1e-6", - help="sample times (s) [%(default)s]") - parser.add_argument("-v", "--voltages", - default="(1-np.cos(t/t[-1]*2*np.pi))/2", - help="sample voltages (V) [%(default)s]") - parser.add_argument("-o", "--order", default=3, type=int, - help="interpolation (0: const, 1: lin, 2: quad, 3: cubic)" - " [%(default)s]") - parser.add_argument("-m", "--dcm", default=None, type=int, - help="choose fast 100MHz clock [%(default)s]") - parser.add_argument("-x", "--demo", default=False, action="store_true", - help="demo mode: pulse and chirp, 1V*ch+0.1V*frame [%(default)s]") - parser.add_argument("-p", "--plot", help="plot to file [%(default)s]") - parser.add_argument("-d", "--debug", default=False, - action="store_true", help="debug communications") - parser.add_argument("-r", "--reset", default=False, - action="store_true", help="do reset before") - parser.add_argument("-b", "--bit", default=False, - action="store_true", help="do bit test") - - args = parser.parse_args() - - if args.debug: - logging.basicConfig(level=logging.DEBUG) - else: - logging.basicConfig(level=logging.WARNING) - - times = eval(args.times, globals(), {}) - voltages = eval(args.voltages, globals(), dict(t=times)) - - dev = Pdq2(serial=args.serial) - - if args.reset: - dev.write(b"\x00") # flush any escape - dev.write_cmd("RESET_EN") - time.sleep(.1) - if args.dcm: - dev.write_cmd("DCM_EN") - dev.freq = 100e6 - elif args.dcm == 0: - dev.write_cmd("DCM_DIS") - dev.freq = 50e6 - dev.write_cmd("START_DIS") - - if args.demo: - channels = [args.channel] if args.channel < dev.num_channels \ - else range(dev.num_channels) - frames = [args.frame] if args.frame < dev.num_frames \ - else range(dev.num_frames) - for channel in channels: - f = [] - for frame in frames: - vi = .1*frame + channel + voltages - pi = 2*np.pi*(.01*frame + .1*channel + 0*voltages) - fi = 10e6*times/times[-1] - f.append(b"".join([ - dev.frame(times, vi, order=args.order, end=False), - dev.frame(2*times, voltages, pi, fi, trigger=False), - #dev.frame(2*times, 0*vi+.1, 0*pi, 0*fi+1e6), - #dev.frame(times, 0*vi, order=args.order, silence=True), - ])) - board, dac = divmod(channel, dev.num_dacs) - dev.write_data(dev.add_mem_header(board, dac, dev.map_frames(f))) - elif args.bit: - map = [0] * dev.num_frames - t = np.arange(2*16) * 1. - v = [-1, 0, -1] - for i in range(15): - vi = 1<, 2012 + +import argparse +import time +import logging + +from scipy import interpolate +import numpy as np + +from artiq.devices.pdq2com import Pdq2 + + +def _main(): + parser = argparse.ArgumentParser(description="""PDQ2 frontend. + Evaluates times and voltages, interpolates and uploads + them.""") + parser.add_argument("-s", "--serial", default=None, + help="device (FT245R) serial string [first]") + parser.add_argument("-c", "--channel", default=0, type=int, + help="channel: 3*board_num+dac_num [%(default)s]") + parser.add_argument("-f", "--frame", default=0, type=int, + help="frame [%(default)s]") + parser.add_argument("-e", "--free", default=False, + action="store_true", + help="software trigger [%(default)s]") + parser.add_argument("-n", "--disarm", default=False, + action="store_true", + help="disarm group [%(default)s]") + parser.add_argument("-t", "--times", + default="np.arange(5)*1e-6", + help="sample times (s) [%(default)s]") + parser.add_argument("-v", "--voltages", + default="(1-np.cos(t/t[-1]*2*np.pi))/2", + help="sample voltages (V) [%(default)s]") + parser.add_argument("-o", "--order", default=3, type=int, + help="interpolation (0: const, 1: lin, 2: quad, 3: cubic)" + " [%(default)s]") + parser.add_argument("-m", "--dcm", default=None, type=int, + help="choose fast 100MHz clock [%(default)s]") + parser.add_argument("-x", "--demo", default=False, action="store_true", + help="demo mode: pulse and chirp, 1V*ch+0.1V*frame [%(default)s]") + parser.add_argument("-p", "--plot", help="plot to file [%(default)s]") + parser.add_argument("-d", "--debug", default=False, + action="store_true", help="debug communications") + parser.add_argument("-r", "--reset", default=False, + action="store_true", help="do reset before") + parser.add_argument("-b", "--bit", default=False, + action="store_true", help="do bit test") + + args = parser.parse_args() + + if args.debug: + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.WARNING) + + times = eval(args.times, globals(), {}) + voltages = eval(args.voltages, globals(), dict(t=times)) + + dev = Pdq2(serial=args.serial) + + if args.reset: + dev.write(b"\x00") # flush any escape + dev.write_cmd("RESET_EN") + time.sleep(.1) + if args.dcm: + dev.write_cmd("DCM_EN") + dev.freq = 100e6 + elif args.dcm == 0: + dev.write_cmd("DCM_DIS") + dev.freq = 50e6 + dev.write_cmd("START_DIS") + + if args.demo: + channels = [args.channel] if args.channel < dev.num_channels \ + else range(dev.num_channels) + frames = [args.frame] if args.frame < dev.num_frames \ + else range(dev.num_frames) + for channel in channels: + f = [] + for frame in frames: + vi = .1*frame + channel + voltages + pi = 2*np.pi*(.01*frame + .1*channel + 0*voltages) + fi = 10e6*times/times[-1] + f.append(b"".join([ + dev.frame(times, vi, order=args.order, end=False), + dev.frame(2*times, voltages, pi, fi, trigger=False), + #dev.frame(2*times, 0*vi+.1, 0*pi, 0*fi+1e6), + #dev.frame(times, 0*vi, order=args.order, silence=True), + ])) + board, dac = divmod(channel, dev.num_dacs) + dev.write_data(dev.add_mem_header(board, dac, dev.map_frames(f))) + elif args.bit: + map = [0] * dev.num_frames + t = np.arange(2*16) * 1. + v = [-1, 0, -1] + for i in range(15): + vi = 1<