-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_oscilloscope.py
34 lines (27 loc) · 1.19 KB
/
test_oscilloscope.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
# -*- coding: utf-8 -*-
import traceback
from Oscilloscope.AgilentOscilloscope import AgilentOscilloscopeDSO1002A
from Utils import Excel
from datetime import date
import subprocess
device = None
try:
device = AgilentOscilloscopeDSO1002A()
device.reset()
# Wait for trigger and retrieve data (Volts / seconds)
time_s, ch1_v, ch2_v = device.get_single_shoot(trigger_channel=1, trigger_level=1.5,
trigger_slope_down=True, time_scale="200us",
channel_1_y_scale=1, channel_2_y_scale=1)
# Create excel file
excel_file = "oscilloscope_out_%s.xlsx" % date.today()
time_us = [t*1e6 for t in time_s]
Excel.plot_signals(excel_file, time_us, ch1_v, 'Channel 1', ch2_v, 'Channel 2',
x_label='Time (us)', y_label='Voltage (V)', title="Signal Data")
# Open excel file
subprocess.call([r'C:\Program Files (x86)\Microsoft Office\Office15\excel.exe', excel_file])
except RuntimeError as e:
traceback.print_exc()
print("Error description: '%s'" % e)
if device is not None:
# Screen is locked when remote access is detected
device.unlock_screen()