def __init__(self, port='/dev/ttyS0'): Pyro.core.ObjBase.__init__(self) self.valon = Synthesizer(port) self.vs = vegas_status() self.dbuf2 = vegas_databuf(2) self.dbuf3 = vegas_databuf(3) self.running = True
class VegasServer(Pyro.core.ObjBase): def __init__(self,port='/dev/ttyS0'): Pyro.core.ObjBase.__init__(self) self.valon = Synthesizer(port) # get instance_id somehow self.vs = vegas_status(instance_id) self.dbuf2 = vegas_databuf(2) self.dbuf3 = vegas_databuf(3) self.running = True def getTime(self): return time.time() def getSynthRefFreq(self): return self.valon.get_reference() def setSynthFreq(self,freq,chan_spacing=2.0): resA = self.valon.set_frequency(SYNTH_A,freq,chan_spacing=chan_spacing) resB = self.valon.set_frequency(SYNTH_B,freq,chan_spacing=chan_spacing) return resA,resB def getSynthFreq(self): fA = self.valon.get_frequency(SYNTH_A) fB = self.valon.get_frequency(SYNTH_B) return fA,fB def getSynthLocked(self): resA = self.valon.get_phase_lock(SYNTH_A) resB = self.valon.get_phase_lock(SYNTH_B) return resA,resB def initShmem(self): pass def setParams(self,**kwargs): self.vs.read() for k,v in kwargs.items(): self.vs.update(k,v) self.vs.write() def getParam(self,param=None): self.vs.read() if param: return {param:self.vs[param]} else: return dict(self.vs.items()) def updateFromGBT(self): self.vs.read() self.vs.update_with_gbtstatus() self.vs.write() def getData(self,block=0,buf=2): if buf == 2: return self.dbuf2.data(block) else: return self.dbuf3.data(block) def quit(self): self.running = False
def __init__(self): Pyro.core.ObjBase.__init__(self) try: Synthesizer.__init__(self,config.serialPortMap['Valon']) except: corelog.exception("Couldn't open Valon serial port") return self.conn.setTimeout(1) self.setup()
def __init__(self,port='/dev/ttyS0'): Pyro.core.ObjBase.__init__(self) self.valon = Synthesizer(port) self.vs = vegas_status() self.dbuf2 = vegas_databuf(2) self.dbuf3 = vegas_databuf(3) self.running = True
class VegasServer(Pyro.core.ObjBase): def __init__(self, port='/dev/ttyS0'): Pyro.core.ObjBase.__init__(self) self.valon = Synthesizer(port) # get instance_id somehow self.vs = vegas_status(instance_id) self.dbuf2 = vegas_databuf(2) self.dbuf3 = vegas_databuf(3) self.running = True def getTime(self): return time.time() def getSynthRefFreq(self): return self.valon.get_reference() def setSynthFreq(self, freq, chan_spacing=2.0): resA = self.valon.set_frequency(SYNTH_A, freq, chan_spacing=chan_spacing) resB = self.valon.set_frequency(SYNTH_B, freq, chan_spacing=chan_spacing) return resA, resB def getSynthFreq(self): fA = self.valon.get_frequency(SYNTH_A) fB = self.valon.get_frequency(SYNTH_B) return fA, fB def getSynthLocked(self): resA = self.valon.get_phase_lock(SYNTH_A) resB = self.valon.get_phase_lock(SYNTH_B) return resA, resB def initShmem(self): pass def setParams(self, **kwargs): self.vs.read() for k, v in kwargs.items(): self.vs.update(k, v) self.vs.write() def getParam(self, param=None): self.vs.read() if param: return {param: self.vs[param]} else: return dict(self.vs.items()) def updateFromGBT(self): self.vs.read() self.vs.update_with_gbtstatus() self.vs.write() def getData(self, block=0, buf=2): if buf == 2: return self.dbuf2.data(block) else: return self.dbuf3.data(block) def quit(self): self.running = False
parser.add_option("--save", action="store_true", dest="save", default=False, help="Save configuration on internal flash memory") parser.add_option("--channel", action="store", dest="channel", default="A", help="Synth Channel (def: 'A')") (options, args) = parser.parse_args() try: sync = Sync("/dev/ttyUSB0") print "\nSuccessfully connected to the Valon Synthesizer on port /dev/ttyUSB0\n" except: print "\nCannot connect to the Valon Synthesizer on port /dev/ttyUSB0\n" exit(0) if not options.freq == 0: if options.channel.upper() == "A": print "Setting Synth A to " + str(options.freq) + " MHz" sync.set_frequency(SYNTH_A, int(options.freq)) else: print "Setting Synth B to " + str(options.freq) + " MHz" sync.set_frequency(SYNTH_B, int(options.freq)) if options.reference == "external": sync.set_ref_select(EXT_REF)
#!/bin/env python import sys import argparse from valon_synth import Synthesizer, SYNTH_A, SYNTH_B parser = argparse.ArgumentParser( description='Get Frequency of Valon Synthesizer') parser.add_argument('dev', help='The device file of Valon, usally /dev/ttyUSBn') opts = parser.parse_args() syn = Synthesizer(opts.dev) print('A: %f %d' % (syn.get_frequency(SYNTH_A), syn.get_rf_level(SYNTH_A))) print('B: %f %d' % (syn.get_frequency(SYNTH_B), syn.get_rf_level(SYNTH_B)))
type=int, choices=[-4, -1, 2, 5], help='RF output level in dBm') parser.add_argument('-s', '--store', action='store_true') opts = parser.parse_args() if _VERBOSE: print('Device: ' + opts.dev) print('Port: ' + opts.port) print('Frequency: %dMHz' % opts.freq) print('Out level: %ddBm' % opts.level) if opts.port == 'A': synth = SYNTH_A else: synth = SYNTH_B syn = Synthesizer(opts.dev) syn.set_frequency(synth, opts.freq) print(syn.get_frequency(synth)) if opts.level != None: syn.set_rf_level(synth, opts.level) print(syn.get_rf_level(synth)) if opts.store: print('Storing into flash memory ... '), syn.flash() print('Done.')
def __init__(self, synth, port, restore=False): try: Synthesizer.__init__(self, port) except valon_synth.serial.SerialException as err: raise RuntimeError("Unable to open serial port.\nError MSG:\n%s" % err) except: raise # Add usage instructions for parent call functions self.get_vco_range.__func__.__doc__ = "\ \nReturn the minimum and maximum frequency range of the selected synthesizer VCO. \ \nThe VCO Frequency Range information is used to limit and check the resulting VCO output frequency, \ \nentered in the set frequency request function. \ \n\t@param synth String: Synthesizer name \ \n\t@return List: (lowest VCO output frequency, highest VCO output frequency) in MHz \ \n" self.set_vco_range.__func__.__doc__ = "\ \nSet the minimum and maximum frequency range of the selected synthesizer VCO. \ \n\t@param synth String: Synthesizer name \ \n\t@param min Int: The lowest VCO output frequency (MHz) that may be set \ \n\t@param max Int: The highest VCO output frequency (MHz) that may be set \ \n\t@return Boolean: Reply message indicating success. \ \n" self.get_frequency.__func__.__doc__ = "\ \nReturn the current VCO output frequency for the selected synthesizer. \ \n\t@param synth String: Synthesizer name \ \n\t@return Float: Synthesizer output frequency (MHz) \ \n" self.set_frequency.__func__.__doc__ = "\ \nRequest to set the desired frequency (MHz) for the selected synthesizer. \ \nThis is will cause the registers synthesizer to be updated and the new frequency generated. \ \nThe resulting output frequency must be within the range specified in the frequency range. \ \n\t@param synth String: Synthesizer name \ \n\t@param freq Int: Desired frequency (MHz) \ \n\t@param chan_spacing Float: Frequency Increment (KHz) to set required output frequency resolution \ \n\t@return Boolean: Reply message indicating success. \ \n" self.get_reference.__func__.__doc__ = "\ \nRequest the input frequency of the reference oscillator. \ \n\t@param No input parameters \ \n\t@return Int: Reference input frequency (Hz) \ \n" self.set_reference.__func__.__doc__ = "\ \nSet the input frequency of the reference oscillator. \ \nThis value must be between 5 MHz and 150 MHz according to the 5007 datasheet. \ \n\t@param freq Int: Reference input frequency (Hz) \ \n\t@return Boolean: Reply message indicating success. \ \n" self.get_rf_level.__func__.__doc__ = "\ \nReturns the current output power level: -4, -1, 2, 5 \ \n\t@param synth String: Synthesizer name \ \n\t@return Int: Ouput power level \ \n" self.set_rf_level.__func__.__doc__ = "\ \nAllows user to select one of four output power levels: -4, -1, 2, 5 \ \nThese levels corresponds approximately to some preset output power. \ \n\t@param synth String: Synthesizer name \ \n\t@param rf_level Int: Ouput power level \ \n\t@return Boolean: Reply message indicating success. \ \n" self.get_ref_select.__func__.__doc__ = "\ \nReturns the currently selected reference clock. \ \n\t@param No input parameters \ \n\t@return Int: 1 for external reference and 0 otherwise \ \n" self.set_ref_select.__func__.__doc__ = "\ \nSelects either internal or external reference clock. \ \n\t@parameter e_not_i Int: 1 for external reference and 0 for internal reference \ \n\t@return Boolean: Reply message indicating success. \ \n" self.get_label.__func__.__doc__ = "\ \nRead the assigned synthesizer name. \ \n\t@param synth String: Synthesizer name \ \n\t@return String: Assigned synthesizer name \ \n" self.set_label.__func__.__doc__ = "\ \nLabel the selected synthesizer to suit your application, if desired. \ \nThe maximum length of a name is 16 characters. \ \n\t@param synth String: Synthesizer name \ \n\t@param label String: Synthesizer alias to assign\ \n\t@return Boolean: Reply message indicating success. \ \n" self.get_phase_lock.__func__.__doc__ = " \ \n Return the VCO lock status of the selected synthesizer. \ \n\t@param synth String: Synthesizer name \ \n\t@return Boolean: Reply message indicating VCO lock status. \ \n" self.flash.__func__.__doc__ = "\ \nWrite setup parameters to non-volatile flash memory in the microcontroller board. \ \nThe next time the board is powered up, the registers will be set to the values in the non-volatile flash memory. \ \nIf the board is powered down before the write flash command command is issued, all the data in the registers will be lost. \ \n\t@param No input parameters \ \n\t@return Boolean: Reply message indicating parameters written to flash. \ \n" self.get_options.__func__.__doc__ = "\ \nOptional VCO Settings \ \n\tprint synth.get_options(valon_synth.SYNTH_B) \ \nOutput a list of 4 parameters, which can be 0 (disabled) or 1(enabled) \ \ndouble: The reference doubler is used to enable a multiply by 2 function before the internal reference divider. \ \n\tEnable the doubler when using a 5 MHz external reference frequency. \ \n\tWhen using the internal 10 MHz reference the doubler should be disabled. \ \nhalf: The reference divide by 2 is used to enable a divide by 2 function after the intercal reference divider. \ \n\tWhen enabled, the input to phase-frequency detector will have a 50% duty cycle which will allow for faster lock up time. \ \n\tIn order to use this mode a 20 MHz external reference would have to be available. \ \n\tFor normal operations set the reference div by 2 to disabled. \ \nr: ?? \ \nspur: Low noise mode vs Low spur mode. \ \n\tLow noise mode affects the operation of the fractional synthesizer, \ \n\tand this mode will produce the lowest phase noise but there may be some spurious output signals. \ \n\tLow spur mode will reduce spurious output response but the overall phase noise will be higher. \ \n" self.set_options.__func__.__doc__ = "\ \nOptional VCO Settings for a specified synthesizer \ \nOutput a list of 4 parameters, which can be 0 (disabled) or 1(enabled) \ \ndouble: The reference doubler is used to enable a multiply by 2 function before the internal reference divider. \ \n\tEnable the doubler when using a 5 MHz external reference frequency. \ \n\tWhen using the internal 10 MHz reference the doubler should be disabled. \ \nhalf: The reference divide by 2 is used to enable a divide by 2 function after the intercal reference divider. \ \n\tWhen enabled, the input to phase-frequency detector will have a 50% duty cycle which will allow for faster lock up time. \ \n\tIn order to use this mode a 20 MHz external reference would have to be available. \ \n\tFor normal operations set the reference div by 2 to disabled. \ \nr: ?? \ \nspur: Low noise mode vs Low spur mode. \ \n\tLow noise mode affects the operation of the fractional synthesizer, \ \n\tand this mode will produce the lowest phase noise but there may be some spurious output signals. \ \n\tLow spur mode will reduce spurious output response but the overall phase noise will be higher. \ \n" if not restore: ## Set valon to use internal reference clock if self.get_ref_select() == "1": self.set_rf_select(e_not_i=0) ## Set frequency to 2.4 GHz self.set_frequency(synth, freq=2465) ## Set rf level to be minimum available self.set_rf_level(synth, -4) self.synth = synth