-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple MSO68B example using tm_devices. (#64)
* tm_devices example for MSO6B * Update of the Main directory for tm_devices example. * Update to tm_devices example folder names. * simple typo fix * Updated some bad links in teh basic scopes area
- Loading branch information
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
Examples/Oscilloscopes/BenchScopes/src/Ivi2MatlabDriverExample/README.md
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
8 changes: 8 additions & 0 deletions
8
...copes/TekSeriesScopes_HighSpeedDigitizers/src/Measurements_tm_devices/README.md
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,8 @@ | ||
# Get simple measurement using tm_devices | ||
Original Attribution: Gayland P - Tektronix Applications | ||
|
||
This is a simple example using Tektronix tm_devices tools to connect to an oscilloscope by USB connection. This program finds the maximum peak to peak voltage value on a signal connected to Channel 1 of a 6 Series B oscilloscope. It runs the oscilloscope 10 times for 3 seconds at a time and publishes the results to a file in a C:\\Test directory. Very minor changes would be needed to use this script with a 5 Series, 4 series, or other 6 series oscilloscopes. | ||
|
||
For a description of tm_devices please go to https://pypi.org/project/tm-devices. | ||
|
||
This script uses numpy arrays, and assumes that the user has a version of VISA loaded on their PC that supports USB control of instrumentation, such as TekVISA, or NI-VISA. |
61 changes: 61 additions & 0 deletions
61
...kSeriesScopes_HighSpeedDigitizers/src/Measurements_tm_devices/tm_devices_MSO6B_example.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,61 @@ | ||
# This is an introductory python script originally written with pycharm IDE. This shows how to use tm_devices | ||
# for a relatively realistic short automation routine. Its goal is to find the maximum peak to peak | ||
# value of a signal on CH1 for a period of three seconds for 10 separate periods. | ||
|
||
# to use this script please create a folder under "C" drive called "Test" | ||
|
||
# This program uses tm_devices. see https://pypi.org/project/tm-devices/ for more details. | ||
# Device Manager interacts with pyvisa (and if a third party VISA is installed pyvisa interacts | ||
# with that). It has the routines that control instruments. | ||
from tm_devices import DeviceManager | ||
|
||
# Now we import the specific drivers that control the individual instrument, in this case a B version 6-series | ||
from tm_devices.drivers import MSO6B | ||
# Import time so we can use time.sleep() | ||
import time | ||
# Import Numpy (https://pypi.org/project/numpy/) to use numpy's array tools | ||
import numpy as np | ||
|
||
# set up initial values, including the numpy array. | ||
i = 0 | ||
NumberOfRuns = 10 | ||
MaxPKtoPK = np.zeros(NumberOfRuns) | ||
|
||
# Set up and connect to scope and check its idn string to ensure we connected. verbose in the DeviceManager | ||
# means you can see all commands going to instrument and all responses to queries which is useful for debug, or | ||
# not. Here we chose "false" so that we do not print those out. | ||
with DeviceManager(verbose=False) as device_manager: | ||
scope: MSO6B = device_manager.add_scope("MSO68B-B025464", connection_type="USB" ) | ||
print(scope.idn_string) | ||
|
||
# default the oscilloscope so that it is in a standard condition | ||
scope.reset() | ||
|
||
# Run Autoset to get the signal set up on screen. Followed by OPC query to ensure it completes. | ||
scope.commands.autoset.write("EXEC") | ||
scope.commands.opc.query() | ||
# Set up horizontal record length to 1 million points. | ||
scope.commands.horizontal.mode.write("MANual") | ||
scope.commands.horizontal.recordlength.write(1e6) | ||
# Ad Meas1 as a PK2PK measurement and display all stats in the badge | ||
# Then add a second Risetime measurement using a different method within tm_devices. | ||
scope.add_new_measurement("MEAS1", "PK2PK", "CH1") | ||
scope.commands.measurement.meas[1].displaystat.enable.write("ON") | ||
scope.commands.measurement.addmeas.write("RISETIME") | ||
scope.commands.measurement.meas[2].source.write("CH1") | ||
|
||
# stop the scope | ||
scope.commands.acquire.state.write("OFF") | ||
# This loop first clear the previous measurement values, starts the scope and runs it for 3 seconds, stops the | ||
# scope. and then add the Maximum peak to peak measurement value to the numpy array. | ||
while i < NumberOfRuns: | ||
scope.commands.clear.write() | ||
scope.commands.acquire.state.write("ON") | ||
time.sleep(3) | ||
scope.commands.acquire.state.write("OFF") | ||
MaxPKtoPK[i] = scope.commands.measurement.meas[1].results.allacqs.maximum.query() | ||
i = i+1 | ||
# Create the output file in the folder "Test" and use a numpy command to save the data into it. | ||
filename = "C:\\Test\\MaxAmp.txt" | ||
np.savetxt(filename, MaxPKtoPK) | ||
|