def turn_off_RF(self):
        """Override method that will turn off the RF device output.

        This device does not have the ability to turn off teh RF source.
        Instead it is turned down to the lowest level."""

        itechbl12hi_common.turn_rf_off(self.tn, timeout=self.timeout)
    def turn_on_RF(self):
        """Override method that will turn on the RF device output.

        Set the level to the requested power.
        This hardware does not have the ability to turn the RF source on and off."""
        itechbl12hi_common.turn_rf_on(self.tn,
                                      timeout=self.timeout,
                                      Output_Power=self.Output_Power)
    def set_frequency(self, frequency):
        """Override method that will set the output frequency.
        
        SCPI command "FREQ" is used to set the output frequency level. 
        
        Args:
            frequency (float): Desired value of the output frequency in MHz.
        Returns:
            float: The current frequency value as a float and assumed units. 
            str: The current output frequency concatenated with the units.
        """
        # check the input is a numeric
        if type(frequency) != float and type(frequency) != int \
                and np.float64 != np.dtype(frequency) and np.int64 != np.dtype(frequency):
            raise TypeError('Frequency value is not a float or int')
        # check the output is a positive number
        elif frequency < 0:
            raise ValueError('Frequency value is < 0')

        self.Frequency = frequency
        f_str = str(frequency).replace('.', ',')
        if len(f_str) == 6:
            # Adding the truncated 0
            f_str = f_str + '0'
        freq_str = ''.join(("FREQ:RF " + f_str))
        # Write the frequency value in MHz
        ret, check = itechbl12hi_common.telnet_query(self.tn, self.timeout,
                                                     freq_str)
        return check
    def set_output_power(self, power):
        """Override method that will set the output power.
        
        The SCPI command "UNIT:POW" is used to set the units of the power output, then the 
        command "LEV" is used to set the output level in those units. 

        Args:
            power (float): Desired value of the output power in dBm.  
        Returns:
            float: The current power value as a float in dBm
            str: The current output power concatenated with the units. 
        """
        # check the input is a numeric
        if type(power) != float and type(power) != int \
                and np.float64 != np.dtype(power) and np.int64 != np.dtype(power):
            raise TypeError('Power value is not numeric')
        elif power > self.limit:  # If a value that is too high is used, the hardware may break.
            power = self.limit
            # tell the user the limit has been reached and cap the output level
            warnings.warn(
                'Power limit has been reached, output will be capped')
        elif power < -50:
            power = -50
            warnings.warn('Power level is too low setting to -50 dBm')
        self.Output_Power = np.round(power)
        #  print 'Power = ', self.Output_Power
        # write the new output power
        ret, check = itechbl12hi_common.telnet_query(
            self.tn, self.timeout, "POW:RF " + str(self.Output_Power))
        return check
예제 #5
0
    def get_modulation_state(self):
        """Override method, Checks if the pulse modulation is on or off

        Args: 

        Returns:

        """
        modulation, check = itechbl12hi_common.telnet_query(
            self.tn, self.timeout, "GATE:FILL?")  # Checks the modulation state
        if modulation == "100 %":
            modulation_state = False  # If it isn't, return a False
        else:
            modulation_state = True  # If it is, return a True
        return modulation_state
    def get_frequency(self):
        """Override method that will get the output frequency of the SigGen
        
        Uses the SCPI command "FREQ?" to get the set frequency. 
        
        Args:
        
        Returns:
            float: The current frequency value as a float and assumed units. 
            str: The current output frequency concatenated with the units.
        """

        self.Frequency, check = itechbl12hi_common.telnet_query(
            self.tn, self.timeout, "FREQ:RF?")  # get the device frequency
        return float(self.Frequency.replace(',', '.')[0:-4]), self.Frequency
 def get_output_power(self):
     """Override method that will return the output power.
     
     Uses the "command POW:RF?"  to get the current output power level and units.
     
     Args:
     
     Returns:
         float: The current power value as a float in dBm
         str: The current output power concatenated with the units.
     """
     self.Output_Power = itechbl12hi_common.telnet_query(
         self.tn, self.timeout, "POW:RF?")
     return float(self._split_num_char(
         self.Output_Power)[0]), self.Output_Power
예제 #8
0
    def get_pulse_period(self):
        """Override method, Gets the total pulse period of the modulation signal

        Args: 

        Returns:
            float: The pulse period in float form
            str: The units that the pulse period is measured in 

        """
        m_clk, check = itechbl12hi_common.telnet_query(self.tn, self.timeout,
                                                       "FREQ:MC?")
        m_num = m_clk[0:-4]
        m_num2 = float(m_num.replace(',', '.'))  # MHz
        self.pulse_period = 1. / m_num2  # Gets the pulse period of the device
        # Returns the pulse period as a float, and a string with the units
        return self.pulse_period, "us"
예제 #9
0
    def get_pulse_dutycycle(self):
        """Override method, Gets the duty cycle of the modulation signal

        The duty cycle of the signal will be set as a decimal of the pulse period.
        If the pulse period is 100us and the duty cycle input is 0.3, the pulse that 
        modulates the RF will be on for 30us, then off for 70us, then repeat. This 
        will return the decimal value.

         Args: 

         Returns:
             float: decimal value (0-1) of the duty cycle of the pulse modulation
         """
        fill, check = itechbl12hi_common.telnet_query(
            self.tn, self.timeout,
            "GATE:FILL?")  # calculates the duty cycle and returns it
        g_fill = float(fill[0:-2])
        return g_fill / 100.
    def get_output_state(self):
        """Override method that will get the current output state.

        This method send the SCPI command "POW:RF?" to request the output state from
        the ITechBL12HI.

        Args:

        Returns:
            bool: Returns True if the output is enabled, False if it is not.
        """
        # checks output state
        ret, check = itechbl12hi_common.telnet_query(self.tn, self.timeout,
                                                     "POW:RF?")
        if "-50" in ret:
            self.Output_State = False  # output must be off
            return False
        else:
            self.Output_State = True  # output must be on
            return True
예제 #11
0
    def turn_off_modulation(self):
        """Override method, Turns on the pulse modulation.

        This function will turn off the modulation of the RF output 
        The RF output must turned off/on independently.

        Args: 

        Returns:

        """
        # Turns off the modulation state output
        ret, check = itechbl12hi_common.telnet_query(
            tn=self.tn, timeout=self.timeout, orig_message="GATE:FILL 100")
        if 'OK' in check:
            self.modulation_state = False
        else:
            self.modulation_state = None
            raise IOError("Gate modulation in unknown state")

        return self.modulation_state
예제 #12
0
    def set_pulse_dutycycle(self, dutycycle):
        """Override method, Gets the duty cycle of the modulation signal

        The duty cycle of the signal will be set as a decimal (0 - 1). This
        will return the decimal value.

        Args: 
            dutycycle (float): decimal value of the duty cycle (0-1) for the pulse modulation
        Returns:
            float: decimal value (0-1) of the duty cycle of the pulse modulation 
        """
        # makes sure the duty cycle value is a numeric
        if type(dutycycle) != float and type(
                dutycycle) != int and np.float64 != np.dtype(dutycycle):
            raise TypeError('Duty cycle is not numeric')
        # makes sure the duty cycle value is a decimal between 0 and 1
        elif dutycycle > 1 or dutycycle < 0:
            raise ValueError('Duty cycle is >1 or < 0')
        duty_str = "GATE:FILL " + str(int(np.round(dutycycle * 100))) + '\r\n'
        # writes the calculated pulse width
        ret, check = itechbl12hi_common.telnet_query(self.tn, self.timeout,
                                                     duty_str)
        return check
    def __init__(self, ipaddress, port=5555, timeout=1, limit=-20):
        """Initialises and opens the connection to the ITechBL12HI over telnet and informs the user 

        Args:
            ipaddress (str): The IP address of the ITechBL12HI 
            port (int/str): The port number for the messages to be sent on (default 5555)
            timeout (float): The timeout for telnet commands in seconds (default 1)
            
        Returns:
            
        """
        self.timeout = timeout  # timeout for the telnet comms
        self.ipaddress = ipaddress
        self.port = port
        self.tn = itechbl12hi_common.telnet_setup(ipaddress, port, timeout)
        self.device_id = self.get_device_id(
        )  # gets the device of the telnet device, makes sure its the right one
        self.turn_off_RF()  # turn off the RF output
        self.limit = limit  # set the RF output limit
        # self.set_output_power_limit(limit)  # set the RF output limit

        print(
            "Opened connection to RF source " +
            self.device_id)  # tells the user the device has been connected to
 def get_device_id(self):
     """Override method that will return the device ID."""
     return itechbl12hi_common.get_device_identity(self.tn,
                                                   timeout=self.timeout)