Skip to content

Commit b152bae

Browse files
committed
params pw,showPlot,tsamp
1 parent 5cdf26b commit b152bae

3 files changed

Lines changed: 36 additions & 9 deletions

File tree

nintan/pacq.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212
import time
1313
import threading
1414
import socket
15+
import matplotlib.pyplot as plt
16+
17+
try:
18+
showPlot = concore.params['plot']
19+
except:
20+
showPlot = False
21+
22+
try:
23+
tsamp = concore.params['tsamp']
24+
if tsamp > 1:
25+
tsamp = 1
26+
except:
27+
tsamp = 1
1528

1629
def extract(amplifierData):
1730
s = 0.0
@@ -39,9 +52,9 @@ def readUint16(array, arrayIndex):
3952
return variable, arrayIndex
4053

4154
def acq():
42-
# Run controller for 1 second
55+
# Run controller for tsamp second
4356
scommand.sendall(b'set runmode run')
44-
time.sleep(1)
57+
time.sleep(tsamp)
4558
scommand.sendall(b'set runmode stop')
4659

4760
# Read waveform data
@@ -152,13 +165,20 @@ def acq():
152165
ym = concore.read(1,"ym",init_simtime_ym)
153166
acq_thread.join()
154167
acq_thread = nxtacq_thread
168+
oldAmpT = amplifierTimestamps
155169
oldAmpD = amplifierData
156170
amplifierTimestamps = []
157171
amplifierData = []
158172
acq_thread.start()
159173
nxtacq_thread = threading.Thread(target=acq, daemon=True)
160174
ym[0] = extract(oldAmpD)
161-
print("ym="+str(ym[0]));
175+
print("ym="+str(ym[0]))
176+
if showPlot:
177+
plt.plot(oldAmpT,oldAmpD)
178+
plt.title("ym="+str(ym[0]))
179+
plt.xlabel('Time (s)')
180+
plt.ylabel('Voltage (uV)')
181+
plt.show()
162182
concore.write(1,"ym",ym)
163183
acq_thread.join()
164184
print("retry="+str(concore.retrycount))

nintan/pstim.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
global uglobal
1212
uglobal = 0.5
13-
PULSE_WIDTH = 10
13+
14+
try:
15+
PULSE_WIDTH = concore.params['pw']
16+
except:
17+
PULSE_WIDTH = 10
1418

1519
def pwm():
1620
while(True):
@@ -20,15 +24,15 @@ def pwm():
2024
if ulocal > 1.0:
2125
ulocal = 1.0
2226

23-
print("+")
27+
if PULSE_WIDTH >= 2:
28+
print("+")
2429
writer.write_one_sample_one_line(data=1,timeout=10)
2530
time.sleep(PULSE_WIDTH*ulocal)
26-
# accurate_delay(PULSE_WIDTH*ulocal)
2731

28-
print("-")
32+
if PULSE_WIDTH >= 2:
33+
print("-")
2934
writer.write_one_sample_one_line(data=0,timeout=10)
3035
time.sleep(PULSE_WIDTH*(1.0-ulocal))
31-
# accurate_delay(PULSE_WIDTH*(1.0-ulocal))
3236

3337
pwm_thread = threading.Thread(target=pwm, daemon=True)
3438

nintan/pstim0.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
global uglobal
77
uglobal = 0.5
8-
PULSE_WIDTH = 10
8+
try:
9+
PULSE_WIDTH = concore.params['pw']
10+
except:
11+
PULSE_WIDTH = 10
912

1013
def pwm():
1114
while(True):

0 commit comments

Comments
 (0)