Пример #1
0
 def set_frequency(self, channel, freq):
     """
     Sets frequency on the selected channel.
     
     Command examples:        
         WMF00000000000001 equals 1 uHz on channel 1
         WMF00000001000000 equals 1 Hz on channel 1
         WMF00001000000000 equals 1 kHz on channel 1
         WFF00000000000001 equals 1 uHz on channel 2
         and so on.
     """
     
     if channel is not None and channel not in CHANNELS:
         raise UnknownChannelError(CHANNELS_ERROR)
     
     freq_str = "%.2f" % freq
     freq_str = freq_str.replace(".", "")
     freq_str = freq_str + "0000"
    
     # Channel 1
     if channel in (0, 1) or channel is None:
         cmd = "WMF%s" % freq_str
         self.send_command(cmd)
     
     # Channel 2
     if channel in (0, 2) :
         cmd = "WFF%s" % freq_str
         self.send_command(cmd)
Пример #2
0
    def enable_output(self, channel=None, on=False):
        """
        Turns channels output on or off.
        The channel is defined by channel variable. If channel is None, both channels are set.
        
        Commands:        
            WMN1 means main wave output set to on
            WMN0 means main wave output set to off
            WFN1 means second channel wave output set to on
            WFN0 means second channel wave output set to off

        Separate commands are thus needed to set the channels for the FY6600.
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)
        
        if channel is not None and channel != 0:
            self.channel_on[channel-1] = on
        else:
            self.channel_on = [on, on]
        
        ch1 = "1" if self.channel_on[0] == True else "0"
        ch2 = "1" if self.channel_on[1] == True else "0"
        
        # The fy6600 uses separate commands to enable each channel.
        cmd = "WMN%s" % (ch1)
        self.send_command(cmd)
        cmd = "WFN%s" % (ch2)
        self.send_command(cmd)
Пример #3
0
    def set_load_impedance(self, channel, z):
        """
        Sets load impedance connected to each channel. Default value is 50 Ohms.
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        self.r_load = z
        """
        The voltage amplitude which is requestd from the AWG by the
        oscilloscope is the actual peak-to-peak amplitude.
        The actual output of BK4075 is twice the defined value because it
        supposes that it is loaded with 50 Ohm and half of the output voltage
        will fall on the internal impedance which is also 50 Ohm.
        If the connected load has other impedance, the output amplitude must
        be adjusted.
        For example, in order to obtain 1Vp-p on a Hi-Z load, the amplitude
        defined on BK405 must be 0.5Vp-p. For other load impedances it must
        be adjusted accordingly. 
        v_out_coeff variable stores the coefficient by which the amplitude
        defined by the oscilloscope will be multiplied before sending it
        to the AWG. 
        """
        if self.r_load == constants.HI_Z:
            self.v_out_coeff = 0.5
        else:
            self.v_out_coeff = 0.5 * (self.r_load + R_IN) / self.r_load
Пример #4
0
    def set_offset(self, channel, offset):
        """
        Sets DC offset of the selected channel.
        
        Command examples:
            :w27=9999.    
                sets the offset of channel 1 to 9.99V.
            :w27=1000. 
                sets the offset of channel 1 to 0V.
            :w28=1. 
                sets the offset of channel 2 to -9.99V.
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        # Adjust the offset to the defined load impedance
        offset = offset / self.v_out_coeff[channel - 1]

        offset_val = 1000 + int(offset * 100)

        # Channel 1
        if channel in (0, 1) or channel is None:
            cmd = ":w27=%s." % offset_val
            self.send_command(cmd)

        # Channel 2
        if channel in (0, 2) or channel is None:
            cmd = ":w28=%s." % offset_val
            self.send_command(cmd)
Пример #5
0
    def set_amplitue(self, channel, amplitude):
        """
        Sets amplitude of the selected channel.
        
        Commands
            :w25=30.
            :w26=30.
        set amplitudes of channel 1 and channel 2 accordingly to 0.03V.
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)
        """
        Adjust the output amplitude to obtain the requested amplitude
        on the defined load impedance.
        """
        amplitude = amplitude / self.v_out_coeff[channel - 1]

        amp_str = "%.3f" % amplitude
        amp_str = amp_str.replace(".", "")

        # Channel 1
        if channel in (0, 1) or channel is None:
            cmd = ":w25=%s." % amp_str
            self.send_command(cmd)

        # Channel 2
        if channel in (0, 2) or channel is None:
            cmd = ":w26=%s." % amp_str
            self.send_command(cmd)
