Exemple #1
0
                16,
                xform=lambda obj, x: int(
                    round(x * (_ADC_DEFAULT_CALIBRATION /
                               (10.0 if obj.get_frontend(2)[1] else 1.0)) *
                          obj._adc_gains()[1] * 2.0**10))),
  from_reg_signed(
      0,
      16,
      xform=lambda obj, x: x * (
          (10.0 if obj.get_frontend(2)[1] else 1.0
           ) / _ADC_DEFAULT_CALIBRATION) / obj._adc_gains()[1] / 2.0**10)),
 'ch1_sampling_freq': (REG_SAMPLINGFREQ, to_reg_unsigned(0, 1),
                       from_reg_unsigned(0, 1)),
 'ch2_sampling_freq': (REG_SAMPLINGFREQ, to_reg_unsigned(1, 1),
                       from_reg_unsigned(1, 1)),
 'filter_reset': (REG_FILT_RESET, to_reg_bool(0), from_reg_bool(0)),
 'input_scale1': (REG_INPUTSCALE_CH0,
                  to_reg_signed(0, 18, xform=lambda obj, x: x * 2.0**9),
                  from_reg_signed(0, 18, xform=lambda obj, x: x /
                                  (2.0**9))),
 'input_scale2': (REG_INPUTSCALE_CH1,
                  to_reg_signed(0, 18, xform=lambda obj, x: x * 2.0**9),
                  from_reg_signed(0, 18, xform=lambda obj, x: x /
                                  (2.0**9))),
 'output_scale1':
 (REG_OUTPUTSCALE_CH0,
  to_reg_signed(
      0,
      18,
      xform=lambda obj, x: int(
          round(x * 2.0**9 /
Exemple #2
0
        return monitor_source_gains[source]

    def _update_dependent_regs(self, scales):
        super(FIRFilter, self)._update_dependent_regs(scales)
        self._update_control_matrix_regs()
        self._update_gains_offsets_regs()

    def _on_reg_sync(self):
        super(FIRFilter, self)._on_reg_sync()
        # Update local variables with device variables
        self._sync_gains_offsets_regs()
        self._sync_control_matrix_regs()


_fir_reg_handlers = {
    'reset_ch1': (REG_FIR_CONTROL, to_reg_bool(0), from_reg_bool(0)),
    'reset_ch2': (REG_FIR_CONTROL, to_reg_bool(1), from_reg_bool(1)),
    'filter_en1': (REG_FIR_CONTROL, to_reg_bool(2), from_reg_bool(2)),
    'filter_en2': (REG_FIR_CONTROL, to_reg_bool(3), from_reg_bool(3)),
    'link': (REG_FIR_CONTROL, to_reg_bool(4), from_reg_bool(4)),
    'input_en1': (REG_FIR_CONTROL, to_reg_bool(5), from_reg_bool(5)),
    'input_en2': (REG_FIR_CONTROL, to_reg_bool(6), from_reg_bool(6)),
    'mon1_source':
    (REG_FIR_CONTROL, to_reg_unsigned(8, 3), from_reg_unsigned(8, 3)),
    'mon2_source': (REG_FIR_CONTROL, to_reg_unsigned(12, 3),
                    from_reg_unsigned(12, 3)),
    'mon1_clip': (REG_FIR_CONTROL, to_reg_bool(11), from_reg_bool(11)),
    'mon2_clip': (REG_FIR_CONTROL, to_reg_bool(15), from_reg_bool(15)),
    'output_en1': (REG_FIR_CONTROL, to_reg_bool(16), from_reg_bool(16)),
    'output_en2': (REG_FIR_CONTROL, to_reg_bool(17), from_reg_bool(17)),
    'input_scale1':
Exemple #3
0
                to_reg_unsigned(8,
                                8,
                                allow_set=[
                                    _OSC_SOURCE_CH1, _OSC_SOURCE_CH2,
                                    _OSC_SOURCE_DA1, _OSC_SOURCE_DA2,
                                    _OSC_SOURCE_EXT
                                ]), from_reg_unsigned(8, 8)),
 'trig_ch': (REG_OSC_TRIGCTL,
             to_reg_unsigned(4,
                             6,
                             allow_set=[
                                 _OSC_SOURCE_CH1, _OSC_SOURCE_CH2,
                                 _OSC_SOURCE_DA1, _OSC_SOURCE_DA2,
                                 _OSC_SOURCE_EXT
                             ]), from_reg_unsigned(4, 6)),
 'hf_reject': (REG_OSC_TRIGCTL, to_reg_bool(12), from_reg_bool(12)),
 'loopback_mode_ch1':
 (REG_OSC_ACTL,
  to_reg_unsigned(0, 1, allow_set=[_OSC_LB_CLIP,
                                   _OSC_LB_ROUND]), from_reg_unsigned(0,
                                                                      1)),
 'loopback_mode_ch2':
 (REG_OSC_ACTL,
  to_reg_unsigned(1, 1, allow_set=[_OSC_LB_CLIP,
                                   _OSC_LB_ROUND]), from_reg_unsigned(1,
                                                                      1)),
 'ain_mode': (REG_OSC_ACTL,
              to_reg_unsigned(16,
                              2,
                              allow_set=[_OSC_AIN_DDS, _OSC_AIN_DECI]),
              from_reg_unsigned(16, 2)),
Exemple #4
0
                                          16,
                                          xform=lambda obj, x: x * 2**15 - 1),
                            from_reg_signed(16,
                                            16,
                                            xform=lambda obj, x: x /
                                            (2**14 - 1))),
    'cliprange_lower_ch2':
    (REG_LLB_CLIP_SLOW, to_reg_signed(0,
                                      16,
                                      xform=lambda obj, x: x * 2**15 - 1),
     from_reg_signed(0, 16, xform=lambda obj, x: x / (2**14 - 1))),
    'cliprange_upper_ch2': (REG_LLB_CLIP_SLOW,
                            to_reg_signed(16,
                                          16,
                                          xform=lambda obj, x: x * 2**15 - 1),
                            from_reg_signed(16,
                                            16,
                                            xform=lambda obj, x: x /
                                            (2**14 - 1))),
    'fast_aux_enable': (REG_LLB_AUX_CTRL, to_reg_bool(1), from_reg_bool(1)),
    'slow_aux_enable': (REG_LLB_AUX_CTRL, to_reg_bool(2), from_reg_bool(2)),
    'fast_channel_en': (REG_LLB_ENABLES_LIGHTS, to_reg_bool(2),
                        from_reg_bool(2)),
    'slow_channel_en': (REG_LLB_ENABLES_LIGHTS, to_reg_bool(3),
                        from_reg_bool(3)),
    'out1_en': (REG_LLB_ENABLES_LIGHTS, to_reg_bool(4), from_reg_bool(4)),
    'out2_en': (REG_LLB_ENABLES_LIGHTS, to_reg_bool(5), from_reg_bool(5)),
    'input1_light': (REG_LLB_ENABLES_LIGHTS, to_reg_bool(6), from_reg_bool(6)),
    'input2_light': (REG_LLB_ENABLES_LIGHTS, to_reg_bool(7), from_reg_bool(7))
}
Exemple #5
0
     to_reg_unsigned(0, 16, xform=lambda obj, a: a / obj._dac_gains()[0]),
     from_reg_unsigned(0, 16, xform=lambda obj, a: a * obj._dac_gains()[0])),
    'pm_out2_amplitude':
    (REG_PM_SG_AMP,
     to_reg_unsigned(16, 16, xform=lambda obj, a: a / obj._dac_gains()[1]),
     from_reg_unsigned(16, 16, xform=lambda obj, a: a * obj._dac_gains()[1])),
    'pm_out1_phase':
    ((REG_PM_SG_PHASE1_H, REG_PM_SG_PHASE1_L),
     to_reg_unsigned(0, 48, xform=lambda obj, p: (p / _PM_SG_PHASESCALE)),
     from_reg_unsigned(0, 48, xform=lambda obj, p: p * _PM_SG_PHASESCALE)),
    'pm_out2_phase':
    ((REG_PM_SG_PHASE2_H, REG_PM_SG_PHASE2_L),
     to_reg_unsigned(0, 48, xform=lambda obj, p: (p / _PM_SG_PHASESCALE)),
     from_reg_unsigned(0, 48, xform=lambda obj, p: p * _PM_SG_PHASESCALE)),
    'pm_out1_locked_out': (REG_PM_LOCKED_OUTS, to_reg_bool(0),
                           from_reg_bool(0)),
    'pm_out2_locked_out': (REG_PM_LOCKED_OUTS, to_reg_bool(1),
                           from_reg_bool(1))
}


