-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signal Generation Restructure and addition of high level methods (#246)
fix: Added function generation to all signal generators fix: fixes to strange resolutions to new commits and updates to docs docs: update to documentation for signal generation docs: fix to CHANGELOG.md and typos and grammer changes docs: fixed changelog, some grammer changes and removal of some useless known words docs: fixed changelog, changed docstring docs: signal generation updates fix: Added function generation to all signal generators fix: fixes to strange resolutions to new commits and updates to docs docs: update to documentation for signal generation docs: fix to CHANGELOG.md and typos and grammer changes docs: fixed changelog, some grammer changes and removal of some useless known words docs: fixed changelog, changed docstring docs: Updated the mkdocs plugin load order to fix weird capitalization issues in the new signal generation doc. Also fixed a few things in the signal generation doc to make links render properly. fix: Fix an issue where setup burst did not turn the channel on, so no burst would be generated docs: Added more detail to the composition diagram in order to try to make it render more clearly fix: Fix an issue where setup burst did not turn the channel on, so no burst would be generated docs: Added more detail to the composition diagram in order to try to make it render more clearly
- Loading branch information
Showing
84 changed files
with
6,531 additions
and
914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""An example showing how to generate a function using an AFG.""" | ||
|
||
from tm_devices import DeviceManager | ||
from tm_devices.drivers import AFG3K | ||
|
||
with DeviceManager(verbose=True) as dm: | ||
# Create a connection to the AFG and indicate that it is an AFG3K for type hinting | ||
afg3k: AFG3K = dm.add_afg("192.168.0.1") | ||
|
||
# Generate a RAMP waveform on SOURCE1 of the AFG3K with the provided properties. | ||
afg3k.generate_function( | ||
function=afg3k.source_device_constants.functions.RAMP, | ||
channel="SOURCE1", | ||
frequency=10e6, | ||
amplitude=0.5, | ||
offset=0, | ||
symmetry=50.0, | ||
) |
17 changes: 17 additions & 0 deletions
17
examples/signal_generators/set_source_channel_properties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""An example showing the use of an AWG source channel.""" | ||
|
||
from tm_devices import DeviceManager | ||
from tm_devices.drivers import AWG5K | ||
|
||
with DeviceManager(verbose=True) as dm: | ||
# Create a connection to the scope and indicate that it is an AWG5K for type hinting. | ||
awg5k: AWG5K = dm.add_awg("192.168.0.1") | ||
|
||
# Set the offset to 0.5 on SOURCE1 of the AWG5K | ||
awg5k.source_channel["SOURCE1"].set_offset(0.5) | ||
|
||
# Set the amplitude to 0.2 on SOURCE1 of the AWG5K | ||
awg5k.source_channel["SOURCE1"].set_amplitude(0.2) | ||
|
||
# Turn on SOURCE1 of the AWG5K | ||
awg5k.source_channel["SOURCE1"].set_state(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
"""An example showing the use of waveform constraints for an AWG.""" | ||
|
||
from tm_devices import DeviceManager | ||
from tm_devices.drivers import AWG5K | ||
from tm_devices.helpers.enums import SignalGeneratorFunctionsAWG | ||
|
||
# The desired frequency. | ||
DESIRED_FREQUENCY = 10e18 | ||
|
||
# The desired amplitude. | ||
DESIRED_AMPLITUDE = 5.0 | ||
|
||
# The desired sample rate. | ||
DESIRED_SAMPLE_RATE = 1 | ||
|
||
# The desired function to generate. | ||
DESIRED_FUNCTION = SignalGeneratorFunctionsAWG.SIN | ||
|
||
# The desired waveform length to generate. | ||
DESIRED_WAVEFORM_LENGTH = 1000000 | ||
|
||
# Format error message for function constraints. | ||
FORMAT_ERROR_MESSAGE_FUNCTION = ( | ||
"The desired {desired_prop_name} ({desired_val}) is not within the device's " | ||
"{desired_prop_name} range for generating a {function_name} waveform. " | ||
"Must be in the range of [{lower}, {upper}]." | ||
) | ||
|
||
# Format error message for waveform length constraints. | ||
FORMAT_ERROR_MESSAGE_WAVEFORM_LENGTH = ( | ||
"The desired {desired_prop_name} ({desired_val}) is not within the device's " | ||
"{desired_prop_name} range for generating a waveform with a length of {waveform_length}. " | ||
"Must be in the range of [{lower}, {upper}]." | ||
) | ||
|
||
|
||
with DeviceManager(verbose=True) as dm: | ||
# Create a connection to the scope and indicate that it is an AWG5K for type hinting. | ||
awg5k: AWG5K = dm.add_awg("192.168.0.1") | ||
|
||
# Get the device constraints for generating the desired function on an AWG5K. | ||
awg5k_constraints_function = awg5k.get_waveform_constraints(function=DESIRED_FUNCTION) | ||
|
||
# Get the frequency constraints. | ||
frequency_range = awg5k_constraints_function.frequency_range | ||
|
||
# Print a message if the desired frequency is not within the frequency constraints. | ||
if not frequency_range.lower <= DESIRED_FREQUENCY <= frequency_range.upper: | ||
print( | ||
FORMAT_ERROR_MESSAGE_FUNCTION.format( | ||
desired_prop_name="frequency", | ||
desired_val=DESIRED_FREQUENCY, | ||
function_name=DESIRED_FUNCTION.name, | ||
lower=frequency_range.lower, | ||
upper=frequency_range.upper, | ||
) | ||
) | ||
else: | ||
# generate a function as the signal source should be able to handle it | ||
awg5k.generate_function( | ||
function=awg5k.source_device_constants.functions.RAMP, | ||
channel="SOURCE1", | ||
frequency=DESIRED_FREQUENCY, | ||
amplitude=0.5, | ||
offset=0, | ||
) | ||
|
||
# Get the amplitude constraints. | ||
amplitude_range = awg5k_constraints_function.amplitude_range | ||
|
||
# Print a message if the desired amplitude is not within the amplitude constraints. | ||
if not amplitude_range.lower <= DESIRED_AMPLITUDE <= amplitude_range.upper: | ||
print( | ||
FORMAT_ERROR_MESSAGE_FUNCTION.format( | ||
desired_prop_name="amplitude", | ||
desired_val=DESIRED_AMPLITUDE, | ||
function_name=DESIRED_FUNCTION.name, | ||
lower=amplitude_range.lower, | ||
upper=amplitude_range.upper, | ||
) | ||
) | ||
else: | ||
# generate a function as the signal source should be able to handle it | ||
awg5k.generate_function( | ||
function=awg5k.source_device_constants.functions.RAMP, | ||
channel="SOURCE1", | ||
frequency=500.0e3, | ||
amplitude=DESIRED_AMPLITUDE, | ||
offset=0, | ||
) | ||
|
||
# Get the device constraints for generating the desired waveform length on an AWG5K. | ||
awg5k_constraints_waveform_length = awg5k.get_waveform_constraints( | ||
waveform_length=DESIRED_WAVEFORM_LENGTH | ||
) | ||
|
||
# Get the frequency constraints. | ||
sample_rate_range = awg5k_constraints_waveform_length.sample_rate_range | ||
|
||
# Print a message if the desired sample rate is not within the sample rate constraints. | ||
if not sample_rate_range.lower <= DESIRED_SAMPLE_RATE <= sample_rate_range.upper: | ||
print( | ||
FORMAT_ERROR_MESSAGE_WAVEFORM_LENGTH.format( | ||
desired_prop_name="sample rate", | ||
desired_val=DESIRED_SAMPLE_RATE, | ||
waveform_length=DESIRED_WAVEFORM_LENGTH, | ||
lower=sample_rate_range.lower, | ||
upper=sample_rate_range.upper, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.