與我們聯絡

與 Tek 業務代表即時對談。 上班時間:上午 6:00 - 下午 4:30 (太平洋時間)

致電

請致電

與 Tek 業務代表即時對談。 上班時間:上午 8:30 - 下午 5:30 (太平洋時間)

下載

下載手冊、產品規格表、軟體等等:

下載類型
機型或關鍵字

意見回饋

How do I save and transfer a screenshot from the 4, 5 or 6 Series MSO oscilloscope to my PC via the remote command interface?

問題:

How do I save and transfer a screenshot from the 4, 5 or 6 Series MSO oscilloscope to my PC via the remote command interface?

答案:

Screenshots (also known as hard copies) can be transferred from the Series 4, 5 and 6 MSO oscilloscopes via the remote programming interface using just a few simple commands.  For information on how to send commands to the instrument via the remote programming interface, please see the 4, 5, 6 Series MSO Programmer’s Manual.

To save and transfer a screenshot, send the following commands to the instrument:

SAVE:IMAGe “C:/Temp.png”

*OPC?

REM SAVE:IMAGE is an OPC generating command. Wait for instrument to finish writing the screenshot to disk by querying *OPC?

FILESystem:READFile “C:/Temp.png”

REM Read back the data sent from the instrument and write the data (un-altered) it to a .png file on your local system.

FILESystem:DELEte “C:/Temp.png”

Note: The REM command means remark and can be used for adding commands to command listings or .set files.  When the instrument encounters this command, the entire line is ignored by the command parser.

Avoiding Errors When Trying to Readback Image Data

If you send the SAVE:IMAGE command and then immediately send the FILESystem:READFile command, it is likely that you will get a timeout error or possibly a partial image when trying to read back the image data.  The reason for this is that you did not wait long enough after sending SAVE:IMAGe before sending FILESystem:READFile.  On the 4, 5, 6 Series MSO oscilloscopes the SAVE:IMAGE command is an OPC generating command therefore the *OPC? query command can be used to synchronize your program with the completion of the save operation.  After sending the SAVE:IMAGe command, send the *OPC? query command and wait for the response.  After you readback ‘1’ from the *OPC? query you can send the FILESystem:READFile command and readback the image data.

Python Example Code

The following example code written in Python can be used to transfer screenshots from the 4, 5, 6 Series MSO to your PC.  This code is written for Python 3 and the PyVISA library.

#-------------------------------------------------------------------------------

# Name:  Save Screenshot (Hard Copy) to PC for 4, 5, 6 Series MSO Oscilloscopes

#

# Purpose:  This example demonstrates how to save a screen shot (hard copy) image

#  from a 4, 5, 6 Series MSO oscilloscope to the PC.

#

# Development Environment: Python 3.6, PyVisa 1.8, NI-VISA 2017, Windows 10 x64

#

# Compatible Instruments: 4, 5, 6 Series MSO, MSO44, MSO46, MSO54, MSO56, MSO58, MSO58-LP, MSO64

#

# Compatible Interfaces:  USB, Ethernet

#

# Tektronix provides the following example "AS IS" with no support or warranty.

#

#-------------------------------------------------------------------------------

 

from datetime import datetime # std library

import time # std library

import visa # https://pyvisa.readthedocs.io/

 

# Replace string with your instrument's VISA Resource Address

visaRsrcAddr = "MSO58"

 

rm = visa.ResourceManager()

scope = rm.open_resource(visaRsrcAddr)

print(scope.query('*IDN?'))  # Print instrument id to console window

 

# Save image to instrument's local disk

scope.write('SAVE:IMAGe \"C:/Temp.png\"')

 

# Generate a filename based on the current Date & Time

dt = datetime.now()

fileName = dt.strftime("MSO5_%Y%m%d_%H%M%S.png")

 

# Wait for instrument to finish writing image to disk

scope.query('*OPC?')

 

# Read image file from instrument

scope.write('FILESystem:READFile \"C:/Temp.png\"')

imgData = scope.read_raw(1024*1024)

 

# Save image data to local disk

file = open(fileName, "wb")

file.write(imgData)

file.close()

 

# Image data has been transferred to PC and saved. Delete image file from instrument's hard disk.

scope.write('FILESystem:DELEte \"C:/Temp.png\"')

 

scope.close()

rm.close()

 

 


常見問答集 ID 245436

檢視所有常見問答集 »