Пример #6
0
 def set_amplitue(self, channel, amplitude):
     """
     Sets amplitude of the selected channel.
     
     Commands:
         WMA0.44 for 0.44 volts Channel 1
         WFA9.87 for 9.87 volts Channel 2
     """
     if channel is not None and channel not in CHANNELS:
         raise UnknownChannelError(CHANNELS_ERROR)
     
     """
     Adjust the output amplitude to obtain the requested amplitude
     on the defined load impedance.
     """
     amplitude = amplitude / self.v_out_coeff[channel-1] 
     amp_str = "%.3f" % amplitude
     
     # Channel 1
     if channel in (0, 1) or channel is None:
         cmd = "WMA%s" % amp_str
         self.send_command(cmd)
     
     # Channel 2
     if channel in (0, 2) or channel is None:
         cmd = "WFA%s" % amp_str
         self.send_command(cmd)
Пример #7
0
    def set_frequency(self, channel, freq):
        """
        Sets frequency on the selected channel.
        
        Command examples:
            :w23=25786,0.
                sets the output frequency of channel 1 to 2578.6Hz.
            :w23=25786,1.
                sets the output frequency of channel 1 to 2578.6kHz.
            :w24=25786,3.
                sets the output frequency of channel 2 to 25.786mHz.
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        freq_str = "%.2f" % freq
        freq_str = freq_str.replace(".", "")

        # Channel 1
        if channel in (0, 1) or channel is None:
            cmd = ":w23=%s,0." % freq_str
            self.send_command(cmd)

        # Channel 2
        if channel in (0, 2) or channel is None:
            cmd = ":w24=%s,0." % freq_str
            self.send_command(cmd)
Пример #8
0
    def enable_output(self, channel=None, on=False):
        """
        Turns the output on or off.

        Syntax: :OUTPut[:STATe]<ws>ON|1|OFF|0
        Examples:
            :OUTP:STAT ON
            :OUTP OFF
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        self.output_on = on

        if self.output_on:
            self.send_command(":OUTP:STAT ON")
        else:
            self.send_command(":OUTP:STAT OFF")
Пример #9
0
    def set_frequency(self, channel, freq):
        """
        Sets output frequency.
        
        Syntax:
            [:SOURce]:FREQuency[:CW]<ws><frequency>[units]
            [:SOURce]:FREQuency<ws>MINimum|MAXimum
        Examples: :FREQ 5KHZ
            :FREQ 5E3
            :FREQ MAXIMUM
            :FREQ MIN
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        freq_str = "%.10f" % freq
        cmd = ":FREQ %s" % (freq_str)
        self.send_command(cmd)
Пример #10
0
    def set_offset(self, channel, offset):
        """
        Sets DC offset of the output.
        
        Syntax:
            [:SOURce]:VOLTage:OFFSet<ws><offset>[units]
            [:SOURce]:VOLTage:OFFSet<ws>MINimum|MAXimum
        Examples:
            :VOLT:OFFS 2.5
            :VOLT:OFFS 2.5V
            :VOLT:OFFS MAX
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        # Adjust the offset voltage to match the defined load impedance
        offset = offset * self.v_out_coeff

        cmd = ":VOLT:OFFS %s" % (offset)
        self.send_command(cmd)
Пример #11
0
    def set_wave_type(self, channel, wave_type):
        """
        Sets the output wave type.
        
        Syntax:
            [:SOURce]:FUNCtion[:SHAPe]<WS><OPTION>
        Available functions:
            SINusoid, Square, TRIangle, ARBitrary, PULse
            SIN|TRI|SQU|ARB|PUL
        Examples: 
            :FUNC SIN
            :FUNC ARB
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)
        if not wave_type in constants.WAVE_TYPES:
            raise ValueError("Incorrect wave type.")

        cmd = WAVEFORM_COMMANDS[wave_type]
        self.send_command(cmd)
Пример #12
0
    def set_load_impedance(self, channel, z):
        """
        Sets load impedance connected to each channel. Default value is 50 Ohm.
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        self.r_load[channel - 1] = z
        """
        Vout coefficient defines how the requestd amplitude must be increased
        in order to obtain the requested amplitude on the defined load.
        If the load is Hi-Z, the amplitude must not be increased.
        If the load is 50 Ohm, the amplitude has to be double of the requested
        value, because of the voltage divider between the output impedance
        and the load impedance.
        """
        if z == constants.HI_Z:
            v_out_coeff = 1
        else:
            v_out_coeff = z / (z + R_IN)
        self.v_out_coeff[channel - 1] = v_out_coeff
