Waveform Generator Instrument

Supports the generation of Sine, Square and Ramp waves.

The output waveforms can also be frequency, phase or amplitude modulated. The modulation source can be another internally-generated Sinewave, the associated analog input channel or the other output channel. That other output channel may itself be modulated in some way, allowing the creation of very complex waveforms.

Note

For frequencies over approximately 30MHz, the Square Wave can be subject to edge jitter due to the DDS technology used in the Moku:Lab. If this is a problem, and you don’t need duty-cycle control, a clipped Sine Wave can provide better performance.

Example Usage

For an in-depth walkthrough on using the pymoku Waveform Generator Instrument, see the pymoku Waveform Generator tutorial. The following example code and a wide range of other pymoku demo scripts can be found at the pymoku Github repository.

waveformgenerator_basic.py
#
# pymoku example: Waveform Generator Basic
#
# This example demonstrates how you can use the Waveform Generator instrument to
# generate a sinewave on Channel 1 and a squarewave on Channel 2.
#
# (c) 2019 Liquid Instruments Pty. Ltd.
#
from pymoku import Moku
from pymoku.instruments import WaveformGenerator

# Connect to your Moku by its device name
# Alternatively, use Moku.get_by_serial('#####') or Moku('192.168.###.###')
m = Moku.get_by_name('Moku')

try:
	# Deploy the Signal Generator to your Moku
	i = m.deploy_instrument(WaveformGenerator)

	# Generate a sinewave (amp = 1Vpp, freq = 50 kHz) on channel 1. Squarewave (amp = 1 Vpp, freq = 500 Hz) on channel 2.
	i.gen_sinewave(1, amplitude=1.0, frequency=50e3)
	i.gen_squarewave(2, amplitude=1.0, frequency=500)

	# Configure the Moku's frontend
	i._set_frontend(channel=1, fiftyr=True, atten=True, ac=False)
	i._set_frontend(channel=2, fiftyr=True, atten=True, ac=False)

finally:
	m.close()

The WaveformGenerator Class

class pymoku.instruments.WaveformGenerator

Waveform Generator instrument object.

To run a new Waveform Generator instrument, this should be instantiated and deployed via a connected Moku object using deploy_instrument. Alternatively, a pre-configured instrument object can be obtained by discovering an already running Waveform Generator instrument on a Moku:Lab device via discover_instrument.

__init__()

Create a new WaveformGenerator instance, ready to be attached to a Moku.

type = "signal_generator"

Name of this instrument.

commit()

Apply all modified settings.

Note

If the autocommit feature has been turned off, this function can be used to manually apply any instrument settings to the Moku device. These instrument settings are those configured by calling all set_ and gen_ type functions. Manually calling this function allows you to atomically apply many instrument settings at once.

gen_modulate(*args, **kwargs)

Warning

Parameter Deprecation: ‘in’ and ‘out’ modulation sources have been deprecated. Use ‘adc1’, ‘adc2’, ‘dac1’ or ‘dac2’ instead.

Set up modulation on an output channel.

Parameters:
  • ch (int; {1,2}) – Channel to modulate
  • mtype (string, {'amplitude', 'frequency', 'phase'}) – Modulation type. Respectively Off, Amplitude, Frequency and Phase modulation.
  • source (string, {'adc1', 'adc2', 'dac1', 'dac2', 'internal', 'in', 'out'}) – Modulation source. Respectively Internal Sinewave, associated input channel or opposite output channel. In and out sources are deprecated.
  • depth (float 0-1, 0-125MHz or 0 - 360 deg) – Modulation depth (depends on modulation type): Fractional modulation depth, Frequency Deviation/Volt or +/- phase shift/Volt
  • frequency (float) – Frequency of internally-generated sine wave modulation. This parameter is ignored if the source is set to ADC or DAC.
Raises:

ValueOutOfRangeException – if the channel number is invalid or modulation parameters can’t be achieved

gen_modulate_off(*args, **kwargs)

Warning

Method Deprecation: ‘gen_modulate_off’ has been deprecated. Use set_modulate_trig_off instead.

‘gen_modulate_off’ has been deprecated. Use set_modulate_trig_off instead.

Turn off modulation for the specified output channel.

If ch is None (the default), both channels will be turned off, otherwise just the one specified by the argument.

Parameters:ch (int; {1,2} or None) – Output channel to turn modulation off.
gen_off(*args, **kwargs)

Turn Waveform Generator output(s) off.

The channel will be turned on when configuring the waveform type but can be turned off using this function. If ch is None (the default), both channels will be turned off, otherwise just the one specified by the argument.

Parameters:ch (int; {1,2} or None) – Channel to turn off, or both.
gen_rampwave(*args, **kwargs)

Generate a Ramp with the given parameters on the given channel.

This is a wrapper around the Square Wave generator, using the riserate and fallrate parameters to form the ramp.

