Commit 40aab67500064243e9f3dcddfedbdef82d2c3808

Authored by bmarechal
1 parent b383042b0b
Exists in master

add pt100 sensor in VAL_TYPE

Showing 1 changed file with 12 additions and 3 deletions Inline Diff

instruments/T7Pro.py
from abstract_instrument import abstract_instrument 1 1 from abstract_instrument import abstract_instrument
from labjack import ljm 2 2 from labjack import ljm
import numpy 3 3 import numpy
4 4
#============================================================================== 5 5 #==============================================================================
6 6
ALL_VAL_TYPE = ['RES'] 7 7 ALL_VAL_TYPE = ['RES', 'TEMP PT100 K', 'TEMP PT100 C']
ALL_CHANNELS = ['1', '2', '3', '4'] 8 8 ALL_CHANNELS = ['1', '2', '3', '4']
9 9
ADRESS = "192.168.0.25" 10 10 ADRESS = "192.168.0.25"
CONF_CHANNELS = [["AIN0", "AIN10"], ["AIN2", "AIN11"], ["AIN4", "AIN12"], ["AIN6", "AIN13"]] 11 11 CONF_CHANNELS = [["AIN0", "AIN10"], ["AIN2", "AIN11"], ["AIN4", "AIN12"], ["AIN6", "AIN13"]]
12 VISHAY_CHANNELS = [1000., 1000., 1079., 10000.]
12 13
#============================================================================== 13 14 #==============================================================================
14 15
class T7Pro(abstract_instrument): 15 16 class T7Pro(abstract_instrument):
def __init__(self, channels, vtypes, adress): 16 17 def __init__(self, channels, vtypes, adress):
self.adress = adress 17 18 self.adress = adress
self.channels = channels 18 19 self.channels = channels
self.vtypes = vtypes 19 20 self.vtypes = vtypes
20 21
def model(self): 21 22 def model(self):
return 'T7Pro' 22 23 return 'T7Pro'
23 24
def connect(self): 24 25 def connect(self):
print('Connecting to device @%s...' %(self.adress)) 25 26 print('Connecting to device @%s...' %(self.adress))
self.handle = ljm.openS("T7", "ETHERNET", self.adress) 26 27 self.handle = ljm.openS("T7", "ETHERNET", self.adress)
print(' --> Ok') 27 28 print(' --> Ok')
print(self.model()) 28 29 print(self.model())
self.configure() 29 30 self.configure()
30 31
def configure(self): 31 32 def configure(self):
names = ["AIN0_NEGATIVE_CH", "AIN0_RANGE", "AIN0_RESOLUTION_INDEX", 32 33 names = ["AIN0_NEGATIVE_CH", "AIN0_RANGE", "AIN0_RESOLUTION_INDEX",
"AIN1_NEGATIVE_CH", "AIN1_RANGE", "AIN1_RESOLUTION_INDEX", 33 34 "AIN1_NEGATIVE_CH", "AIN1_RANGE", "AIN1_RESOLUTION_INDEX",
"AIN2_NEGATIVE_CH", "AIN2_RANGE", "AIN2_RESOLUTION_INDEX", 34 35 "AIN2_NEGATIVE_CH", "AIN2_RANGE", "AIN2_RESOLUTION_INDEX",
"AIN3_NEGATIVE_CH", "AIN3_RANGE", "AIN3_RESOLUTION_INDEX", 35 36 "AIN3_NEGATIVE_CH", "AIN3_RANGE", "AIN3_RESOLUTION_INDEX",
"AIN4_NEGATIVE_CH", "AIN4_RANGE", "AIN4_RESOLUTION_INDEX", 36 37 "AIN4_NEGATIVE_CH", "AIN4_RANGE", "AIN4_RESOLUTION_INDEX",
"AIN5_NEGATIVE_CH", "AIN5_RANGE", "AIN5_RESOLUTION_INDEX", 37 38 "AIN5_NEGATIVE_CH", "AIN5_RANGE", "AIN5_RESOLUTION_INDEX",
"AIN6_NEGATIVE_CH", "AIN6_RANGE", "AIN6_RESOLUTION_INDEX", 38 39 "AIN6_NEGATIVE_CH", "AIN6_RANGE", "AIN6_RESOLUTION_INDEX",
"AIN7_NEGATIVE_CH", "AIN7_RANGE", "AIN7_RESOLUTION_INDEX", 39 40 "AIN7_NEGATIVE_CH", "AIN7_RANGE", "AIN7_RESOLUTION_INDEX",
#"AIN8_NEGATIVE_CH", "AIN8_RANGE", "AIN8_RESOLUTION_INDEX", 40 41 #"AIN8_NEGATIVE_CH", "AIN8_RANGE", "AIN8_RESOLUTION_INDEX",
#"AIN9_NEGATIVE_CH", "AIN9_RANGE", "AIN9_RESOLUTION_INDEX", 41 42 #"AIN9_NEGATIVE_CH", "AIN9_RANGE", "AIN9_RESOLUTION_INDEX",
"AIN10_NEGATIVE_CH", "AIN10_RANGE", "AIN10_RESOLUTION_INDEX", 42 43 "AIN10_NEGATIVE_CH", "AIN10_RANGE", "AIN10_RESOLUTION_INDEX",
"AIN11_NEGATIVE_CH", "AIN11_RANGE", "AIN11_RESOLUTION_INDEX", 43 44 "AIN11_NEGATIVE_CH", "AIN11_RANGE", "AIN11_RESOLUTION_INDEX",
"AIN12_NEGATIVE_CH", "AIN12_RANGE", "AIN12_RESOLUTION_INDEX", 44 45 "AIN12_NEGATIVE_CH", "AIN12_RANGE", "AIN12_RESOLUTION_INDEX",
"AIN13_NEGATIVE_CH", "AIN13_RANGE", "AIN13_RESOLUTION_INDEX" 45 46 "AIN13_NEGATIVE_CH", "AIN13_RANGE", "AIN13_RESOLUTION_INDEX"
] 46 47 ]
l_names = len(names) 47 48 l_names = len(names)
aValues = [1, 1, 12,#0 48 49 aValues = [1, 1, 12,#0
199, 1, 12,#1 49 50 199, 1, 12,#1
3, 1, 12,#2 50 51 3, 1, 12,#2
199, 1, 12,#3 51 52 199, 1, 12,#3
5, 1, 12,#4 52 53 5, 1, 12,#4
199, 1, 12,#5 53 54 199, 1, 12,#5
7, 1, 12,#6 54 55 7, 1, 12,#6
199, 1, 12,#7 55 56 199, 1, 12,#7
#199, 1, 12,#8 56 57 #199, 1, 12,#8
#199, 1, 12,#9 57 58 #199, 1, 12,#9
199, 1, 12,#10 58 59 199, 1, 12,#10
199, 1, 12,#11 59 60 199, 1, 12,#11
199, 1, 12,#12 60 61 199, 1, 12,#12
199, 1, 12#13 61 62 199, 1, 12#13
] 62 63 ]
63 64
ljm.eWriteNames(self.handle, l_names, names, aValues) 64 65 ljm.eWriteNames(self.handle, l_names, names, aValues)
65 66
def getValue(self): 66 67 def getValue(self):
strMes = '' 67 68 strMes = ''
for ch in self.channels: 68 69 for ch in self.channels:
raw = self.read(CONF_CHANNELS[ALL_CHANNELS.index(ch)]) 69 70 if self.vtypes[self.channels.index(ch)] == 'RES':
strMes = strMes + str(100.*raw[0]/raw[1]) + ';' 70 71 raw = self.read(CONF_CHANNELS[ALL_CHANNELS.index(ch)])
72 strMes = strMes + str(VISHAY_CHANNELS[ALL_CHANNELS.index(ch)]*raw[0]/raw[1]) + ';'
73 elif self.vtypes[self.channels.index(ch)] == 'TEMP PT100 K':
74 raw = self.read(CONF_CHANNELS[ALL_CHANNELS.index(ch)])
75 strMes = strMes + str(((VISHAY_CHANNELS[ALL_CHANNELS.index(ch)]*raw[0]/raw[1])/100.-1)/0.003850+273.15) + ';'
76 elif self.vtypes[self.channels.index(ch)] == 'TEMP PT100 C':
77 raw = self.read(CONF_CHANNELS[ALL_CHANNELS.index(ch)])
78 strMes = strMes + str(((VISHAY_CHANNELS[ALL_CHANNELS.index(ch)]*raw[0]/raw[1])/100.-1)/0.003850) + ';'
79
strMes = strMes[0:-1] + '\n' 71 80 strMes = strMes[0:-1] + '\n'