Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 27497a09c3 | |||
| 5dc2d22686 | |||
| 56b239eb8b | |||
| 8bc5815db9 | |||
| 940a2d32fa |
@@ -660,9 +660,9 @@ class CC2650Device(Device):
|
||||
break
|
||||
|
||||
elif device_type == 'EISZeroOne':
|
||||
i = 0
|
||||
i = 1
|
||||
request_times = 0
|
||||
while i < 13:
|
||||
while i <= 24:
|
||||
try:
|
||||
# send
|
||||
code = self._encode_instruction(DeviceInstruction.TYP_CIS, DeviceInstruction.CIS_CALI, i)
|
||||
|
||||
+225
-172
@@ -1413,128 +1413,204 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
|
||||
@staticmethod
|
||||
def _decode_cali_coeff(cali_coeff: bytes) -> Optional[List[Tuple[int, int]]]:
|
||||
if cali_coeff != b'':
|
||||
cali_table = []
|
||||
hsrtia_a = []
|
||||
hsrtia_b = []
|
||||
hsrtia_c = []
|
||||
hsrtia_d = []
|
||||
phase_coeff = []
|
||||
phase_offset = []
|
||||
|
||||
# phase_coeff = [[0]*4 for i in range(4)]
|
||||
# phase_offset = [[0]*4 for i in range(4)]
|
||||
|
||||
phase_coeff = numpy.zeros([4, 4], dtype = int)
|
||||
phase_offset = numpy.zeros([4, 4], dtype = int)
|
||||
|
||||
########################################
|
||||
# phase_coeff
|
||||
#####################################################
|
||||
# phase_coeff/phase_offset/hsrtia_a/hsrtia_b/rolloff
|
||||
# [[gain0, g1, g2, g3] ----->最高頻
|
||||
# [gain0, g1, g2, g3] ----->中頻
|
||||
# [gain0, g1, g2, g3] ----->低頻
|
||||
# [gain0, g1, g2, g3] ----->最低頻
|
||||
# ]
|
||||
#######################################
|
||||
#####################################################
|
||||
print('cali_coeff=', cali_coeff)
|
||||
if cali_coeff != b'':
|
||||
cali_table = []
|
||||
hsrtia_a = numpy.zeros([4, 8], dtype = int) #hsrtia_a[freq][gain]
|
||||
hsrtia_b = numpy.zeros([4, 8], dtype = numpy.int64) #hsrtia_b[freq][gain]
|
||||
rolloff = numpy.zeros([4, 8], dtype = int) #rolloff[freq][gain]
|
||||
phase_coeff = numpy.zeros([4, 8], dtype = int) #phase_coeff[freq][gain]
|
||||
phase_offset = numpy.zeros([4, 8], dtype = int) #phase_offset[freq][gain]
|
||||
cis_data_len = 20
|
||||
|
||||
# print('cali_coeff', cali_coeff)
|
||||
cutoff_freq = struct.unpack('>I', cali_coeff[1:5])[0] * 100 #4
|
||||
# temp = struct.unpack('>B', cali_coeff[5:6])[0] #1
|
||||
# hsrtia_200r = struct.unpack('>B', cali_coeff[6:7])[0] #1
|
||||
# hsrtia_5k = struct.unpack('>H', cali_coeff[7:9])[0] #2
|
||||
# hsrtia_20k = struct.unpack('>H', cali_coeff[6:8])[0] #2
|
||||
# hsrtia_160k = struct.unpack('>I', cali_coeff[8:12])[0] #4
|
||||
#gain=0
|
||||
cis_cali_packet = 1
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][0] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][0] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][0] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 20
|
||||
g = 0
|
||||
phase_coeff[0][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 40
|
||||
g = 0
|
||||
phase_coeff[2][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#Lv[0] 160k
|
||||
index = 60
|
||||
hsrtia_a.append(int.from_bytes(cali_coeff[index+1:index+6], signed=True, byteorder='big'))
|
||||
hsrtia_b.append(int.from_bytes(cali_coeff[index+6:index+11], signed=True, byteorder='big'))
|
||||
hsrtia_c.append(int.from_bytes(cali_coeff[index+11:index+16], signed=True, byteorder='big'))
|
||||
cis_cali_packet = 2
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][0] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][0] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][0] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][0] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#Lv[1] 20k
|
||||
index = 80
|
||||
hsrtia_a.append(int.from_bytes(cali_coeff[index+1:index+6], signed=True, byteorder='big'))
|
||||
hsrtia_b.append(int.from_bytes(cali_coeff[index+6:index+11], signed=True, byteorder='big'))
|
||||
hsrtia_c.append(int.from_bytes(cali_coeff[index+11:index+16], signed=True, byteorder='big'))
|
||||
cis_cali_packet = 3
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][0] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][0] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][0] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][0] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#Lv[2] 5k
|
||||
index = 100
|
||||
hsrtia_a.append(int.from_bytes(cali_coeff[index+1:index+6], signed=True, byteorder='big'))
|
||||
hsrtia_b.append(int.from_bytes(cali_coeff[index+6:index+11], signed=True, byteorder='big'))
|
||||
hsrtia_c.append(int.from_bytes(cali_coeff[index+11:index+16], signed=True, byteorder='big'))
|
||||
#gain=1
|
||||
cis_cali_packet = 4
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][1] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][1] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][1] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#Lv[3] 200R
|
||||
index = 120
|
||||
hsrtia_a.append(int.from_bytes(cali_coeff[index+1:index+6], signed=True, byteorder='big'))
|
||||
hsrtia_b.append(int.from_bytes(cali_coeff[index+6:index+11], signed=True, byteorder='big'))
|
||||
hsrtia_c.append(int.from_bytes(cali_coeff[index+11:index+16], signed=True, byteorder='big'))
|
||||
cis_cali_packet = 5
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][1] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][1] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][1] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][1] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 140
|
||||
g = 1
|
||||
phase_coeff[0][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 160
|
||||
g = 1
|
||||
phase_coeff[2][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 180
|
||||
g = 2
|
||||
phase_coeff[0][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 200
|
||||
g = 2
|
||||
phase_coeff[2][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 220
|
||||
g = 3
|
||||
phase_coeff[0][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
index = 240
|
||||
g = 3
|
||||
phase_coeff[2][g] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][g] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][g] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][g] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
cis_cali_packet = 6
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][1] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][1] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][1] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][1] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
print('cutoff_freq', cutoff_freq)
|
||||
print('hsrtia_a', hsrtia_a)
|
||||
print('hsrtia_b', hsrtia_b)
|
||||
print('hsrtia_c', hsrtia_c)
|
||||
#gain=2
|
||||
cis_cali_packet = 7
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][2] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][2] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][2] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 8
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][2] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][2] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][2] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][2] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 9
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][2] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][2] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][2] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][2] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#gain=3
|
||||
cis_cali_packet = 10
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][3] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][3] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][3] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 11
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][3] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][3] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][3] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][3] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 12
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][3] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][3] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][3] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][3] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#gain=4
|
||||
cis_cali_packet = 13
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][4] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][4] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][4] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 14
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][4] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][4] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][4] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][4] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 15
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][4] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][4] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][4] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][4] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#gain=5
|
||||
cis_cali_packet = 16
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][5] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][5] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][5] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 17
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][5] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][5] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][5] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][5] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 18
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][5] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][5] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][5] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][5] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#gain=6
|
||||
cis_cali_packet = 19
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][6] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][6] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][6] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 20
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][6] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][6] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][6] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][6] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 21
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][6] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][6] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][6] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][6] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
#gain=7
|
||||
cis_cali_packet = 22
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
hsrtia_a[0][7] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
hsrtia_b[0][7] = struct.unpack('>q', cali_coeff[index+5:index+13])[0]
|
||||
rolloff[0][7] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 23
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[0][7] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[0][7] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[1][7] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[1][7] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
cis_cali_packet = 24
|
||||
index = (cis_cali_packet - 1) * cis_data_len
|
||||
phase_coeff[2][7] = struct.unpack('>i', cali_coeff[index+1:index+5])[0]
|
||||
phase_offset[2][7] = struct.unpack('>i', cali_coeff[index+5:index+9])[0]
|
||||
phase_coeff[3][7] = struct.unpack('>i', cali_coeff[index+9:index+13])[0]
|
||||
phase_offset[3][7] = struct.unpack('>i', cali_coeff[index+13:index+17])[0]
|
||||
|
||||
print('hsrtia_a')
|
||||
print(hsrtia_a)
|
||||
print('hsrtia_b')
|
||||
print(hsrtia_b)
|
||||
print('rolloff')
|
||||
print(rolloff)
|
||||
print('phase_coeff')
|
||||
print(phase_coeff)
|
||||
print('phase_offset')
|
||||
print(phase_offset)
|
||||
|
||||
cali_table.append((cutoff_freq, phase_coeff, phase_offset, hsrtia_a, hsrtia_b, hsrtia_c, hsrtia_d))
|
||||
cali_table.append((phase_coeff, phase_offset, hsrtia_a, hsrtia_b, rolloff))
|
||||
|
||||
return cali_table
|
||||
else:
|
||||
@@ -1558,16 +1634,16 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
if len(data) < 18:
|
||||
return None
|
||||
|
||||
ch1 = struct.unpack('>i', data[1+3:5+3])[0] # unit: 1/1000 nA
|
||||
ch2 = struct.unpack('>i', data[5+3:9+3])[0] # unit: mV
|
||||
ch3 = struct.unpack('>i', data[9+3:13+3])[0] # unit: kOm
|
||||
ch1 = struct.unpack('>i', data[1+3:5+3])[0]
|
||||
ch2 = struct.unpack('>i', data[5+3:9+3])[0]
|
||||
ch3 = struct.unpack('>i', data[9+3:13+3])[0]
|
||||
time_stamp: float = struct.unpack('<I', data[13+3:17+3])[0] # unit: ms
|
||||
cycle_number = struct.unpack('>H', data[17+3:19+3])[0]
|
||||
d19 = data[19+3]
|
||||
gain = data[20+3]
|
||||
finishMode = (d19 & 0x80) >> 7
|
||||
ch4 = struct.unpack('<i', data[21+3:25+3])[0] # Amp[uV]
|
||||
|
||||
finishMode = (d19 & 0x80) >> 7
|
||||
ch4 = struct.unpack('<i', data[21+3:25+3])[0]
|
||||
|
||||
notify_one = struct.unpack('<i', data[25+3:29+3])[0]
|
||||
notify_two = struct.unpack('<i', data[29+3:33+3])[0]
|
||||
notify_three = struct.unpack('<i', data[33+3:37+3])[0]
|
||||
@@ -1589,64 +1665,41 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
return None
|
||||
else:
|
||||
if self.cali_coeff is not None and (self._mode == 0 or self._mode == 5):
|
||||
hsrtia_a = []
|
||||
hsrtia_b = []
|
||||
hsrtia_c = []
|
||||
hsrtia_d = []
|
||||
cutoff_freq, phase_coeff, phase_offset, hsrtia_a, hsrtia_b, hsrtia_c, hsrtia_d = self.cali_coeff[0]
|
||||
phase_coeff, phase_offset, hsrtia_a, hsrtia_b, rolloff = self.cali_coeff[0]
|
||||
|
||||
if (self._mode == 0 or self._mode == 5):
|
||||
img = ch1
|
||||
real = ch2
|
||||
freq = ch3
|
||||
|
||||
img = ch1 #img[ohm]
|
||||
real = ch2 #real[ohm]
|
||||
freq = ch3 #freq[10mHz]
|
||||
fre_idx = 0
|
||||
voltage_amp = round(ch4 / 1000) # Amp[mV]
|
||||
voltage_amp = round(ch4 / 1000) #ch4=Amp[uV] #voltage_amp[mV]
|
||||
rolloff_cali = rolloff[0][gain]
|
||||
|
||||
# rolloff_cali = cutoff_freq/1e5
|
||||
rolloff_cali = hsrtia_c[gain]
|
||||
voltage_mag = math.sqrt(img ** 2 + real ** 2) * (1 + freq ** 2 / rolloff_cali ** 2 / 1e4)
|
||||
|
||||
# if (gain == 3):
|
||||
# current = hsrtia_a[gain] * math.exp(hsrtia_b[gain] * voltage_mag) + hsrtia_c[gain] * math.exp(hsrtia_d[gain] * voltage_mag)
|
||||
# else:
|
||||
current = (voltage_mag ** 2 * hsrtia_a[0][gain] + voltage_mag * hsrtia_b[0][gain]) / 1e8 #current[nA]
|
||||
|
||||
current = (voltage_mag ** 2 * hsrtia_a[gain] + voltage_mag * hsrtia_b[gain]) / 1e8 #[nA]
|
||||
# current = voltage_mag ** 2 * hsrtia_a[gain] + voltage_mag * hsrtia_b[gain] + hsrtia_c[gain]
|
||||
|
||||
|
||||
if (current != 0):
|
||||
# impedance[mOhm] = voltage_amp[mv] * 1000000 / 1.414213 / current[nA] #RMS=amp*SQRT(2), SQRT(2)=1.414213
|
||||
# impedance[mOhm] = voltage_amp[mV] * 1000000 / 1.414213 / current[nA] #RMS=amp*SQRT(2), SQRT(2)=1.414213
|
||||
impedance = voltage_amp * 707106.78 / current
|
||||
else:
|
||||
impedance = 0
|
||||
|
||||
raw_phase = math.atan2(img , real) * 180 / math.pi
|
||||
|
||||
if (freq >= 1000000): # 10000 Hz
|
||||
if (freq >= 1000000): #10000Hz
|
||||
fre_idx = 0
|
||||
elif (freq >= 10000): # 100 Hz
|
||||
elif (freq >= 10000): #100Hz
|
||||
fre_idx = 1
|
||||
elif (freq >= 1000): # 10 Hz
|
||||
elif (freq >= 1000): #10Hz
|
||||
fre_idx = 2
|
||||
elif (freq >= 1): # 0.01 Hz
|
||||
elif (freq >= 1): #0.01Hz
|
||||
fre_idx = 3
|
||||
|
||||
ideal_raw_phase = phase_coeff[gain][fre_idx] /1e10 * freq + phase_offset[gain][fre_idx] / 1e6
|
||||
phase = raw_phase - ideal_raw_phase
|
||||
phase = phase % 180 if phase % 180<=90 else phase % 180-180
|
||||
|
||||
# last_phase_to90 = self._last_phase % 180 if self._last_phase % 180<=90 else self._last_phase % 180-180
|
||||
# diff = phase - last_phase_to90
|
||||
|
||||
# if (self._first_phase_flag):
|
||||
# # self._last_phase = phase
|
||||
# self._first_phase_flag = 0
|
||||
# elif (abs(diff) >= 90):
|
||||
# phase = self._last_phase + diff + (180 if diff<0 else-180)
|
||||
# else:
|
||||
# phase = self._last_phase + diff
|
||||
# self._last_phase = phase
|
||||
|
||||
imag_after_cal = impedance * math.sin(phase * math.pi / 180)
|
||||
real_after_cal = impedance * math.cos(phase * math.pi / 180)
|
||||
|
||||
@@ -1654,17 +1707,17 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
if (self._mode == 0 or self._mode == 5):
|
||||
print('|', '{:10}'.format(time_stamp),
|
||||
'|', '{:5}'.format(delta),
|
||||
'|', '{:5}'.format(ch1), #raw_img
|
||||
'|', '{:5}'.format(ch2), #raw_real
|
||||
'|', '{:8}'.format(ch3 * 10), '[mHz]', #Frequency [mHz]
|
||||
'|', '{:5}'.format(cycle_number), #cycle
|
||||
'|', '{:5}'.format(round(imag_after_cal)), '[Ohm]', #Z_imag [Ohm]
|
||||
'|', '{:5}'.format(round(real_after_cal)), '[Ohm]', #Z_real [Ohm]
|
||||
'|', '{:5}'.format(round(impedance)), '[Ohm]', #Impedance [Ohm]
|
||||
'|', '{:5}'.format(round(phase*1000)), '[mdegree]', #Phase [millidegree]
|
||||
'|', '{:5}'.format(round(current)), '[nA]', #Current [nA]
|
||||
'|', '{:1}'.format(gain), #gain
|
||||
'|', '{:1}'.format(finishMode), #finishMode
|
||||
'|', '{:5}'.format(img),
|
||||
'|', '{:5}'.format(real),
|
||||
'|', '{:9}'.format(freq*10), '[mHz]',
|
||||
'|', '{:5}'.format(cycle_number),
|
||||
'|', '{:5}'.format(round(imag_after_cal)), '[Ohm]', #Z_imag[Ohm]
|
||||
'|', '{:5}'.format(round(real_after_cal)), '[Ohm]', #Z_real[Ohm]
|
||||
'|', '{:5}'.format(round(impedance)), '[mOhm]',
|
||||
'|', '{:5}'.format(round(phase*1000)), '[mdegree]',
|
||||
'|', '{:10}'.format(round(current)), '[nA]',
|
||||
'|', '{:1}'.format(gain),
|
||||
'|', '{:1}'.format(finishMode),
|
||||
'@', str(self.device), '|', flush = True)
|
||||
|
||||
print('|', '{:10}'.format(time_stamp),
|
||||
@@ -1672,7 +1725,7 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
'|', '{:5}'.format(notify_one),
|
||||
'|', '{:5}'.format(notify_two),
|
||||
'|', '{:5}'.format(notify_three),
|
||||
'|', '{:5}'.format(voltage_amp), #amp[mV]
|
||||
'|', '{:5}'.format(voltage_amp), '[mV]',
|
||||
'|', flush = True)
|
||||
pass
|
||||
else:
|
||||
@@ -1694,30 +1747,30 @@ class EISZeroOneDataDecoder(RecDataDecoder):
|
||||
self._mode_stop = 0
|
||||
|
||||
ret = RecordingData(self.device, int(time_stamp * 1000 / 2), 0)
|
||||
if self._mode == 0 or self._mode == 5: #EIS Mode
|
||||
ret.append_data(0, ch1) #raw_img
|
||||
ret.append_data(1, ch2) #raw_real
|
||||
ret.append_data(2, ch3 * 10) #Frequency [mHz]
|
||||
ret.append_data(3, cycle_number) #cycle
|
||||
if self._mode == 0 or self._mode == 5: #EIS/CF Mode
|
||||
ret.append_data(0, img)
|
||||
ret.append_data(1, real)
|
||||
ret.append_data(2, freq * 10) #[mHz]
|
||||
ret.append_data(3, cycle_number)
|
||||
ret.append_data(4, round(imag_after_cal)) #Z_imag [Ohm]
|
||||
ret.append_data(5, round(real_after_cal)) #Z_real [Ohm]
|
||||
ret.append_data(6, round(impedance)) #Impedance [Ohm]
|
||||
ret.append_data(7, round(phase*1000)) #Phase [millidegree]
|
||||
ret.append_data(8, round(current)) #Current [nA]
|
||||
ret.append_data(9, gain) #gain
|
||||
ret.append_data(6, round(impedance)) #[mOhm]
|
||||
ret.append_data(7, round(phase*1000)) #[millidegree]
|
||||
ret.append_data(8, round(current)) #[nA]
|
||||
ret.append_data(9, gain)
|
||||
|
||||
#debug data
|
||||
ret.append_data(10, notify_one)
|
||||
ret.append_data(11, notify_two)
|
||||
ret.append_data(12, notify_three)
|
||||
ret.append_data(13, voltage_amp) #amp[mV]
|
||||
ret.append_data(13, voltage_amp) #mV
|
||||
|
||||
|
||||
|
||||
else: #CV Mode
|
||||
ret.append_data(0, ch1) #Iin [nA]
|
||||
ret.append_data(1, ch2) #Vset [nV]
|
||||
ret.append_data(2, ch3) #Vout [nV]
|
||||
ret.append_data(0, ch1) #Iin [nA]?
|
||||
ret.append_data(1, ch2) #Vset [nV]?
|
||||
ret.append_data(2, ch3) #Vout [nV]?
|
||||
ret.append_data(3, cycle_number)
|
||||
|
||||
if cycle_number != self._cycle_number:
|
||||
|
||||
Reference in New Issue
Block a user