Parameters:
  • ch (int; {1,2}) – Channel on which to generate the wave
  • amplitude (float, [0, 2.0] volts) – Waveform peak-to-peak amplitude
  • frequency (float, [0, 100e6] hertz) – Frequency of the wave
  • offset (float, [-1.0, 1.0] volts) – DC offset applied to the waveform
  • symmetry (float, [0, 1.0]) – Fraction of the cycle rising.
  • phase (float, degrees [0, 360]) – Phase offset of the wave
gen_sinewave(*args, **kwargs)

Generate a Sine Wave with the given parameters on the given channel.

Parameters:
  • ch (int; {1,2}) – Channel on which to generate the wave
  • amplitude (float, [0.0,2.0] Vpp) – Waveform peak-to-peak amplitude
  • frequency (float, [0,250e6] Hz) – Frequency of the wave
  • offset (float, [-1.0,1.0] Volts) – DC offset applied to the waveform
  • phase (float, [0-360] degrees) – Phase offset of the wave
gen_squarewave(*args, **kwargs)

Generate a Square Wave with given parameters on the given channel.

Parameters:
  • ch (int; {1,2}) – Channel on which to generate the wave
  • amplitude (float, [0, 2.0] volts) – Waveform peak-to-peak amplitude
  • frequency (float, [0, 100e6] hertz) – Frequency of the wave
  • offset (float, [-1.0, 1.0] volts) – DC offset applied to the waveform
  • duty (float, [0, 1.0]) – Fractional duty cycle
  • risetime (float, [0, 1.0]) – Fraction of a cycle taken for the waveform to rise
  • falltime (float [0, 1.0]) – Fraction of a cycle taken for the waveform to fall
  • phase (float, degrees 0-360) – Phase offset of the wave
gen_trigger_off(*args, **kwargs)

Warning

Method Deprecation: ‘gen_trigger_off’ has been deprecated. Use set_modulate_trig_off instead.

‘gen_trigger_off’ has been deprecated. Use set_modulate_trig_off instead.”

Turn off trigger/sweep mode for the specified output channel.

If ch is None (the default), both channels will be turned off, otherwise just the one specified by the argument.

Parameters:ch (int; {1,2} or None) – Output channel to turn trigger/sweep mode off
set_defaults(*args, **kwargs)

Can be extended in implementations to set initial state

set_modulate_trig_off(*args, **kwargs)

Turn off modulation and trigger modes for the specified output channel.

If ch is None (the default), both channels will be turned off, otherwise just the one specified by the argument.

Parameters:ch (int; {1,2} or None) – Output channel to turn modulation off.
set_trigger(*args, **kwargs)

Warning

Parameter Deprecation: ‘in’ and ‘out’ trigger sources have been deprecated. Use ‘adc1’, ‘adc2’, ‘dac1’ or ‘dac2’ instead.

Configure gated, start, ncycle or sweep trigger mode on target channel.

The trigger event can come from an ADC input channel, the opposite generated waveform, the external trigger input (for hardware that supports that) or a internally-generated clock of configurable period.

The trigger event can be used in several different ways: - gated: The output waveform is only generated while the trigger is asserted - start: The output waveform is enabled once the trigger event fires - ncycle: The output waveform starts at a trigger event and completes the given number of cycles, before turning off and re-arming - sweep: The trigger event starts the waveform generation at the sweep_start_freq, before automatically sweeping the frequency to sweep_end_freq over the course of sweep_duration seconds.

Parameters:
  • ch (int) – target channel.
  • mode (string, {'gated', 'start', 'ncycle', 'sweep', 'off'}) – Select the mode in which the trigger is operated.
  • ncycles (int, [1, 1e6]) – integer number of signal repetitions in ncycle mode.
  • sweep_start_freq (float, [0.0,250.0e6], hertz) – starting sweep frequency, set to current waveform frequency if not specified. Value range may vary for different waveforms.
  • sweep_end_freq (float, [0.0,250.0e6], hertz) – finishing sweep frequency. Value range may vary for different waveforms.
  • sweep_duration (float, [1.0e-3,1000.0], seconds) – sweep duration in seconds.
  • trigger_source (string {'adc1','adc2', 'dac1', 'dac2', 'external', 'internal', 'in', 'out'}) – defines which source should be used as triggering signal. In and out sources are deprecated.
  • trigger_threshold (float, [-5, 5], volts) – The threshold value range dependes on the source and the attenution used. Values ranges might be less for different settings.
  • internal_trig_period (float, [0,1e11], seconds) – period of the internal trigger clock, if used.
  • internal_trig_high (float, [0,1e11], seconds) – High time of the internal trigger clock, if used. Must be less than the internal trigger period.
sync_phase(*args, **kwargs)

Synchronize the phase of both output channels.

The phase of both channels is reset to their respestive phase offset values.