Пример #13
0
    def set_amplitue(self, channel, amplitude):
        """
        Sets output amplitude.
        
        Syntax:
            [:SOURce]:VOLTage:AMPLitude<ws><amplitude>[units]
            [:SOURce]:VOLTage:AMPLitude<ws>MINimum|MAXimum
        Examples:
            :VOLT:AMPL 2.5
            :VOLT:AMPL 2.5V
            :VOLT:AMPL MAX
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        # Adjust the amplitude to the defined load impedance
        amplitude = amplitude * self.v_out_coeff

        amp_str = "%.3f" % amplitude
        cmd = ":VOLT:AMPL %s" % (amp_str)
        self.send_command(cmd)
Пример #14
0
 def set_offset(self, channel, offset):
     """
     Sets DC offset of the selected channel.
     
     Command examples:
     WMO0.33 sets channel 1 offset to 0.33 volts
     WFO-3.33sets channel 2 offset to -3.33 volts
     """
     if channel is not None and channel not in CHANNELS:
         raise UnknownChannelError(CHANNELS_ERROR)
     # Adjust the offset to the defined load impedance
     offset = offset / self.v_out_coeff[channel-1] 
     
     # Channel 1
     if channel in (0, 1) or channel is None:
         cmd = "WMO%s" % offset
         self.send_command(cmd)
     
     # Channel 2
     if channel in (0, 2) or channel is None:
         cmd = "WFO%s" % offset
         self.send_command(cmd)
Пример #15
0
 def set_wave_type(self, channel, wave_type):
     """
     Sets wave type of the selected channel.
     
     Commands:
         WMW00 for Sine wave channel 1
         WFW00 for Sine wave channel 2
     Both commands are "hard-coded".
    """
     if channel is not None and channel not in CHANNELS:
         raise UnknownChannelError(CHANNELS_ERROR)
     if not wave_type in constants.WAVE_TYPES:
         raise ValueError("Incorrect wave type.")
     
     # Channel 1
     if channel in (0, 1) or channel is None:
         cmd = "WMW00"
         self.send_command(cmd)
     
     # Channel 2
     if channel in (0, 2) or channel is None:
         cmd = "WFW00"
         self.send_command(cmd)
Пример #16
0
    def set_wave_type(self, channel, wave_type):
        """
        Sets wave type of the selected channel.
        
        Commands
            :w21=0.
            :w22=0.
        set wave forms of channels 1 and 2 accordingly to sine wave.
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)
        if not wave_type in constants.WAVE_TYPES:
            raise ValueError("Incorrect wave type.")

        # Channel 1
        if channel in (0, 1) or channel is None:
            cmd = ":w21=%s." % wave_type
            self.send_command(cmd)

        # Channel 2
        if channel in (0, 2) or channel is None:
            cmd = ":w22=%s." % wave_type
            self.send_command(cmd)
Пример #17
0
    def enable_output(self, channel=None, on=False):
        """
        Turns channels output on or off.
        The channel is defined by channel variable. If channel is None, both channels are set.
        
        Commands
            :w20=0,0.
            :w20=0,1.
            :w20=1,1.
        enable outputs of channels 1, 2 and of both accordingly.
        
        """
        if channel is not None and channel not in CHANNELS:
            raise UnknownChannelError(CHANNELS_ERROR)

        if channel is not None and channel != 0:
            self.channel_on[channel - 1] = on
        else:
            self.channel_on = [on, on]

        ch1 = "1" if self.channel_on[0] == True else "0"
        ch2 = "1" if self.channel_on[1] == True else "0"
        cmd = ":w20=%s,%s." % (ch1, ch2)
        self.send_command(cmd)