HuangJunye / GrapheneLab-Measurement-Code

Simple to use transport measurement code
Apache License 2.0
13 stars 3 forks source link

Errors in do_device_sweep #20

Closed HuangJunye closed 5 years ago

HuangJunye commented 5 years ago

The following errors are shown when running do_device_sweep

---------------------------------------------------------------------------
VisaIOError                               Traceback (most recent call last)
<ipython-input-12-173f2ff82bf1> in <module>()
      7     timeout=0, wait=0.1,
      8     comment=comment_string,
----> 9     ignore_magnet = True)

~\Documents\Github\GrapheneLab-Measurement-Code\measurement\do_device_sweep.py in do_device_sweep(graph_proc, rpg, data_file, sweep_inst, read_inst, set_inst, set_value, finish_value, pre_value, b_set, persist, ignore_magnet, sweep_start, sweep_stop, sweep_step, sweep_finish, sweep_mid, delay, sample, t_set, timeout, wait, return_data, make_plot, socket_data_number, comment, network_dir)
     93 
     94     if sweep_start != 0:
---> 95         sweep_inst.ramp(sweep_start)
     96     else:
     97         sweep_inst.set_output(0)

~\Documents\Github\GrapheneLab-Measurement-Code\instrument\keithley\sourcemeter.py in ramp(self, finish_value)
    137                 time.sleep(0.01)
    138 
--> 139             self.read_data()
    140         return

~\Documents\Github\GrapheneLab-Measurement-Code\instrument\keithley\sourcemeter.py in read_data(self)
    108 
    109     def read_data(self):
--> 110         reply = self.visa.query(":READ?")
    111         self.data = [float(i) for i in reply.split(",")[0:2]]
    112         pass

C:\ProgramData\Anaconda3\lib\site-packages\pyvisa\resources\messagebased.py in query(self, message, delay)
    376         if delay > 0.0:
    377             time.sleep(delay)
--> 378         return self.read()
    379 
    380     # Kept for backwards compatibility.

C:\ProgramData\Anaconda3\lib\site-packages\pyvisa\resources\messagebased.py in read(self, termination, encoding)
    305         if termination is None:
    306             termination = self._read_termination
--> 307             message = self.read_raw().decode(enco)
    308         else:
    309             with self.read_termination_context(termination):

C:\ProgramData\Anaconda3\lib\site-packages\pyvisa\resources\messagebased.py in read_raw(self, size)
    279                     logger.debug('%s - reading %d bytes (last status %r)',
    280                                  self._resource_name, size, status)
--> 281                     chunk, status = self.visalib.read(self.session, size)
    282                     ret += chunk
    283             except errors.VisaIOError as e:

C:\ProgramData\Anaconda3\lib\site-packages\pyvisa\ctwrapper\functions.py in read(library, session, count)
   1567     buffer = create_string_buffer(count)
   1568     return_count = ViUInt32()
-> 1569     ret = library.viRead(session, buffer, count, byref(return_count))
   1570     return buffer.raw[:return_count.value], ret
   1571 

C:\ProgramData\Anaconda3\lib\site-packages\pyvisa\ctwrapper\highlevel.py in _return_handler(self, ret_value, func, arguments)
    143 
    144         if ret_value < 0:
--> 145             raise errors.VisaIOError(ret_value)
    146 
    147         if ret_value in self.issue_warning_on:

VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
HuangJunye commented 5 years ago

Additional errors are shown on Keithley2400 device:

  1. ERROR: ID CODE = 102, Syntax error
  2. ERROR: ID CODE = 803, Not permitted with OUTPUT off
  3. ERROR: ID CODE = -420, Query UNTERMINATED
HuangJunye commented 5 years ago
    def switch_output(self):
        self.output = not self.output
        self.visa.write(f":OUTP:STAT {self.output:d}")
        pass

The problem was due to inappropriate type in f string in switch_output() under Keithley class. self.output is bool type. If not type is specified in f string, it will be converated to "True" or "False" string, instead of "1" and "0" as intended. The bug is fixed by specifying {self.output:d} integer type (commit c6940099e846ccf363c55b56c724ac7378c53248)