class Phasemeter(_stream_instrument.StreamBasedInstrument,
                 Phasemeter_WaveformGenerator):
    # TODO Frame instrument may not be appropriate when we get streaming going.
    """ Phasemeter instrument object.

    To run a new Phasemeter instrument, this should be instantiated and
    deployed via a connected :any:`Moku` object using
    :any:`deploy_instrument`. Alternatively, a pre-configured instrument object
    can be obtained by discovering an already running Phasemeter
    instrument on a Moku:Lab device via
    def commit(self):
        # Restart the sweep as instrument settings are being changed
        self._restart_sweep()
        super(FrequencyResponseAnalyzer, self).commit()

        # Update the scaling factors for processing of incoming frames
        # stateid allows us to track which scales correspond to which register
        # state
        self.scales[self._stateid] = self._calculate_scales()

    commit.__doc__ = MokuInstrument.commit.__doc__


_fra_reg_handlers = {
    'loop_sweep': (REG_FRA_ENABLES, to_reg_bool(0), from_reg_bool(0)),
    'single_sweep': (REG_FRA_ENABLES, to_reg_bool(1), from_reg_bool(1)),
    'sweep_reset': (REG_FRA_ENABLES, to_reg_bool(2), from_reg_bool(2)),
    'channel1_en': (REG_FRA_ENABLES, to_reg_bool(3), from_reg_bool(3)),
    'channel2_en': (REG_FRA_ENABLES, to_reg_bool(4), from_reg_bool(4)),
    'adc1_en': (REG_FRA_ENABLES, to_reg_bool(5), from_reg_bool(5)),
    'adc2_en': (REG_FRA_ENABLES, to_reg_bool(6), from_reg_bool(6)),
    'dac1_en': (REG_FRA_ENABLES, to_reg_bool(7), from_reg_bool(7)),
    'dac2_en': (REG_FRA_ENABLES, to_reg_bool(8), from_reg_bool(8)),
    'sweep_freq_min':
    ((REG_FRA_SWEEP_FREQ_MIN_H, REG_FRA_SWEEP_FREQ_MIN_L),
     to_reg_unsigned(0, 48, xform=lambda obj, f: f * _FRA_FREQ_SCALE),
     from_reg_unsigned(0, 48, xform=lambda obj, f: f / _FRA_FREQ_SCALE)),
    'sweep_freq_delta':
    ((REG_FRA_SWEEP_FREQ_DELTA_H, REG_FRA_SWEEP_FREQ_DELTA_L),
     to_reg_signed(0, 48), from_reg_signed(0, 48)),
Exemple #7
0
        stubbed for now.
        """
        if (source == _ARB_TRIG_SRC_CH1):
            level = scales['gain_adc1']
        elif (source == _ARB_TRIG_SRC_CH2):
            level = scales['gain_adc2']
        elif (source == _ARB_TRIG_SRC_EXT):
            level = 1.0
        else:
            level = 1.0

        return level


