コード例 #1
0
    def __init__(self):
	self.zeros = signal.firwin(29, 1.5e3, window='hanning',nyq = 128.0e6)
	self.zeros = self.zeros[1:-1]
    	self.center_freq = 750.0  # this is the LO frequency in MHz
	self.v1 = valon_synth.Synthesizer('/dev/ttyUSB0')
	#self.v1.set_frequency(0,self.center_freq,0.01)
	self.v1.set_frequency(8,512.0,0.01)
        self.ip = '192.168.40.55'
	self.fpga = casperfpga.katcp_fpga.KatcpFpga(self.ip,timeout=120.) 
	#self.v1.set_frequency(0,512.0, 0.01) # Channel 0 is the clock on the Valon (keep at 512.0 MHz)
        self.dds_shift = 373  # this is a number specific to the firmware used. It will change with a new firmware. 
	self.dac_samp_freq = 512.0e6
        self.fpga_samp_freq = 256.0e6
	#neg_freqs, self.neg_delta = np.linspace(-75.001234e6+5.0e4, -1.02342e6, 500, retstep = True)
	#pos_freqs, self.pos_delta = np.linspace(1.02342e6,75.001234e6, 500, retstep = True)
	neg_freqs, self.neg_delta = np.linspace(-250.001234e6+5.0e4, -5.02342e6, 500, retstep = True)
	pos_freqs, self.pos_delta = np.linspace(5.02342e6,250.001234e6, 500, retstep = True)
	self.test_comb = np.concatenate((neg_freqs, pos_freqs))
	#self.test_comb = np.array([-180.1340, -100.23423, -50.913, 50.752, 100.56, 180.650])*1.0e6
	self.test_comb = np.array([50.0125])*1.0e6
	self.test_comb = self.test_comb[ self.test_comb != 0]
	self.test_comb = np.roll(self.test_comb, - np.argmin(np.abs(self.test_comb)) - 1)
	self.upconvert = np.sort(self.test_comb/1.0e6  + self.center_freq)
	self.LUTbuffer_len = 2**21
        self.dac_freq_res = self.dac_samp_freq/self.LUTbuffer_len
        self.fft_len = 4096
        self.accum_len = (2**17) 
        self.accum_freq = self.fpga_samp_freq/(self.accum_len - 1)
	#self.fpga.write_int('sync_accum_len', self.accum_len - 1)
	self.s = socket(AF_PACKET, SOCK_RAW, htons(3))
        self.s.setsockopt(SOL_SOCKET, SO_RCVBUF, 8192 + 42)
	self.s.bind(('eth4', 3))
        self.main_prompt = '\n\t\033[33mKID-PY ROACH2 Readout\033[0m\n\t\033[35mChoose number and press Enter\033[0m'
        self.main_opts= ['Initialize','Write test comb', 'Write saved bb freqs','Write OLIMPO 150 freqs (from this script)','Print packet info to screen (UDP)','VNA sweep and plot','Locate resonances','Target sweep and plot', 'Plot channel phase PSD (quick look)','Save dirfile for all channels (I, Q, phase)', 'Save dirfile for all channels using centered phase (I, Q, phase)', 'For more than ~50 channels: Save dirfile of average I, Q, phase for all chan','Exit'] 
