#
# Moku example: Waveform Generator Triggering
#
# This example demonstrates how you can use the Waveform Generator instrument
# to generate a gated sinewave on Channel 1, and a swept frequency squarewave
# on Channel 2.
#
# (c) 2023 Liquid Instruments Pty. Ltd.
#
from moku.instruments import WaveformGenerator
# Launch Waveform Generator and connect to your device via IP
i = WaveformGenerator('192.168.###.###', force_connect = False)
try:
# Set sine wave to channel 1 and square wave to channel 2
i.generate_waveform(channel=1, type='Sine', amplitude=1, frequency=10)
i.generate_waveform(channel=2, type='Square', amplitude=1, duty=50, frequency=500)
# Activate burst trigger for output 1 and sweep trigger for output 2
i.set_burst_mode(channel=1, source='Internal', mode='Gated', burst_period=2, trigger_level=0.5)
i.set_sweep_mode(channel=2, source='Internal', stop_frequency=10, sweep_time=2, trigger_level=0.1)
finally:
# Close the connection to the Moku device
# This ensures network resources are released correctly
i.relinquish_ownership()