_arb_reg_handlers = {
    'enable1': (REG_ARB_SETTINGS1, to_reg_bool(0), from_reg_bool(0)),
    'phase_rst1': (REG_ARB_SETTINGS1, to_reg_bool(1), from_reg_bool(1)),
    'mode1': (REG_ARB_SETTINGS1,
              to_reg_unsigned(2,
                              2,
                              allow_set=[
                                  _ARB_MODE_125, _ARB_MODE_250, _ARB_MODE_500,
                                  _ARB_MODE_1000
                              ]), from_reg_unsigned(2, 2)),
    'interpolation1': (REG_ARB_SETTINGS1, to_reg_bool(4), from_reg_bool(4)),
    'trig_source1': (REG_ARB_SETTINGS1,
                     to_reg_unsigned(5,
                                     5,
                                     allow_set=[
                                         _ARB_TRIG_SRC_CH1, _ARB_TRIG_SRC_CH2,
                                         _ARB_TRIG_SRC_EXT
Exemple #8
0
 def wait_for_trig(self):
     r = self.reg_base + SweepGenerator._REG_CONFIG
     return self._instr._accessor_get(r, from_reg_bool(2))
Exemple #9
0
 def hold_last(self):
     r = self.reg_base + SweepGenerator._REG_CONFIG
     return self._instr._accessor_get(r, from_reg_bool(3))
Exemple #10
0
        else:
            # If aux is set to LO or demod, set the sine amplitude as desired.
            # Only ever output on Channel 2.
            self.sineout_amp = (self._lo_amp if self.aux_source == 'sine' else
                                self._demod_amp) / self._dac_gains()[1]

    @deprecated(category='method', message="Deprecated.")
    def set_control_matrix(self):
        # This function is merely here because LIA inherits PID which has a
        # control matrix
        # We need to rethink PID inheritance.
        pass


_lia_reg_hdl = {
    'lpf_en': (REG_LIA_ENABLES, to_reg_bool(0), from_reg_bool(0)),
    'ch1_pid1_en': (REG_LIA_ENABLES, to_reg_bool(1), from_reg_bool(1)),
    'ch1_pid1_ien': (REG_LIA_ENABLES, to_reg_bool(3), from_reg_bool(3)),
    'ch1_pid1_pen': (REG_LIA_ENABLES, to_reg_bool(5), from_reg_bool(5)),
    'ch1_out_en': (REG_LIA_ENABLES, to_reg_bool(8), from_reg_bool(8)),
    'ch2_out_en': (REG_LIA_ENABLES, to_reg_bool(9), from_reg_bool(9)),
    'lpf_den': (REG_LIA_ENABLES, to_reg_bool(10), from_reg_bool(10)),
    'pid1_ch1_den': (REG_LIA_ENABLES, to_reg_bool(11), from_reg_bool(11)),
    'ch1_pid1_bypass': (REG_LIA_ENABLES, to_reg_bool(13), from_reg_bool(13)),
    'ch1_signal_en': (REG_LIA_ENABLES, to_reg_bool(14), from_reg_bool(14)),
    'ch1_pid1_int_dc_pole':
    (REG_LIA_ENABLES, to_reg_bool(16), from_reg_bool(16)),
    'ch2_signal_en': (REG_LIA_ENABLES, to_reg_bool(17), from_reg_bool(17)),
    'ext_demod': (REG_LIA_ENABLES, to_reg_bool(18), from_reg_bool(18)),
    'lo_PLL': (REG_LIA_ENABLES, to_reg_bool(19), from_reg_bool(19)),
    'filt_bypass1': (REG_LIA_ENABLES, to_reg_bool(21), from_reg_bool(21)),
Exemple #11
0
        :type en: bool
        :param en: Enable the specified input channel(s).

        :raises InvalidParameterException: Invalid parameters
        """
        _utils.check_parameter_valid('set', ch, [1, 2, None], 'input channel')
        _utils.check_parameter_valid('bool', en, desc='enable input')

        if ch is None or ch == 1:
            self.ch1_input_en = en
        if ch is None or ch == 2:
            self.ch2_input_en = en


_PID_reg_hdl = {
    'ch1_pid1_bypass': (REG_PID_ENABLES, to_reg_bool(0), from_reg_bool(0)),
    'ch1_pid2_bypass': (REG_PID_ENABLES, to_reg_bool(1), from_reg_bool(1)),
    'ch1_pid1_int_dc_pole':
    (REG_PID_ENABLES, to_reg_bool(2), from_reg_bool(2)),
    'ch1_pid2_int_dc_pole':
    (REG_PID_ENABLES, to_reg_bool(3), from_reg_bool(3)),
    'ch2_pid1_bypass': (REG_PID_ENABLES, to_reg_bool(4), from_reg_bool(4)),
    'ch2_pid2_bypass': (REG_PID_ENABLES, to_reg_bool(5), from_reg_bool(5)),
    'ch2_pid1_int_dc_pole':
    (REG_PID_ENABLES, to_reg_bool(6), from_reg_bool(6)),
    'ch2_pid2_int_dc_pole': (REG_PID_ENABLES, to_reg_bool(7),
                             from_reg_bool(7)),
    'ch1_pid1_en': (REG_PID_ENABLES, to_reg_bool(8), from_reg_bool(8)),
    'ch1_pid2_en': (REG_PID_ENABLES, to_reg_bool(9), from_reg_bool(9)),
    'ch2_pid1_en': (REG_PID_ENABLES, to_reg_bool(10), from_reg_bool(10)),
    'ch2_pid2_en': (REG_PID_ENABLES, to_reg_bool(11), from_reg_bool(11)),
Exemple #12
0
 def ntrigger_mode(self):
     r = self.reg_base + Trigger._REG_NTRIGGER
     return self._instr._accessor_get(r, from_reg_bool(31))
Exemple #13
0
 def input_en(self):
     r = self.reg_base + PID._REG_EN
     return self._instr._accessor_get(r, from_reg_bool(6))
Exemple #14
0
 def dc_pole(self):
     r = self.reg_base + PID._REG_EN
     return self._instr._accessor_get(r, from_reg_bool(3))
Exemple #15
0
 def bypass(self):
     r = self.reg_base + PID._REG_EN
     return self._instr._accessor_get(r, from_reg_bool(1))
Exemple #16
0
 def enable(self):
     r = self.reg_base + PID._REG_EN
     return self._instr._accessor_get(r, from_reg_bool(0))