Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

Python3 PPG Simple

Programming examples for remote communication with instruments
C/C++, C#, Python, Matlab, LabVIEW
Post Reply
Carl M
Tektronix Applications
Tektronix Applications
Posts: 800
Joined: July 30th, 2008, 4:45 pm
Country: United States

Python3 PPG Simple

Post by Carl M » November 26th, 2018, 9:10 am

A simplistic example of PPG communication and control.

Code: Select all

# Python3 PPG Simple
# https://www.tek.com/sample-license

# basic PPG communication and control

import time # std module
import visa # http://github.com/pyvisa/pyvisa

visa_address = 'USB::0x0699::0x3132::9211157::INSTR'

# instrument communication
rm = visa.ResourceManager()
ppg = rm.open_resource(visa_address)
ppg.timeout = 30000 # ms
ppg.encoding = 'latin_1'
ppg.write_termination = None

# clear messages by reading all
r = ppg.query('system:error?')
i = 0
while r != '0, No error\n':
    r = ppg.query('system:error?')
    i += 1
print('messages cleared: {}'.format(i))

r = ppg.query('*idn?')

# reset
print('recalling default setup...')
t1 = time.perf_counter()
r = ppg.query('system:error?')
t2 = time.perf_counter()
print('reset time: {} s'.format(t2-t1))

# simple setup
print('configuring example setup...')
t3 = time.perf_counter()
ppg.write('source:frequency 20e9')
ppg.write('digital1:pattern:type PRBS')
ppg.write('digital1:pattern:plength 15')
ppg.write('source:voltage1 300e-3')
ppg.write('output:clock:divider 2')
ppg.write('output1:state ON')
r = ppg.query('system:error?')
t4 = time.perf_counter()
print('setup time: {} s'.format(t4-t3))

# print status
print('status: {}'.format(r.strip()))
while r != '0, No error\n':
    r = ppg.query('system:error?')
Tektronix Application Engineer

Post Reply

Return to “Remote Instrument Communication (Programming) Examples”

Who is online

Users browsing this forum: No registered users and 2 guests