Skip to content

Instantly share code, notes, and snippets.

@brookst
Created March 21, 2015 08:10
Show Gist options
  • Save brookst/12bf723fcc1559bf3880 to your computer and use it in GitHub Desktop.
Save brookst/12bf723fcc1559bf3880 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
Tools for interacting with usbtmc devices
Tim Brooks 2015 <brooks@cern.ch>
"""
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np
import usbtmc
VID, PID = 0x0699, 0x036a # Tektronics TDS 2024B
INST = usbtmc.Instrument(VID, PID)
def plot(values):
"""Plot a blob of data"""
plt.plot(np.array(values.split(',')))
plt.tight_layout()
plt.show()
def main():
"""Simple aquisition demo"""
INST.timeout = 2000 # Capturing waveforms can take some time...
INST.write(":data:enc ASCII;") # ASCII data, please
INST.write(":data:source CH1;") # Acquire channel 1
print(INST.ask("wfmpre?")) # Print preamble
data = INST.ask("curve?")
plot(data)
# print(data)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment