Generating a pulse wave using Moku
Using ncycle mode to generate a pulse wave
Pulse waves are not pre-set in Moku, different from sine waves and square waves.
To generate a pulse wave, we need to combine the square wave with the set_burst_mode 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_burst_mode function, where ncycles = 1. The pulse width is determined by the square wave frequency and duty cycle, the pulse frequency is set by the burst period or frequency.
The example below generates a pulse wave with an amplitude of 1 Vpp and a frequency of 1 Hz.
# # Moku 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) 2023 Liquid Instruments Pty. Ltd. # from moku.instruments import WaveformGenerator i = WaveformGenerator('192.168.###.###') try: # Generate a square wave with 1Vpp amplitude, 500 Hz frequency and 0.5V offset i.generate_waveform(channel=1, type='Square', duty=50, amplitude=1, frequency=500, offset=0.5) # Configure channel 1 square wave to ncycle trigger mode, with internal clock # as the trigger. With the number of cycles set the 1, this is a pulse wave. # The signal will pusle once every second. i.set_burst_mode(channel=1, source='Internal', mode='NCycle', burst_cycles=1) finally: # Close the connection to the Moku device # This ensures network resources and released correctly i.relinquish_ownership()