def test_phase_switching_simultan(self, freq1=45, freq2=45, amplitude=-15, address1=0, address2=1, clock=800): "Test two dds simultaneous on" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(address1, clock) dds_device2 = ad9910.AD9910(address2, clock) my_api.init_dds(dds_device) my_api.init_dds(dds_device2) my_api.label("test") my_api.init_frequency(dds_device, 0.0, 0) my_api.init_frequency(dds_device2, 0.0, 0) my_api.init_frequency(dds_device, freq1, 1) my_api.init_frequency(dds_device2, freq2, 2) my_api.dac_value(amplitude, address1) my_api.dac_value(amplitude, address2) my_api.ttl_value(0x1, 2) my_api.switch_frequency(dds_device, 0, 0) my_api.switch_frequency(dds_device2, 0, 0) my_api.wait(2000) my_api.switch_frequency(dds_device, 1, 0) my_api.switch_frequency(dds_device2, 1, 0) my_api.ttl_value(0x0, 2) my_api.wait(10000) my_api.jump("test") self.compile(my_sequencer)
def test_phase_switching(self, freq1=45, freq2=45, amplitude=-15, address1=0, address2=1, clock=800): "Just sets a loop profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(address1, clock) dds_device2 = ad9910.AD9910(address2, clock) my_api.init_dds(dds_device) my_api.init_dds(dds_device2) my_api.label("test") my_api.init_frequency(dds_device, 0.0, 0) my_api.init_frequency(dds_device2, 0.0, 0) my_api.init_frequency(dds_device, freq1, 1) my_api.init_frequency(dds_device2, freq1, 1) my_api.init_frequency(dds_device2, freq2, 2) my_api.dac_value(amplitude, address1) my_api.dac_value(amplitude, address2) my_api.ttl_value(0x1, 2) my_api.switch_frequency(dds_device, 0, 0) my_api.switch_frequency(dds_device2, 0, 0) my_api.wait(20) my_api.switch_frequency(dds_device, 1, 0) my_api.switch_frequency(dds_device2, 1, 0) for i in range(15): my_api.switch_frequency(dds_device2, 1, i * 0.05 * 3.1415) my_api.wait(20) my_api.switch_frequency(dds_device2, 1, 0) my_api.wait(100) for i in range(10): my_api.switch_frequency(dds_device2, 2, i * 0.05 * 3.1415) my_api.wait(20) my_api.switch_frequency(dds_device2, 1, 0) my_api.wait(100) my_api.switch_frequency(dds_device, 0, 0) my_api.switch_frequency(dds_device2, 0, 0) my_api.ttl_value(0x0, 2) my_api.wait(10000) my_api.jump("test") self.compile(my_sequencer)
def test_dds_profile_switching(self, my_device=0, clock=800): "Just sets a single profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(my_device, clock) my_api.label("beginseq") my_api.init_dds(dds_device) # saves frequencies in dds registers/profiles my_api.dac_value(-10, my_device) my_api.init_frequency(dds_device, 0.0, 0) my_api.init_frequency(dds_device, 5.0, 1) my_api.init_frequency(dds_device, 10.0, 2) my_api.update_dds(dds_device) my_api.wait(2) # my_api.dac_value(-2, my_device) my_api.ttl_value(0x2) my_api.set_dds_profile(dds_device, 1) my_api.update_dds(dds_device) my_api.wait(2) my_api.set_dds_profile(dds_device, 2) my_api.update_dds(dds_device) my_api.wait(2) my_api.set_dds_profile(dds_device, 0) my_api.ttl_value(0x0) my_api.jump("beginseq") self.compile(my_sequencer)
def test_dds_switching(self, frequency1, frequency2, ampl1=0, ampl2=0, my_device=0, clock=800): "Just sets a single profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(my_device, clock) my_api.label("beginseq") my_api.init_dds(dds_device) my_api.ttl_value(0x2) # set_dds_freq params: dds_device, frequency, profile my_api.set_dds_freq(dds_device, frequency1, 0) my_api.update_dds(dds_device) my_api.dac_value(ampl1, my_device) my_api.wait(1) my_api.set_dds_freq(dds_device, frequency2, 0) my_api.update_dds(dds_device) my_api.ttl_value(0x0) my_api.dac_value(ampl2, my_device) my_api.set_dds_freq(dds_device, 0.0, 0) my_api.update_dds(dds_device) my_api.jump("beginseq") self.compile(my_sequencer)
def test_switch_off(self, freq1=45, amplitude=-15, address1=0, wait=0.0, clock=800): "Just sets a loop profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(address1, clock) my_api.init_dds(dds_device) my_api.label("test") my_api.init_frequency(dds_device, 0.0, 0) my_api.init_frequency(dds_device, freq1, 1) my_api.dac_value(amplitude, address1) my_api.ttl_value(0x1, 2) my_api.switch_frequency(dds_device, 0, 0) my_api.wait(20) my_api.switch_frequency(dds_device, 1, 0) my_api.wait(20 + wait) my_api.switch_frequency(dds_device, 0, 0) my_api.ttl_value(0x0, 2) my_api.wait(10000) my_api.jump("test") self.compile(my_sequencer)
def test_all_dds_loops(self, frequency=10, amplitude=-15, clock=800): """Tests all the number of DDS boards that is given in the config file via putting out the frequency and amplitude given with the paramters""" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = [] for k in range(no_of_boards): dds_device.append(ad9910.AD9910(k, clock)) my_api.init_dds(dds_device[k]) my_api.label("beginseq") # saves frequencies in dds registers/profiles for k in range(no_of_boards): my_api.dac_value(amplitude, k) my_api.init_frequency(dds_device[k], frequency, 0) my_api.update_dds(dds_device[k]) my_api.wait(2) my_api.ttl_value(0x1) for k in range(no_of_boards): my_api.set_dds_profile(dds_device[k], 0) my_api.update_dds(dds_device[k]) my_api.ttl_value(0x0) my_api.jump("beginseq") self.compile(my_sequencer)
def test_api_ad9910(self): """Tests the api functions for the ad9910 """ dds_device = ad9910.AD9910(1, 1e3) my_sequencer=sequencer.sequencer() my_api=api.api(my_sequencer) my_api.init_dds(dds_device) my_sequencer.compile_sequence() my_sequencer.debug_sequence()
def test_freq_api_ad9910(self): "Tests the API set freq fcuntion for the ad9910" dds_device = ad9910.AD9910(1, 1e3) my_sequencer=sequencer.sequencer() my_api=api.api(my_sequencer) my_api.init_dds(dds_device) my_api.set_dds_freq(dds_device, 300, 2) my_sequencer.compile_sequence() my_sequencer.debug_sequence()
def test_freq_ad9910(self): """Tests the freq profile value of the ad9910 """ device = ad9910.AD9910(1, 1e3) device.set_freq_register(1, 10) addr_tuple = (0xf, 64) val_prof1 = device.reg_value_dict[addr_tuple] print "" print hex(val_prof1) self.assertAlmostEqual(val_prof1, 0x08B50000028F5C29, 64)
def test_init_ad9910(self): """Test the default ad9910 registers """ device = ad9910.AD9910(1, 1e3) val_cfr1 = device.reg_value_dict[device.CFR1] val_cfr2 = device.reg_value_dict[device.CFR2] print "" print hex(val_cfr1) print hex(val_cfr2) self.assertEquals(val_cfr1, 0x2000) self.assertEquals(val_cfr2, 0x50)
def test_dds_simple(self, frequency=10, amplitude=0, my_device=0): "Just sets a single profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(my_device, 800) # my_api.init_dds(dds_device) # my_api.set_dds_freq(dds_device, frequency, 0) # my_api.set_dds_profile(dds_device, 0) my_api.ttl_value(0xf, 1) my_api.update_dds(0, dds_device) # my_api.dac_value(2**14-100, 0) # my_api.dac_value(amplitude, my_device) self.compile(my_sequencer)
def test_dac(self, frequency=10, amplitude=-15, clock=800): """Tests all the number of DDS boards that is given in the config file via putting out the frequency and amplitude given with the paramters""" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = [] k = 0 dds_device.append(ad9910.AD9910(k, clock)) my_api.init_dds(dds_device[k]) my_api.label("a") my_api.dac_value(amplitude, k) my_api.label("b") self.compile(my_sequencer, 1)
def test_ramp_generator(self, my_device=0, frequency=10, amplitude=-15, dt=1, lower_limit=5, upper_limit=50, clock=800): "Just sets a loop profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(my_device, clock) my_api.label("beginseq") my_api.init_dds(dds_device) my_api.init_frequency(dds_device, frequency, 0) my_api.set_dds_profile(dds_device, 0) my_api.update_dds(dds_device) my_api.dac_value(amplitude, my_device) my_api.init_digital_ramp_generator(dds_device, dt, dt, upper_limit - lower_limit, upper_limit - lower_limit, lower_limit, upper_limit) my_api.start_digital_ramp_generator(dds_device, slope_direction=1) my_api.start_digital_ramp_generator(dds_device) ramp_direction = 1 for i in range(10): my_api.configure_ramping(dds_device, ramp_direction) my_api.wait(dt) ramp_direction = ramp_direction ^ 1 my_api.stop_digital_ramp_generator(dds_device) my_api.jump("beginseq") self.compile(my_sequencer)
def test_all_dds_boards(self): "Just sets a single profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = [] for k in range(6): dds_device.append(ad9910.AD9910(k, 800)) my_api.init_dds(dds_device[k]) my_api.label("beginseq") # saves frequencies in dds registers/profiles for k in range(6): my_api.dac_value(-15, k) my_api.init_frequency(dds_device[k], 0.0, 0) my_api.init_frequency(dds_device[k], 5.0, 1) my_api.init_frequency(dds_device[k], 10.0, 2) my_api.update_dds(dds_device[k]) my_api.wait(2) my_api.ttl_value(0x1) for k in range(6): my_api.set_dds_profile(dds_device[k], 1) my_api.update_dds(dds_device[k]) my_api.wait(2) for k in range(6): my_api.set_dds_profile(dds_device[k], 2) my_api.update_dds(dds_device[k]) my_api.wait(2) for k in range(6): my_api.set_dds_profile(dds_device[k], 0) my_api.ttl_value(0x0) my_api.jump("beginseq") self.compile(my_sequencer)
def test_dds_loop(self, frequency=10, amplitude=-15, my_device=0, wait=1000, clock=800): "Just sets a loop profile of the dds and activates it" my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(my_device, clock) my_api.init_dds(dds_device) my_api.init_frequency(dds_device, frequency, 0) my_api.set_dds_profile(dds_device, 0) my_api.update_dds(dds_device) my_api.dac_value(amplitude, my_device) my_api.wait(wait) my_api.label("beginseq") my_api.jump("beginseq") self.compile(my_sequencer)
def __init__(self, chandler, dds_count=1, ttl_dict=None): # The command handler self.chandler = chandler # The sequencer and the API self.sequencer = sequencer.sequencer() self.api = api.api(self.sequencer, ttl_dict) # Load the configuration self.config = config.Config() self.logger = logging.getLogger("server") self.seq_directory = self.config.get_str("SERVER", "sequence_dir") self.is_nonet = self.config.is_nonet() # Instnciate the IncludeHandler include_dir = self.config.get_str("SERVER", "include_dir") self.include_handler = IncludeHandler(include_dir) # The Return string global return_str return_str = "" # Configure the DDS devices self.api.dds_list = [] ref_freq = self.config.get_float("SERVER", "reference_frequency") clk_div = self.config.get_float("SERVER", "clk_divider") for dds_addr in range(dds_count): self.api.dds_list.append(ad9910.AD9910(dds_addr, ref_freq, clk_div)) # Set the parameters for the self.pulse_program_name = "" self.final_array = [] self.busy_ttl_channel = self.config.get_str("SERVER", "busy_ttl_channel") self.qfp_trigger_value = self.config.get_int("SERVER", "qfp_trigger_value") self.line_trigger_value = self.config.get_int("SERVER", "line_trigger_value") self.sequence_parser = sequence_parser.parse_sequence
from sequencer2 import api from sequencer2 import comm from sequencer2 import ad9910 from sequencer2 import ptplog # Set to true for testing without actual hardware nonet = False # Set to true for enabling the infinite loop loop_bool = True time1 = time.time() #Init logger, sequencer, API and DDS logger = ptplog.ptplog(level=logging.DEBUG) my_sequencer = sequencer.sequencer() my_api = api.api(my_sequencer) dds_device = ad9910.AD9910(0, 800) ########################################################## # Program start ########################################################## #Insert label if loop_bool: my_api.label("test") #send reset opcode to LVDS bus my_api.ttl_value(0xffff, 0) my_api.ttl_value(0xffff, 1) my_api.wait(100) my_api.ttl_value(0x1f << 11, 0) my_api.ttl_value(0x1f << 11 | 1 << 10, 0) my_api.wait(10) #initialize the DDS my_api.init_dds(dds_device)