File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212import time
1313import threading
1414import 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
1629def extract (amplifierData ):
1730 s = 0.0
@@ -39,9 +52,9 @@ def readUint16(array, arrayIndex):
3952 return variable , arrayIndex
4053
4154def 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 )
163183acq_thread .join ()
164184print ("retry=" + str (concore .retrycount ))
Original file line number Diff line number Diff line change 1010
1111global uglobal
1212uglobal = 0.5
13- PULSE_WIDTH = 10
13+
14+ try :
15+ PULSE_WIDTH = concore .params ['pw' ]
16+ except :
17+ PULSE_WIDTH = 10
1418
1519def 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
3337pwm_thread = threading .Thread (target = pwm , daemon = True )
3438
Original file line number Diff line number Diff line change 55
66global uglobal
77uglobal = 0.5
8- PULSE_WIDTH = 10
8+ try :
9+ PULSE_WIDTH = concore .params ['pw' ]
10+ except :
11+ PULSE_WIDTH = 10
912
1013def pwm ():
1114 while (True ):
You can’t perform that action at this time.
0 commit comments