-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tek5k7k70k_CheckClippingStatus example
- Loading branch information
Showing
3 changed files
with
116 additions
and
1 deletion.
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
35 changes: 35 additions & 0 deletions
35
...es/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/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,35 @@ | ||
# Check Clipping Status - 5k 7k 70k Series | ||
This script provides a function for checking the clipping status of a channel on a MSO/DPO5000 B, DPO7000 C, MSO/DPO70000 B C D DX, or DPO70000SX Series oscilloscope. | ||
|
||
Original Author: Dave W. - Tektronix Applications | ||
|
||
## Development Environment: | ||
Python 3.11, PyVisa 1.14, NI-VISA 2023 Q4, Windows 10 | ||
|
||
## Compatible Instruments: | ||
* MSO/DPO5000/B Series Oscilloscopes | ||
* DPO7000/C Series Oscilloscopes | ||
* MSO/DPO70000/B/C/D/DX Series Oscilloscopes | ||
* DPO70000SX Series Oscilloscopes | ||
|
||
## Compatible Interfaces: | ||
* USB | ||
* Ethernet | ||
|
||
## Changelog: | ||
### 2024-05-28: | ||
Original Revision | ||
|
||
|
||
<!-- markdown-link-check-disable --> | ||
Resources | ||
--------- | ||
* MSO/DPO5000/B, DPO7000/C, MSO/DPO70000/B/C/DX, DPO70000SX Series Programmer's Manual: | ||
* https://www.tek.com/en/oscilloscope/dpo70000-mso70000-manual/dpo70000sx-mso-dpo70000dx-mso-dpo70000c-dpo7000c-mso5000-b-1 | ||
* Python: https://www.python.org/ | ||
* PyVISA: https://pyvisa.readthedocs.io | ||
* NI-VISA: https://www.ni.com/en/support/downloads/drivers/download.ni-visa.html | ||
|
||
Disclaimer | ||
---------- | ||
Tektronix provides the following example "AS IS" with no support or warranty. |
80 changes: 80 additions & 0 deletions
80
...es/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.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,80 @@ | ||
# Title: | ||
# Check Clipping Status - 5k 7k 70k Series | ||
# | ||
# Description: | ||
# This script provides a function for checking the clipping status of a channel on | ||
# a MSO/DPO5000/B, DPO7000/C, MSO/DPO70000/B/C/D/DX, or DPO70000SX Series oscilloscope. | ||
# | ||
# Author: David Wyban | ||
# Created: 2024-05-28 | ||
# | ||
# Development Environment: | ||
# Python 3.11, PyVisa 1.14, NI-VISA 2023 Q4, Windows 10 | ||
# | ||
# Compatible Instruments: | ||
# MSO/DPO5000/B Series Oscilloscopes | ||
# DPO7000/C Series Oscilloscopes | ||
# MSO/DPO5000/B/C/D/DX Series Oscilloscopes | ||
# DPO70000SX Series Oscilloscopes | ||
# | ||
# Compatible Interfaces: | ||
# USB | ||
# Ethernet | ||
# | ||
# Tektronix provides the following example "AS IS" with no support or warranty. | ||
# | ||
#------------------------------------------------------------------------------- | ||
|
||
from enum import Enum | ||
import pyvisa as visa # https://pyvisa.readthedocs.io/en/latest/ | ||
|
||
class ClippingStatus(Enum): | ||
NotClipping = 0 | ||
Both = 1 | ||
Positive = 2 | ||
Negative = 3 | ||
|
||
|
||
def Tek5k7k70k_CheckClipping(vi : visa.resources.MessageBasedResource, channel : str = 'CH1') -> tuple[bool, ClippingStatus]: | ||
'''Returns True if the signal is clipping and False if it is not.''' | ||
|
||
# Setup status model so that measurement warnings will output to event status queue | ||
vi.write('DESE 16') # Enables execution errors to be reported in the event status register and queue | ||
vi.write('*ESE 16') # Enables execution errors to be reported in the status byte register | ||
|
||
vi.write('*CLS') | ||
vi.write(f':MEASU:IMM:TYPE PK2PK;SOUR1 {channel};') | ||
measVal = vi.query('MEASU:IMM:VAL?') | ||
esr = int(vi.query('*ESR?')) | ||
|
||
if esr != 0: | ||
eventMessages = vi.query('ALLEV?').strip() | ||
print(eventMessages) | ||
eventParts = eventMessages.split(',') | ||
|
||
errCode = int(eventParts[0]) | ||
if errCode == 547: | ||
return True, ClippingStatus.Both | ||
if errCode == 548: | ||
return True, ClippingStatus.Positive | ||
if errCode == 549: | ||
return True, ClippingStatus.Negative | ||
|
||
return False, ClippingStatus.NotClipping | ||
|
||
|
||
def CheckClippingExample(): | ||
rm = visa.ResourceManager() | ||
scope : visa.resources.MessageBasedResource = rm.open_resource('TCPIP::192.168.1.103::inst0::INSTR') | ||
print(scope.query('*IDN?')) | ||
|
||
print('Checking Clipping Status...') | ||
isClipping = Tek5k7k70k_CheckClipping(scope, 'CH1') | ||
print(f'Clipping?: {isClipping}') | ||
|
||
scope.close() | ||
rm.close() | ||
|
||
# Only run the example if this script is the main script being run | ||
if __name__ == '__main__': | ||
CheckClippingExample() |