Skip to content

Commit 39d31a8

Browse files
authored
Added a simple MSO68B example using tm_devices. (tektronix#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
1 parent 6352c99 commit 39d31a8

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

Examples/Oscilloscopes/BenchScopes/src/Ivi2MatlabDriverExample/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Convert IVI to MATLAB Driver and Read Waveform (TBS1kB-EDU)
22
Original Attribution: Will D
33

4-
The purpose of this example is to demonstrate how to get a MATLAB driver for an instrument not listed in the MathWorks repository [here](https://www.mathworks.com/programs/products/instrument/instrument-drivers-search.html) but with a driver available via the IVI Foundation repository [here](http://www.ivifoundation.org/registered_drivers/driver_registry.aspx), such as [this driver](http://www.ivifoundation.org/registered_drivers/driver_registry.aspx) which I am using with a TBS1202B-EDU.
4+
The purpose of this example is to demonstrate how to get a MATLAB driver for an instrument not listed in the MathWorks repository [here](https://www.mathworks.com/hardware-support/instrument-control-toolbox/drivers-search.html?s_tid=srchtitle_site_search_3_instrument%20drivers&q=&page=1) but with a driver available via the IVI Foundation repository [here](https://www.ivifoundation.org/DriverRegistry/default.html), such as [this driver](http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=E3B19B3E94FE659CE034080020E74861) which I am using with a TBS1202B-EDU.
55

66
This example will lead you through installing the NI driver, recognizing where that installation is and confirming its existence, then using the ".c" driver to make a MATLAB ".mdd" driver.
77

Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ MDO3, MSO4/5/6 Series Oscilloscopes & MSO5LP/6LP High Speed Digitizers
1818
| **[Curvestream Maximum Speed (Tekworld Demo)](./src/CurvestreamMaximumSpeed)** | [![Python 3.8](https://img.shields.io/badge/python-3.8-&?labelColor=3E434A&colorB=006281&logo=python)](https://www.python.org/downloads/release/python-360/) |
1919
| **[Hello Scope! Basic Control Example](./src/CSharpHelloScope)** | [![C Sharp](https://img.shields.io/badge/-C%20Sharp-&?labelColor=3E434A&colorB=73BF44&logo=Microsoft)](https://github.com/dotnet/roslyn) |
2020
| **[Curve Query (Fetch Waveform) Windows Forms Example](./src/CSharpCurveQueryWinforms)** | [![C Sharp](https://img.shields.io/badge/-C%20Sharp-&?labelColor=3E434A&colorB=73BF44&logo=Microsoft)](https://github.com/dotnet/roslyn) |
21+
| **[Simple Measurement Automation with tm_devices](./src/Measurements_tm_devices)** | [![Python 3.8](https://img.shields.io/badge/python-3.8-&?labelColor=3E434A&colorB=006281&logo=python)](https://www.python.org/downloads/release/python-360/) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Get simple measurement using tm_devices
2+
Original Attribution: Gayland P - Tektronix Applications
3+
4+
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.
5+
6+
For a description of tm_devices please go to https://pypi.org/project/tm-devices.
7+
8+
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This is an introductory python script originally written with pycharm IDE. This shows how to use tm_devices
2+
# for a relatively realistic short automation routine. Its goal is to find the maximum peak to peak
3+
# value of a signal on CH1 for a period of three seconds for 10 separate periods.
4+
5+
# to use this script please create a folder under "C" drive called "Test"
6+
7+
# This program uses tm_devices. see https://pypi.org/project/tm-devices/ for more details.
8+
# Device Manager interacts with pyvisa (and if a third party VISA is installed pyvisa interacts
9+
# with that). It has the routines that control instruments.
10+
from tm_devices import DeviceManager
11+
12+
# Now we import the specific drivers that control the individual instrument, in this case a B version 6-series
13+
from tm_devices.drivers import MSO6B
14+
# Import time so we can use time.sleep()
15+
import time
16+
# Import Numpy (https://pypi.org/project/numpy/) to use numpy's array tools
17+
import numpy as np
18+
19+
# set up initial values, including the numpy array.
20+
i = 0
21+
NumberOfRuns = 10
22+
MaxPKtoPK = np.zeros(NumberOfRuns)
23+
24+
# Set up and connect to scope and check its idn string to ensure we connected. verbose in the DeviceManager
25+
# means you can see all commands going to instrument and all responses to queries which is useful for debug, or
26+
# not. Here we chose "false" so that we do not print those out.
27+
with DeviceManager(verbose=False) as device_manager:
28+
scope: MSO6B = device_manager.add_scope("MSO68B-B025464", connection_type="USB" )
29+
print(scope.idn_string)
30+
31+
# default the oscilloscope so that it is in a standard condition
32+
scope.reset()
33+
34+
# Run Autoset to get the signal set up on screen. Followed by OPC query to ensure it completes.
35+
scope.commands.autoset.write("EXEC")
36+
scope.commands.opc.query()
37+
# Set up horizontal record length to 1 million points.
38+
scope.commands.horizontal.mode.write("MANual")
39+
scope.commands.horizontal.recordlength.write(1e6)
40+
# Ad Meas1 as a PK2PK measurement and display all stats in the badge
41+
# Then add a second Risetime measurement using a different method within tm_devices.
42+
scope.add_new_measurement("MEAS1", "PK2PK", "CH1")
43+
scope.commands.measurement.meas[1].displaystat.enable.write("ON")
44+
scope.commands.measurement.addmeas.write("RISETIME")
45+
scope.commands.measurement.meas[2].source.write("CH1")
46+
47+
# stop the scope
48+
scope.commands.acquire.state.write("OFF")
49+
# This loop first clear the previous measurement values, starts the scope and runs it for 3 seconds, stops the
50+
# scope. and then add the Maximum peak to peak measurement value to the numpy array.
51+
while i < NumberOfRuns:
52+
scope.commands.clear.write()
53+
scope.commands.acquire.state.write("ON")
54+
time.sleep(3)
55+
scope.commands.acquire.state.write("OFF")
56+
MaxPKtoPK[i] = scope.commands.measurement.meas[1].results.allacqs.maximum.query()
57+
i = i+1
58+
# Create the output file in the folder "Test" and use a numpy command to save the data into it.
59+
filename = "C:\\Test\\MaxAmp.txt"
60+
np.savetxt(filename, MaxPKtoPK)
61+

0 commit comments

Comments
 (0)