@@ -59,8 +59,6 @@ class ScienceLab():
59
59
60
60
61
61
62
-
63
-
64
62
"""
65
63
66
64
CAP_AND_PCS = 0
@@ -75,6 +73,7 @@ class ScienceLab():
75
73
DAC_SHIFTS_PV2B = 7
76
74
DAC_SHIFTS_PV3A = 8
77
75
DAC_SHIFTS_PV3B = 9
76
+ LOC_DICT = {'PV1' :[4 ,5 ],'PV2' :[6 ,7 ],'PV3' :[8 ,9 ]}
78
77
BAUD = 1000000
79
78
WType = {'W1' :'sine' ,'W2' :'sine' }
80
79
def __init__ (self ,timeout = 1.0 ,** kwargs ):
@@ -128,7 +127,7 @@ def __runInitSequence__(self,**kwargs):
128
127
self .achans = [analogAcquisitionChannel (a ) for a in ['CH1' ,'CH2' ,'CH3' ,'MIC' ]]
129
128
self .gain_values = gains
130
129
self .buff = np .zeros (10000 )
131
- self .SOCKET_CAPACITANCE = 0 # 42e-12 is typical for the SEElablet. Actual values will be updated during calibration loading
130
+ self .SOCKET_CAPACITANCE = 42e-12 # 42e-12 is typical for the SEElablet. Actual values will be updated during calibration loading
132
131
self .resistanceScaling = 1.
133
132
134
133
self .digital_channel_names = digital_channel_names
@@ -190,7 +189,7 @@ def __runInitSequence__(self,**kwargs):
190
189
self .aboutArray .append (['ADC INL Correction found' ,adc_shifts [0 ],adc_shifts [1 ],adc_shifts [2 ],'...' ])
191
190
poly_sections = polynomials .split ('STOP' ) #The 2K array is split into sections containing data for ADC_INL fit, ADC_CHANNEL fit, DAC_CHANNEL fit, PCS, CAP ...
192
191
193
- adc_slopes_offsets = poly_sections [0 ]
192
+ adc_slopes_offsets = poly_sections [0 ]
194
193
dac_slope_intercept = poly_sections [1 ]
195
194
inl_slope_intercept = poly_sections [2 ]
196
195
#print('COMMON#########',self.__stoa__(slopes_offsets))
@@ -268,7 +267,7 @@ def __runInitSequence__(self,**kwargs):
268
267
269
268
def get_resistance (self ):
270
269
V = self .get_average_voltage ('SEN' )
271
- if V > 3.295 :return 'Open'
270
+ if V > 3.295 :return np . Inf
272
271
I = (3.3 - V )/ 5.1e3
273
272
res = V / I
274
273
return res * self .resistanceScaling
@@ -705,36 +704,6 @@ def capture_fullspeed_hr(self,chan,samples,tg,*args):
705
704
706
705
return x ,self .analogInputSources [chan ].calPoly12 (y )
707
706
708
- def __charge_cap__ (self ,state ,t ):
709
- try :
710
- self .H .__sendByte__ (CP .ADC )
711
- self .H .__sendByte__ (CP .SET_CAP )
712
- self .H .__sendByte__ (state )
713
- self .H .__sendInt__ (t )
714
- self .H .__get_ack__ ()
715
- except Exception as ex :
716
- self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
717
-
718
- def __capture_capacitance__ (self ,samples ,tg ):
719
- from PSL .analyticsClass import analyticsClass
720
- self .AC = analyticsClass ()
721
- self .__charge_cap__ (1 ,50000 )
722
- try :
723
- x ,y = self .capture_fullspeed_hr ('CAP' ,samples ,tg ,'READ_CAP' )
724
- except Exception as ex :
725
- self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
726
- try :
727
- fitres = self .AC .fit_exp (x ,y )
728
- if fitres :
729
- cVal ,newy = fitres
730
- return x ,y ,newy ,cVal
731
- else :
732
- return None
733
- except Exception as ex :
734
- raise RuntimeError (" Fit Failed " )
735
-
736
- def capacitance_via_RC_discharge (self ,samples ,tg ):
737
- return self .__capture_capacitance__ (samples ,tg )[3 ]
738
707
739
708
def __retrieveBufferData__ (self ,chan ,samples ,tg ):
740
709
'''
@@ -1161,6 +1130,7 @@ def set_gain(self,channel,gain,Force=False):
1161
1130
refresh = False
1162
1131
if self .gains [channel ] != gain :
1163
1132
self .gains [channel ] = gain
1133
+ time .sleep (0.01 )
1164
1134
refresh = True
1165
1135
if refresh or Force :
1166
1136
try :
@@ -1281,7 +1251,7 @@ def get_average_voltage(self,channel_name,**kwargs):
1281
1251
1282
1252
def __get_raw_average_voltage__ (self ,channel_name ,** kwargs ):
1283
1253
"""
1284
- Return the average of 16 raw 10 -bit ADC values of the voltage on the selected channel
1254
+ Return the average of 16 raw 12 -bit ADC values of the voltage on the selected channel
1285
1255
1286
1256
.. tabularcolumns:: |p{3cm}|p{11cm}|
1287
1257
@@ -2571,6 +2541,55 @@ def readPulseCount(self):
2571
2541
except Exception as ex :
2572
2542
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
2573
2543
2544
+
2545
+
2546
+ def __charge_cap__ (self ,state ,t ):
2547
+ try :
2548
+ self .H .__sendByte__ (CP .ADC )
2549
+ self .H .__sendByte__ (CP .SET_CAP )
2550
+ self .H .__sendByte__ (state )
2551
+ self .H .__sendInt__ (t )
2552
+ self .H .__get_ack__ ()
2553
+ except Exception as ex :
2554
+ self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
2555
+
2556
+ def __capture_capacitance__ (self ,samples ,tg ):
2557
+ from PSL .analyticsClass import analyticsClass
2558
+ self .AC = analyticsClass ()
2559
+ self .__charge_cap__ (1 ,50000 )
2560
+ try :
2561
+ x ,y = self .capture_fullspeed_hr ('CAP' ,samples ,tg ,'READ_CAP' )
2562
+ except Exception as ex :
2563
+ self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
2564
+ try :
2565
+ fitres = self .AC .fit_exp (x * 1e-6 ,y )
2566
+ if fitres :
2567
+ cVal ,newy = fitres
2568
+ #from pylab import *
2569
+ #plot(x,newy)
2570
+ #show()
2571
+ return x ,y ,newy ,cVal
2572
+ else :
2573
+ return None
2574
+ except Exception as ex :
2575
+ raise RuntimeError (" Fit Failed " )
2576
+
2577
+ def capacitance_via_RC_discharge (self ):
2578
+ cap = self .get_capacitor_range ()[1 ]
2579
+ T = 2 * cap * 20e3 * 1e6 #uS
2580
+ samples = 500
2581
+ try :
2582
+ if T > 5000 and T < 10e6 :
2583
+ if T > 50e3 :samples = 250
2584
+ RC = self .__capture_capacitance__ (samples ,int (T / samples ))[3 ][1 ]
2585
+ return RC / 10e3
2586
+ else :
2587
+ return 0
2588
+ except Exception as e :
2589
+ self .__print__ (e )
2590
+ return 0
2591
+
2592
+
2574
2593
def __get_capacitor_range__ (self ,ctime ):
2575
2594
try :
2576
2595
self .__charge_cap__ (0 ,30000 )
@@ -2632,7 +2651,7 @@ def get_capacitance(self): #time in uS
2632
2651
#self.__print__('vals',CR,',',CT)
2633
2652
if CT > 65000 :
2634
2653
self .__print__ ('CT too high' )
2635
- return 0
2654
+ return self . capacitance_via_RC_discharge ()
2636
2655
V ,C = self .__get_capacitance__ (CR ,0 ,CT )
2637
2656
#print(CR,CT,V,C)
2638
2657
if CT > 30000 and V < 0.1 :
@@ -2653,11 +2672,13 @@ def get_capacitance(self): #time in uS
2653
2672
elif V <= 0.1 and CR < 3 :
2654
2673
CR += 1
2655
2674
elif CR == 3 :
2656
- self .__print__ ('Constant voltage mode ' )
2657
- return self .get_capacitor_range ()[ 1 ]
2675
+ self .__print__ ('Capture mode ' )
2676
+ return self .capacitance_via_RC_discharge ()
2658
2677
except Exception as ex :
2659
2678
self .raiseException (ex , "Communication Error , Function : " + inspect .currentframe ().f_code .co_name )
2660
2679
2680
+
2681
+
2661
2682
def __calibrate_ctmu__ (self ,scalers ):
2662
2683
#self.currents=[0.55e-3/scalers[0],0.55e-6/scalers[1],0.55e-5/scalers[2],0.55e-4/scalers[3]]
2663
2684
self .currents = [0.55e-3 ,0.55e-6 ,0.55e-5 ,0.55e-4 ]
@@ -3983,7 +4004,7 @@ def opticalArray(self,SS,delay,channel = 'CH3',**kwargs):
3983
4004
self .H .__sendByte__ (CP .TCD1304_HEADER )
3984
4005
if res == 10 :self .H .__sendByte__ (self .__calcCHOSA__ (channel )) #10-bit
3985
4006
else :self .H .__sendByte__ (self .__calcCHOSA__ (channel )| 0x80 ) #12-bit
3986
- self .H .__sendByte__ (tweak ) #Tweak the SH lwo to ICG high space. =tweak*delay
4007
+ self .H .__sendByte__ (tweak ) #Tweak the SH low to ICG high space. =tweak*delay
3987
4008
self .H .__sendInt__ (delay )
3988
4009
self .H .__sendInt__ (int (SS * 64 ))
3989
4010
self .timebase = SS
@@ -4059,6 +4080,6 @@ def raiseException(self,ex, msg):
4059
4080
eg.
4060
4081
I.get_average_voltage('CH1')
4061
4082
""" )
4083
+ #I=connect(verbose = True)
4084
+ #print (I.get_capacitance())
4062
4085
#I=connect(verbose=True,load_calibration=False)
4063
-
4064
-
0 commit comments