コード例 #2
0
 def __init__(self):
     self.v1 = valon_synth.Synthesizer('/dev/ttyUSB0')
     self.v1.set_frequency(8, 512, 0.01)  # DAC/ADC
     self.dac_samp_freq = 512.0e6
     self.fpga_samp_freq = 256.0e6
     self.dds_shift = 304  # This varies b/t fpg/bof files
     self.port = 3000
     self.ip = '192.168.40.56'  # Set to PPC IP in /etc/network/interfaces
     self.fpga = casperfpga.katcp_fpga.KatcpFpga(self.ip, timeout=120.)
     self.test_freq = np.array([50.0125]) * 1.0e6
     self.freqs = np.array(
         np.loadtxt('BLASTResonatorPositionsVer2.txt', delimiter=','))
     self.v1.set_frequency(0, 750.0, 0.01)  # LO
     self.LUTbuffer_len = 2**21
     self.dac_freq_res = self.dac_samp_freq / self.LUTbuffer_len
     self.f_base = 300.0
     self.fft_len = 1024
     self.fft_bins = self.fft_bin_index(self.freqs, self.fft_len,
                                        self.dac_samp_freq)
     self.test_bin = self.fft_bin_index(self.test_freq, self.fft_len,
                                        self.dac_samp_freq)
     #self.vi = valonInterface() # If using a valon as DAC/ADC clock and LO, controlled in Linux
     self.main_prompt = '\n\t\033[35mROACHII mKID Readout\033[0m\n\t\033[33mChoose a number from the list and press Enter. 0 - 4 should be followed in order:\033[0m'
     self.main_opts = [
         'Calibrate QDR',
         'Initialize GbE (Must toggle before writing first tone)',
         'Write Test Tone', 'Write DAC, DDS LUTs', 'Stream UDP packets',
         'VNA sweep and plot', 'Locate resonances', 'Target sweep and plot',
         'Exit'
     ]
     #sys.stdout.flush()
     self.dest_ip = 192 * (2**24) + 168 * (2**16) + 41 * (
         2**8) + 1  # Set to FPGA IP in /etc/network/interfaces
     self.fabric_port = 60000
     self.fpga.write_int('tx_destip', self.dest_ip)
     self.fpga.write_int('tx_destport', self.fabric_port)
     self.accum_len = (2**20) - 1
     self.fpga.write_int('sync_accum_len', self.accum_len)
     self.accum_freq = self.fpga_samp_freq / self.accum_len  # FPGA clock freq / accumulation length
     self.UDP_IP = "192.168.41.1"
     self.UDP_PORT = 60000  # Fabric Port
     self.fpga.write_int('fft_shift', 255)
     self.fpga.write_int('rx_ack', 1)
     #self.fpga.write_int('rx_rst', 0)
     self.s = socket(AF_PACKET, SOCK_RAW, htons(3))
     self.s.setsockopt(SOL_SOCKET, SO_RCVBUF, 8192 + 42)
     self.s.bind(('eth2', 3))
     self.fpga.write_int('dds_shift', self.dds_shift)
     self.save_path = '/mnt/iqstream/'
コード例 #3
0
ファイル: reset_synth.py プロジェクト: jack-h/pocketcorr
def reset_synth(tty_addr):
    """
    This function sets the default settings for the synth to use for
    the ROACH pocket correlator running at 200 MHz.

    freq: 200 MHz
    rf_level: 5 dBm
    """
    synth = vs.Synthesizer(tty_addr)
    run_action(synth.set_frequency, vs.SYNTH_A, 200.0)
    run_action(synth.set_frequency, vs.SYNTH_B, 200.0)
    run_action(synth.set_rf_level, vs.SYNTH_A, 5)
    run_action(synth.set_rf_level, vs.SYNTH_B, 5)
    run_action(synth.flash)
    print 'Synthesizer set to output 200 MHz at 5 dBm.'
コード例 #4
0
    def set_valon(self,freq=None):        
        "Configures Valon synth attached to ROACH2 ser2net gateway on port 7148."
        PORT = 7148             # The same port as used by the server 
        socket._socketobject.read = socket._socketobject.recv
        socket._socketobject.write = socket._socketobject.send
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(2)
        s.connect((self.config['roach_ip_str'], PORT))
        
        valon = valon_synth.Synthesizer(s)                
        if freq==None:
            freq=self.config['sample_clk']
        valon.set_frequency(valon_synth.SYNTH_B,freq/1.e6)
        time.sleep(3)
	valon.set_ref_select(0)
	#time.sleep(3)
        s.close()
