-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_examples.py
132 lines (122 loc) · 5.54 KB
/
main_examples.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import ctypes
import copy
import numpy as np
from matplotlib import pyplot as plt
from picosdk.ps2000a import ps2000a as ps
from picosdk.functions import assert_pico_ok
import time
from driver_config_macros import *
from data_capture_macros import *
from signal_generator_macros import *
from power_operation_macros import *
from capture_config_macros import *
from trig_config_macros import *
from data_processing_macros import *
#driver_replacement() for the driver replacement to properly work, it is advised that it is run seprately from the main program,
# so that the newly generated code is compiled afterwards
channels = ['A', 'B', 'C', 'D']
timeUnits = ['fs', 'ps', 'ns', 'μs', 'ms', 's']
chandle = ctypes.c_int16()
status = {}
serial = b'GR925/0147'
start_scope([chandle, status], serial)
#TEST sigGen_stndrd()
sigGen_stndrd(chandle, status, 0, 1000000, 0, 100, 10000, 100, 0.1, 0, 0, 0, 0, 0, 0, 1)
#time.sleep(60)
#TEST data_block()
channels_ = [0, 1]
preTriggerSamples = 2500
postTriggerSamples = 2500
timebase = 32
totalSamples = preTriggerSamples+postTriggerSamples
segments = 1
ranges = [6, 6]
channel_config(chandle, status, 1, channels_, [0, 0], ranges, [0, 0]) #Configure channels
#trig_simple_config(chandle, status, 1, 0, 1024, 2, 0, 1000) #Setup a simple trigger
trig_logic_config(chandle, status, [[1, 2, 0, 0, 0, 0, 0, 0]], [0, 0, 0, 0, 0, 0], [[4096, 1000, 0, 0, 0, 0], [4096, 1000, 0, 0, 1, 0]], 1000)
time_ = timebase_block_config(chandle, status, timebase, totalSamples) #Setup timebase and time axis
buffersMax, buffersMin = buffer_block_config(chandle, status, channels_, totalSamples, segments, 0) #Setup buffer and segments
buff = []
clear_file('test.out')
for i in range(3):
data_block(chandle, status, preTriggerSamples, postTriggerSamples, timebase, 0, 0) #Get data
buff.append(copy.deepcopy(buffersMax))
for indx in range(len(buff)):
run = buff[indx]
run = run_to_mV(chandle, status, run, channels_, [6, 6], totalSamples, segments)
if True: #True for plots
for i in range(len(channels_)):
run_channel = run[i]
for j in range(segments):
run_channel_segment = run_channel[j]
plt.plot(time_, run_channel_segment)
plt.xlabel('Time (ns)')
plt.ylabel('Voltage (mV)')
plt.show()
if True: #True for file writing
run_to_file(time_, 'ns', run, channels_, segments, indx, 'test.out')
#TEST data_rapid_block() #Measured deadtime between calls ~3/160000 seconds/totalSamples (in data) [Rule of thumb]
'''channels_ = [0, 1]
preTriggerSamples = 2500
postTriggerSamples = 2500
timebase = 8
totalSamples = preTriggerSamples+postTriggerSamples
segments = 3
captures = 3
channel_config(chandle, status, 1, channels_, 0, [7, 7], 0) #Configure channels
trig_simple_config(chandle, status, 1, 0, 1024, 2, 0, 1000) #Setup a simple trigger
time_ = timebase_block_config(chandle, status, timebase, totalSamples) #Setup timebase and time axis
segment_capture_config(chandle, status, segments, captures, totalSamples) #Setup memory segmentation & capture configuration
buffersMax, buffersMin = buffer_block_config(chandle, status, channels_, totalSamples, segments, 0) #Setup buffer and segments
buff = []
clear_file('test.out')
for i in range(2):
data_rapid_block(chandle, status, preTriggerSamples, postTriggerSamples, timebase, segments, captures, 0, 0) #Get data
buff.append(copy.deepcopy(buffersMax))
for indx in range(len(buff)):
print('NEW RUN')
run = buff[indx]
run = run_to_mV(chandle, status, run, channels_, 7, totalSamples, segments)
if True: #True for plots
for i in range(len(channels_)):
run_channel = run[i]
for j in range(segments):
run_channel_segment = run_channel[j]
plt.plot(time_, run_channel_segment)
plt.xlabel('Time (ns)')
plt.ylabel('Voltage (mV)')
plt.show()
if True: #True for file writing
run_to_file(time_, 'ns', run, channels_, segments, indx, 'test.out')'''
#TEST data_streaming()
'''channels_ = [0, 1]
preTriggerSamples = 0
postTriggerSamples = 5000
totalSamples = preTriggerSamples+postTriggerSamples #totalSamples = preTriggerSamples+postTriggerSamples = sizeOfOneBuffer * numBuffersToCapture
sizeOfOneBuffer = 500
totalRuntime = 12500000 #In sampleUnits
sampleInterval = int(totalRuntime/totalSamples)
sampleUnits = 2
segments = 1
channel_config(chandle, status, 1, channels_, 0, [7, 7], 0) #Configure channels
#trig_simple_config(chandle, status, 1, 0, 1024, 2, 0, 1000) #Setup a simple trigger
time_ = timebase_stream_config(totalSamples, sampleInterval, sampleUnits) #Setup timebase and time axis
buffersComplete, buffersMax, buffersMin = buffer_stream_config(chandle, status, channels_, totalSamples, sizeOfOneBuffer, segments, 0) #Setup buffers
buff = []
clear_file('test.out')
for i in range(2):
data_streaming(chandle, status, sampleInterval, 0, buffersComplete, buffersMax, sizeOfOneBuffer, sampleUnits, preTriggerSamples, postTriggerSamples, 0, 1) #Get data
buff.append(copy.deepcopy(buffersComplete))
for indx in range(len(buff)):
run = buff[indx]
run = run_to_mV(chandle, status, run, channels_, 7, totalSamples, segments)
if True: #True for plots
for i in range(len(channels_)):
for j in range(segments):
plt.plot(time_, run[i][j])
plt.xlabel('Time (ns)')
plt.ylabel('Voltage (mV)')
plt.show()
if True: #True for file writing
run_to_file(time_, timeUnits[sampleUnits], run, channels_, segments, indx, 'test.out')'''
stop_scope([chandle, status])