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