コード例 #5
0
    def initialize(self):
        #self.upload_fpg()
        self.v1 = valon_synth.Synthesizer('/dev/ttyUSB0')
	self.dest_ip  = 192*(2**24) + 168*(2**16) + 41*(2**8) + 2 # Set to FPGA IP in /etc/network/interfaces
        self.fabric_port= 60000 
        self.fpga.write_int('tx_destip',self.dest_ip)
        self.fpga.write_int('tx_destport',self.fabric_port)
        self.fpga.write_int('sync_accum_len', self.accum_len - 1)
        self.accum_freq = self.fpga_samp_freq / self.accum_len # FPGA clock freq / accumulation length    
        self.fpga.write_int('fft_shift', 2**6 -1)    
        self.fpga.write_int('dds_shift', self.dds_shift)
        #self.save_path = '/mnt/iqstream/'
	self.qdrCal()
	self.lpf(self.zeros)
	self.initialize_GbE()
        print '\n************ QDR Calibrated ************'
        print '************ Packet streaming activated ************\n'
コード例 #6
0
    def read_config_file(self, filename):
        """
        read_config_file(filename)

        Reads the config file 'filename' and loads the values into data
        structures in memory. 'filename' should be a fully qualified
        filename. The config file contains a 'bank' section of interest to
        this bank; in addition, it contains any number of 'MODEX' sections,
        where 'X' is a mode name/number.
        """

        try:
            config = ConfigParser.ConfigParser()
            config.readfp(open(filename))

            if not self.bank_name:
                self.bank_name = self.get_bank_name(config)

                if not self.bank_name:
                    sys.exit(0)

            bank = self.bank_name
            print "bank =", bank, "filename =", filename

            # Read general stuff:
            telescope = config.get(
                'DEFAULTS',
                'telescope').lstrip().rstrip().lstrip('"').rstrip('"')
            self.set_status(TELESCOP=telescope)

            # Read the HPC MAC addresses
            macs = config.items('HPCMACS')
            self.hpc_macs = {}

            for i in macs:
                #key = _ip_string_to_int(_hostname_to_ip(i[0])) & 0xFF
                #self.hpc_macs[key] = int(i[1], 16)
                # Change made due to different python version (At least I think that is the problem). Debugging was done with these lines in ipython - Mark R.
                key = _ip_string_to_int(i[0]) & 0xFF
                self.hpc_macs[key] = int(i[1], 16)

            # Get all bank data and store it. This is needed by any mode
            # where there is 1 ROACH and N Players & HPC programs
            banks = [s for s in config.sections() if 'BANK' in s]

            for bank in banks:
                b = BankData()
                b.load_config(config, bank)
                self.banks[bank] = b

            # Get config info on this bank's ROACH2. Normally there is 1
            # ROACH per Player/HPC node, so this is it.
            self.bank_data = self.banks[self.bank_name]
            self.instance_id = self.bank2inst(
                self.bank_name)  #self.bank_data.instance_id

            # Get config info on all modes
            modes = [s for s in config.sections() if 'MODE' in s]

            for mode in modes:
                m = ModeData()

                try:
                    m.load_config(config, mode)
                except Exception, e:
                    if self.simulate:
                        pass
                    else:
                        raise e

                self.mode_data[mode] = m

        except ConfigParser.NoSectionError as e:
            print str(e)
            return str(e)

        # Now that all the configuration data is loaded, set up some
        # basic things: KATCP, Valon, etc.  Not all backends will
        # have/need katcp & valon, so it config data says no roach &
        # valon, these steps will not happen.
        self.valon = None
        self.roach = None

        if not self.simulate and self.bank_data.has_roach:
            self.roach = katcp_wrapper.FpgaClient(self.bank_data.katcp_ip,
                                                  self.bank_data.katcp_port,
                                                  timeout=30.0)
            time.sleep(
                1
            )  # It takes the KATCP interface a little while to get ready. It's used below
            # by the Valon interface, so we must wait a little.

            # The Valon can be on this host ('local') or on the ROACH
            # ('katcp'), or None. Create accordingly.
            if self.bank_data.synth == 'local':
                import valon_synth
                self.valon = valon_synth.Synthesizer(self.bank_data.synth_port)
            elif self.bank_data.synth == 'katcp':
                from valon_katcp import ValonKATCP
                self.valon = ValonKATCP(self.roach, self.bank_data.synth_port)

            # Valon is now assumed to be working
            if self.valon:
                self.valon.set_ref_select(self.bank_data.synth_ref)
                self.valon.set_reference(self.bank_data.synth_ref_freq)
                self.valon.set_vco_range(0, *self.bank_data.synth_vco_range)
                self.valon.set_rf_level(0, self.bank_data.synth_rf_level)
                self.valon.set_options(0, *self.bank_data.synth_options)

            print "connecting to %s, port %i" % (self.bank_data.katcp_ip,
                                                 self.bank_data.katcp_port)
        print self.bank_data
        return "config file loaded."
