Skip to content
English
  • There are no suggestions because the search field is empty.

Generating a pulse wave using Pymoku

Using ncycle mode to generate a pulse wave

Pulse waves are not pre-set in Pymoku, different from sine waves and square waves. 

To generate a pulse wave, we need to combine the square wave with the set_trigger function. The square wave should have a DC offset that is half its peak-to-peak voltage. The pulse is achieved by using the ncycle mode in the set_trigger function, where ncycles = 1. The pulse width is determined by the square wave frequency and duty cycle, the pulse frequency is set by the trigger period or frequency.

The example below generates a pulse wave with an amplitude of 1 Vpp and a frequency of 1 Hz.

# pymoku example: Waveform Generator Pulse Wave
#
# This example demonstrates how you can use the Waveform Generator instrument
# to generate a pulse wave on Channel 1.
#
# (c) 2021 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 Waveform Generator to your Moku
    i = m.deploy_instrument(WaveformGenerator)


    # Generate a squarewave (amp = 1 Vpp, freq = 500 Hz, offset = 0.5) on channel 1.
    i.gen_squarewave(1, amplitude=1.0, frequency=500, offset=0.5)


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


    # Configure channel 1 square wave to ncycle trigger mode, with internal 
    # clock as the trigger. With the number of cycles set to 1, this is a 
    # pulse wave. The signal will pulse every second.
    i.set_trigger(ch=1, mode='ncycle', ncycles=1,
                   trigger_source='internal', trigger_threshold=0, internal_trig_period=1)




finally:
    m.close()