11"""Module for interfacing with the Sciospec ISX-3 EIT device via serial communication"""
22
33try :
4+ from pyftdi .ftdi import Ftdi
5+ from pyftdi .usbtools import UsbTools
46 import serial
57except ImportError :
68 print ("Could not import module: serial" )
@@ -52,33 +54,98 @@ class ISX_3:
5254 A class for interfacing with the Sciospec ISX-3 EIT device.
5355 """
5456
55- def __init__ (self ) -> None :
57+ def __init__ (self , VID : hex = 0x0403 , PID : hex = 0x89D0 ) -> None :
5658 self .print_msg = True
5759 self .ret_hex_int = None
60+ self .VID = VID
61+ self .PID = PID
62+
63+ def info ():
64+ print ("ISX-3v2 EIT device specifications" )
65+ print (
66+ """
67+ Frequency
68+ range: 100mHz to 10MHz
69+ resolution: <10mHz @ f<10kHz
70+ <25mHz @ 10kHz ≤ f < 100kHz
71+ <150mHz @ 100kHz ≤ f ≤ 10MHz
72+ precision absolute: ±100ppm (at 25°C)
73+ temperature drift: ±10ppm over operating temperature range
74+ long time stability: ±5ppm first year
75+
76+ Excitation Signal
77+ range: 1mV to 1000mV peak-amplitude
78+ resolution: 0.1 mV
79+ maximum continuous output current: 50 mA
80+
81+ Output Impedance
82+ output impedance: 1Ω (nominal)
83+
84+ DC Bias (optional)
85+ voltage range: -8 V to 8 V
86+ voltage resolution: 10 mV
87+ current range: -20 mA to 20 mA
88+ current resolution: 25µA
89+
90+ Precision Settings
91+ precision range:
92+ 0 to 1: high speed, lower accuracy
93+ 1: standard configuration Δ|Z|/|Z|<0.1%
94+ 1 to 10: high accuracy, low speed
95+ averaging: 1 to 1024
96+
97+ Sweep Setting
98+ available sweep parameters: frequency, amplitude, DC bias voltage, DC bias current, kinetic, point delay
99+ sweep type: linear, logarithmic, list
100+ points: 1 to 2048
101+ sweep delay[1]: 0s to 3min in 1µs steps
102+ point delay[2]: 0s to 3min in 1µs steps
103+
104+ [1] Sweep-Delay: Timing delay between two consecutive measurements of complete impedance spectra
105+ [2] Point-Delay: Timing delay between two consecutive measurements of single frequencies
106+ """
107+ )
108+
109+ def list_usb_devices (self ):
110+ """
111+ Lists all connected USB devices and checks for the ISX-3 device.
58112
59- def connect_device_USB2 (self , port : str , baudrate : int = 9600 , timeout : int = 1 ):
113+ Returns
114+ -------
115+ list
116+ A list of connected USB devices.
60117 """
61- Connect to USB 2.0 Type B
118+ devices = UsbTools .find_all ([(self .VID , self .PID )])
119+ for device in devices :
120+ device_info = {
121+ "vendor" : hex (device [0 ].vid ),
122+ "product" : hex (device [0 ].pid ),
123+ "description" : device [0 ].description ,
124+ }
125+ if self .print_msg :
126+ print (f"Found device: { device_info } " )
127+
128+ def connect_device_FTDI (self ):
62129 """
63- if hasattr (self , "USB-FS" ):
130+ Connect to the ISX-3 device via FTDI interface.
131+ """
132+ if hasattr (self , "USB-FD" ):
64133 print (
65134 f"Serial connection 'self.serial_protocol' already defined as { self .serial_protocol } ."
66135 )
67136 else :
68- self .serial_protocol = "USB-FS"
69- self .device = serial .Serial (
70- port = port ,
71- baudrate = baudrate ,
72- timeout = timeout ,
73- parity = serial .PARITY_NONE ,
74- stopbits = serial .STOPBITS_ONE ,
75- bytesize = serial .EIGHTBITS ,
76- )
77- print ("Connection to" , self .device .name , "is established." )
137+ self .serial_protocol = "USB-FD"
138+ self .device = Ftdi ()
139+ self .device .open (vendor = self .VID , product = self .PID )
140+ print ("Connection to" , self .device , "is established." )
78141
79- def disconnect_device_USB2 (self ):
80- self .device .close ()
81- print ("Connection to" , self .device .name , "is closed." )
142+ def disconnect_device_FTDI (self ):
143+ """
144+ Disconnects the FTDI device.
145+ """
146+ if hasattr (self , "device" ):
147+ self .device .close ()
148+ print ("Connection to ISX-3 is closed." )
82149
83150 def SystemMessageCallback (self ):
84151 """
@@ -90,7 +157,7 @@ def SystemMessageCallback(self):
90157 data_count = 0
91158
92159 while True :
93- buffer = self .device .read ( )
160+ buffer = self .device .read_data ( size = 4 )
94161 if buffer :
95162 received .extend (buffer )
96163 data_count += len (buffer )
@@ -128,7 +195,7 @@ def write_command_string(self, command):
128195 """
129196 Function for writing a command 'bytearray(...)' to the serial port
130197 """
131- self .device .write (command )
198+ self .device .write_data (command )
132199 self .SystemMessageCallback ()
133200
134201 def ResetSystem (self ):
0 commit comments