コード例 #7
0
import valon_synth
v1 = valon_synth.Synthesizer('/dev/ttyUSB0')
v1.set_frequency(8, 512.0, 0.01)
#v1.set_frequency(0,750.0, 0.01)
コード例 #8
0
    def __init__(self,
                 bw=100e6,
                 chw=97656.25,
                 fft=1024,
                 gain=1000,
                 acc_len=(2**28) / 1024,
                 log_handler=None,
                 ip='146.155.121.6',
                 synth=True,
                 synth_port='/dev/ttyUSB0'):
        """
        Creates an ARCManager object.
        
        :param bw: Detector bandwidth.
        :param chw: Detector channel spacing.
        :param fft: FFT size. must be compatible with the bandwidth and channel spacing.
        :param gain: Gain factor. Each channel amplitude is multiplied by this value.
        :param acc_len: Number of spectra to accumulate in one integration.
        :param log_handler: Log handler used to store error messages.
        :param ip: Ip of the ROACH board. **SRT control room**: 146.155.121.6. **AIUC**:146.155.21.32
        :param synth: True if the syntheziser is connected to a control PC with the USB cable. False otherwise.
        :param synth_port: port where the syntheziser is mounted.
        :type bw: int, float
        :type chw: int, float
        :type fft: int, float
        :type gain: int
        :type acc_len: int
        :type log_handler: Logger object
        :type ip: string
        :type synth: bool
        :type synth_port: string
        """

        # Opens the Valon 5007 dual synth
        # SYNTH_B is the ADC clock, SYNTH_A the LO
        self.synth = synth
        if synth:
            self.synth = vs.Synthesizer(synth_port)

        # Connect to ROACH
        self.ip = ip
        self.log_handler = self._init_log(self.ip)
        self.fpga = self._connect_roach(self.katcp_port)

        # Sets configuration parameters
        self.head = []
        self.fft = fft
        self.bw = bw
        self.set_bw(bw)
        self.num_channel = fft  # to duplicate SHManager
        self.chw = chw
        self.set_chw(chw)
        self.lo_freq = 1370  # LO frequency in MHz
        self.set_LO(self.lo_freq)
        self.fc = 1420 - self.lo_freq
        self.acc_time = 0
        self.acc_len = acc_len
        self.acc_num = 0
        self.tdump = 0
        if self.bw == 50e6:
            self.clck = self.bw / 4.0
        else:
            self.clck = self.bw / 4.0
        self.cdelay = 0
        self.gain = gain

        # Writes firmware configuration to ROACH board
        self.boffile = self._config_to_boffile()
        self._set_bof_file()
        self._set_fft_shift()
        self._set_acc_len(self.acc_len)
        self._reset_firmware()
        self._set_gain(gain)
        self.set_coarse_delay(0, self.cdelay)
        self.set_coarse_delay(1, self.cdelay)

        # Sets io detector parameters
        # Separate real from imag output
        data_date = time.strftime("%Y%m%d-%H%M")
        self.filename_abr = data_date + '_abr'
        self.filename_bar = data_date + '_bar'
        self.filename_abi = data_date + '_abi'
        self.filename_bai = data_date + '_bai'
        self.filename_aa = data_date + '_aa'
        self.filename_bb = data_date + '_bb'
        self.datafile_abr = None
        self.datafile_abi = None
        self.datafile_bar = None
        self.datafile_bai = None
        self.datafile_aa = None
        self.datafile_bb = None
        self.amp_ab = numpy.empty(self.fft)
        self.amp_ba = numpy.empty(self.fft)
        self.amp_a = numpy.empty(self.fft)
        self.amp_b = numpy.empty(self.fft)
