-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscope.py
79 lines (69 loc) · 2.29 KB
/
scope.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Imports
import time
import textwrap
import numpy as np
from instruments import Instruments
class Scope():
def __init__(self, visa_resource):
ref = visa_resource
channel = 1
x-axis
pass
def _check_integrity(self):
pass
def set_channel(self, channel: int=1):
# Set source channel
self.ref.write(f":WAV:SOUR CHAN{channel}")
self.channel = channel
def set_trigger(self):
#TODO: Allow either single or stop
# Set trigger
# A stopped screen has best memory depth
self.ref.write(":SING")
#self.ref.write(":STOP")
# Wait for trigger
trig_status = ""
while trig_status != "STOP":
trig_status = self.ref.query(":TRIG:STAT?").strip()
time.sleep(0.2)
def get_settings(self):
# Acquisition settings
# Fetch acquisition settings from scope
mem_depth = int(self.ref.query(":ACQ:MDEP?"))
sample_rate = float(self.ref.query(":ACQ:SRAT?"))
scale = float(self.ref.query(f":CHAN{self.channel}:SCAL?"))
# timescale = scope.query(":TIM:MAIN:SCAL?")
# Calculate waveform duration
time_window = mem_depth / sample_rate
# Calculate time resolution
time_res = 1/sample_rate
# Determine time units
if time_res < 1e-10:
tUnit = "ns"
elif time_res < 1e-7:
tUnit = "us"
elif time_res < 1e-4:
tUnit = "ms"
else:
tUnit = "s"
# Generate time axis
self.x_axis = np.linspace(start=0, stop=time_window, num=int(time_res))
acq_settings = f"""
***********************************
Acquisition Settings:
MemDepth = {mem_depth}
SampleRate = {sample_rate}
DataLength = {time_window}
TimeResolution = {time_res}
***********************************
"""
print(textwrap.dedent(acq_settings))
def get_waveform(self):
pass
def mem_to_screen(self):
# Truncate raw data to what's on screen, but preserve high-res gained from raw's memory depth
"""
* Get vertical reference/offset (potentially offscreen)
* Get vertical scale/step size
"""
pass