コード例 #9
0
ファイル: arcpy.py プロジェクト: ryan-leung/acs-ari
    def __init__(self,
                 bw=100e6,
                 chw=97656.25,
                 fft=1024,
                 gain=1000,
                 acc_len=2**28 / 1024,
                 log_handler=None,
                 ip=arcp.roach_ip,
                 synth=True):
        """
        @param bw: Detector bandwidth
        @param chw: detector channel spacing
        @param fft: fft size. must be compatible with bandwidth 
                    and channel spacing.
        @param gain: gain factor to multiply channel amplitudes
        @param acc_len: number of spectra to accumulate in one integration.
        @param log_handler: log handler used to store error messages.
        @param ip: ip of the ROACH board. 
                   SRT control room:146.155.121.6
                   AIUC:146.155.21.32
        @param synth: True if the syntheziser is connected to a control PC
                      with the USB cable. False otherwise.
        """

        # Opens the Valon 5007 dual synth
        # SYNTH_B is the ADC clock, SYNTH_A the LO
        self.synth = synth
        if synth:
            self.synth = vs.Synthesizer(arcp.synth_port)

        # Connect to ROACH
        self.ip = ip
        self.log_handler = self._init_log(self.ip)
        self.fpga = self._connect_roach(arcp.katcp_port)

        # Sets configuration parameters while checking some
        self.head = []
        self.fft = fft
        self.bw = bw
        self.set_bw(bw)
        self.num_channel = fft  # to duplicate SHManager
        self.chw = chw
        self.set_chw(chw)
        self.lo_freq = 1370  # LO frequency in MHz
        self.set_LO(self.lo_freq)
        self.fc = 1420 - self.lo_freq
        self.acc_time = 0
        self.acc_len = acc_len
        self.acc_num = 0
        self.tdump = 0
        self.clck = self.bw / 4.0
        self.cdelay = 0
        self.gain = gain

        # Writes firmware configuration to ROACH board
        self.boffile = self._config_to_boffile()
        self._set_bof_file()
        self._reset_firmware()
        self._set_fft_shift()
        self._set_acc_len(self.acc_len)
        self._set_gain(gain)
        self.set_coarse_delay(0, self.cdelay)
        self.set_coarse_delay(1, self.cdelay)

        # Sets io detector parameters
        # Separate real from imag output
        self.filename_abr = 'default_abr'
        self.filename_bar = 'default_bar'
        self.filename_abi = 'default_abi'
        self.filename_bai = 'default_bai'
        self.filename_aa = 'default_aa'
        self.filename_bb = 'default_bb'
        self.datafile_abr = None
        self.datafile_abi = None
        self.datafile_bar = None
        self.datafile_bai = None
        self.datafile_aa = None
        self.datafile_bb = None
        self.amp_ab = numpy.empty(self.fft)
        self.amp_ba = numpy.empty(self.fft)
        self.amp_a = numpy.empty(self.fft)
        self.amp_b = numpy.empty(self.fft)
コード例 #10
0
    else:
        print 'Invalid input for power Up/Down, should be either 0 or 1.'
        sys.exit(0)
    data = struct.pack('>BIIIIII', 0x00 | label, reg0, reg1, reg2, reg3, reg4,
                       reg5)
    checksum = _generate_checksum(data)
    conn.write(data + checksum)
    conn.close()


#==================================================
if __name__ == '__main__':
    # opening the serial port
    port = VSerialPort()
    # connecting the synthesizer to serial port
    synth = v.Synthesizer(port)

    # display current v5007 settings
    display_settings(synth)

    chg = raw_input("Do you want to change the settings of V5007? (y/n):")
    if chg.lower() == 'y':
        chg_syn1 = raw_input(
            "Do you want to change the settings of Synthesizer 1? (y/n): ")
        if chg_syn1.lower() == 'y':
            print('Configuring Synthesizer 1')
            phase_lock = synth.get_pahse_lock(8)
            if phase_lock:
                powerdown = raw_input(
                    "Do you want to power down Synthesizer 1 ? (y/n): ")
                if powerdown.lower() == 'y':
コード例 #11
0
o.add_option('-p',
             action="store_false",
             default=True,
             help='Command to print existing settings')
opts, args = o.parse_args()

# All functions from valon_synth return booleans for success/failure (true/false)

# Read in USB port number in format '/dev/ttyUSB#'
# '#' is port number found from issuing dmesg after pluggin in USB
# Device will be recorded as FTDI chip in dmesg | tail -1 (last line)
# FTDI device frequents to port 0 (may not always be the same)
loc = '/dev/ttyUSB0'

# Declare synthesizer object for communication
mySynth = vs.Synthesizer(loc)

# 0 = SYNTH_A, 8 = SYNTH_B
aFreq = mySynth.get_frequency(0)
bFreq = mySynth.get_frequency(8)
aRF = mySynth.get_rf_level(0)
bRF = mySynth.get_rf_level(8)

# If no options passed, print existing values
if not opts.p is True:
    print "\nSYNTH_A, SYNTH_B:"
    print "Frequency: %0.4f, %0.4f" % (aFreq, bFreq)
    print "RF Level: %d, %d\n" % (aRF, bRF)
# Modify values if
else:
    if not opts.freq is None:
コード例 #12
0
        sys.exit(1)

if opt.configxml:
    opt.default = 'True'

if socket.gethostname() == MASTER:
    try:
        obsbw = update_list['OBSBW']
    except:  # Default value
        obsbw = 512.

    try:
        b = Status(log, 1)
        valon_port = '/dev/ttyUSB0'
        if obsbw != b['OBSBW'] * (b['N_DS'] * b['N_GPU']):
            log.info('Changing Valon on %s frequency to %.1f MHz' %
                     (valon_port, obsbw * 2.0))
            valon = valon_synth.Synthesizer(valon_port)
            valon.set_frequency(0, obsbw * 2.0, chan_spacing=1.0)
            valon.set_frequency(8, obsbw * 2.0, chan_spacing=1.0)
            opt.reload = True
    except:
        pass

# Create and init status shm
for i in range(N_GPU):
    log.info('Create status shm')
    b = Status(log, i + 1)

    fill_status_shm(opt, log, b, update_list, i)
コード例 #13
0
ファイル: Menu.py プロジェクト: Chuneeta/valon5007
    def initialize(self):
        #---Connection Status---
        try:
            # opening the serial port
            port = self.VSerialPort()
            # connecting the synthesizer to serial port
            self.synth = v.Synthesizer(port)
            connection = 'Connected'
            connect = True
        except:
            connection = 'Not Connected'
            connect = False
            print 'Unable to establish connection with the serial port'

        label = Tkinter.Label(self,
                              text='Connection Status',
                              font="times 15 bold",
                              bg='ivory').place(x=360, y=210)
        label = Tkinter.Label(self,
                              text=connection,
                              font="times 15 bold",
                              bg='deeppink',
                              borderwidth=3,
                              relief="raised",
                              width=15).place(x=380, y=240)

        #---Header Labels---
        label = Tkinter.Label(self,
                              text='5007 Dual Synthesizer',
                              font=('Comic Sans MS', 22, 'bold'),
                              borderwidth=4,
                              bg='ivory',
                              fg='red').place(x=8, y=5)

        self.lck_label = Tkinter.Label(self,
                                       text='Unknown',
                                       font="times 15 bold",
                                       bg='gray',
                                       borderwidth=3,
                                       relief='sunken')
        self.lck_label.place(x=405, y=180)

        self.option = Tkinter.IntVar()
        self.option.trace("w", self.update_synth)
        self.freqvalue1 = Tkinter.DoubleVar()
        self.freqvalue2 = Tkinter.DoubleVar()
        self.freqvalue3 = Tkinter.DoubleVar()
        self.freqvalue4 = Tkinter.DoubleVar()
        self.clockOpt = Tkinter.IntVar()
        self.selectedRF = Tkinter.StringVar()

        #---VCO Settings---
        def noise_enabled():
            if self.noisebutton.config('text')[-1] == 'Low Noise Enabled':
                self.synth.set_options(self.synth_val,
                                       double=0,
                                       half=0,
                                       divider=1,
                                       low_spur=0)
                self.noisebutton.config(text='Low PLL Spurs')
            else:
                self.synth.set_options(self.synth_val,
                                       double=0,
                                       half=0,
                                       divider=1,
                                       low_spur=1)
                self.noisebutton.config(text='Low Noise Enabled')

        def buffer_enabled():
            if self.powerbutton.config('text')[-1] == 'Double Buffer Enabled':
                self.synth.set_options(self.synth_val,
                                       double=1,
                                       half=0,
                                       divider=1,
                                       low_spur=0)
                self.bufferbutton.config(text='Half Buffer Enabled')
            else:
                self.synth.set_options(self.synth_val,
                                       double=0,
                                       half=0,
                                       divider=1,
                                       low_spur=0)
                self.bufferbutton.config(text='Double Buffer Enabled')

        def power_enabled():
            if self.powerbutton.config('text')[-1] == 'VCO Power Down':
                self.powerDown(switch='off')
                self.powerbutton.config(text='VCO Power Up')
                self.lck_label.config(text='Unlocked')
                self.lck_label.config(bg='pink')
            else:
                self.powerbutton.config(text='VCO Power Down')
                self.powerDown(switch='on')
                self.lck_label.config(text='Locked')
                self.lck_label.config(bg='pink')

        label = Tkinter.Label(self,
                              text='VCO Settings',
                              font="times 15 bold",
                              bg='ivory').place(x=360, y=50)
        self.powerbutton = Tkinter.Button(self,
                                          text='VCO Power Down',
                                          highlightcolor='cyan',
                                          width=15,
                                          borderwidth=3,
                                          relief='raised',
                                          command=power_enabled)
        self.powerbutton.place(x=360, y=80)
        label = Tkinter.Label(self,
                              text='VCO Lock Status',
                              font="times 15 bold",
                              bg='ivory',
                              borderwidth=3).place(x=360, y=150)

        #---Synthesizers---
        radiobutton1 = Tkinter.Radiobutton(self,
                                           text='Synthesizer 1',
                                           bg='ivory',
                                           value=0,
                                           variable=self.option).place(x=300,
                                                                       y=15)
        radiobutton2 = Tkinter.Radiobutton(self,
                                           text='Synthesizer 2',
                                           bg='ivory',
                                           value=8,
                                           variable=self.option).place(x=420,
                                                                       y=15)
        self.option.set(8)

        #---Frequency Settings---
        label = Tkinter.Label(self,
                              text='Frequency Settings',
                              font="times 15 bold",
                              bg='ivory').place(x=10, y=50)
        label = Tkinter.Label(self, text='Desired Frequency',
                              bg='ivory').place(x=10, y=80)
        label = Tkinter.Label(self, text='Reference Frequency',
                              bg='ivory').place(x=10, y=110)
        label = Tkinter.Label(self, text='Minimum Frequency',
                              bg='ivory').place(x=10, y=140)
        label = Tkinter.Label(self, text='Maximum Frequency',
                              bg='ivory').place(x=10, y=170)

        label = Tkinter.Label(self, text='MHz', bg='ivory').place(x=280, y=80)
        label = Tkinter.Label(self, text='MHz', bg='ivory').place(x=280, y=110)
        label = Tkinter.Label(self, text='MHz', bg='ivory').place(x=280, y=140)
        label = Tkinter.Label(self, text='MHz', bg='ivory').place(x=280, y=170)

        entry1 = Tkinter.Spinbox(width=10,
                                 to=4400,
                                 from_=137.5,
                                 bg='lightgreen',
                                 borderwidth=3,
                                 textvariable=self.freqvalue1).place(x=160,
                                                                     y=80)
        entry2 = Tkinter.Spinbox(width=10,
                                 to=4400,
                                 from_=0,
                                 bg='lightgreen',
                                 borderwidth=3,
                                 textvariable=self.freqvalue2).place(x=160,
                                                                     y=110)
        entry3 = Tkinter.Spinbox(width=10,
                                 to=4400,
                                 from_=137.5,
                                 bg='lightgreen',
                                 borderwidth=3,
                                 textvariable=self.freqvalue3).place(x=160,
                                                                     y=140)
        entry4 = Tkinter.Spinbox(width=10,
                                 to=4400,
                                 from_=137.5,
                                 bg='lightgreen',
                                 borderwidth=3,
                                 textvariable=self.freqvalue4).place(x=160,
                                                                     y=170)

        #---Clock Settings---
        self.clockOpt.trace("w", self.conf)
        label = Tkinter.Label(self,
                              text='Clock Settings',
                              font="times 15 bold",
                              bg='ivory').place(x=10, y=220)

        radiobutton1 = Tkinter.Radiobutton(self,
                                           text='Internal',
                                           height=1,
                                           bg='ivory',
                                           value=0,
                                           variable=self.clockOpt).place(x=14,
                                                                         y=250)
        radiobutton2 = Tkinter.Radiobutton(self,
                                           text='External',
                                           height=1,
                                           bg='ivory',
                                           value=1,
                                           variable=self.clockOpt).place(x=14,
                                                                         y=280)

        #---Power Level---
        label = Tkinter.Label(self,
                              text="Output Power",
                              font="times 15 bold",
                              bg='ivory').place(x=150, y=220)

        values = ['Level -4', 'Level -1', 'Level 2', 'Level 5']
        entry = Tkinter.OptionMenu(self, self.selectedRF, *values)
        entry.place(x=170, y=250)
        entry['width'] = 15
        entry['bg'] = 'ivory'

        #---Display/Save/Quit Button---
        button = Tkinter.Button(self,
                                text='Display',
                                bg='gray',
                                command=self.display).place(x=160, y=310)
        button = Tkinter.Button(self,
                                text='Save',
                                bg='gray',
                                command=self.save).place(x=250, y=310)
        button = Tkinter.Button(self,
                                text='Quit',
                                bg='gray',
                                command=self.quit).place(x=330, y=310)

        #---Firmware Verson---
        #label = Tkinter.Label(self,text='Firmware version',font="times 15 bold",bg='ivory').place(x=360,y=240)
        #label = Tkinter.Label(self,text='1.0.0',font="times 15 bold",bg='gray',width=7,relief='solid').place(x=415,y=270)

        #---Reset Button---
        def reset():
            import os, sys
            os.system('python reset.py')

        button = Tkinter.Button(self,
                                text='Reset',
                                bg='gray',
                                width=15,
                                command=reset).place(x=360, y=110)
コード例 #14
0
import valon_synth
import time

a=valon_synth.Synthesizer('/dev/ttyUSB1')

for i in range(1,200):
				freq=190+i*0.1
				b=a.set_frequency(8,freq)
				print b,freq
				time.sleep(0.1)