ap--/voltcraft

SerialTimeoutException on PPS() initialization due to illegal voltage value on reset

Closed this issue · 2 comments

I am using the PPS-16005. On device initialization with reset=True, serial.serialutil.SerialTimeoutException is raised when trying to set the voltage to 0V. This is due to the minimum possible voltage of 0.8V for the PPS-16005.

Minimum working code example:

import voltcraft.pps
supply = voltcraft.pps.PPS("COM7", reset=True, debug=True)

Error and Traceback:

PPS <- GMAX<CR>
PPS -> 362120<CR>OK<CR>
PPS <- SOUT1<CR>
PPS -> OK<CR>
PPS <- VOLT000<CR>
PPS -> Traceback (most recent call last):
  File "C:\Users\larochelle\code\seizure_detection_testbench\playground.py", line 2, in <module>
    supply = voltcraft.pps.PPS("COM7", reset=True, debug=True)
  File "C:\Users\larochelle\code\seizure_detection_testbench\venv\lib\site-packages\voltcraft\pps.py", line 83, in __init__
    self.voltage(0)
  File "C:\Users\larochelle\code\seizure_detection_testbench\venv\lib\site-packages\voltcraft\pps.py", line 137, in voltage
    self._query("VOLT%03d" % voltage)
  File "C:\Users\larochelle\code\seizure_detection_testbench\venv\lib\site-packages\voltcraft\pps.py", line 119, in _query
    raise serial.SerialTimeoutException()
serial.serialutil.SerialTimeoutException

The following code example highlights the minimum voltage value of 0.8V. This is also the minimum voltage that can be set using the knobs on the device.

import voltcraft.pps
supply = voltcraft.pps.PPS("COM7", reset=False, debug=True)
supply.voltage(0.8)  # This is fine
supply.voltage(0.7)  # This raises an error

Error and Traceback:

PPS <- GMAX<CR>
PPS -> 362120<CR>OK<CR>
PPS <- VOLT008<CR>
PPS -> OK<CR>
PPS <- VOLT007<CR>
PPS -> Traceback (most recent call last):
  File "C:\Users\larochelle\code\seizure_detection_testbench\playground.py", line 4, in <module>
    supply.voltage(0.7)  # This raises an error
  File "C:\Users\larochelle\code\seizure_detection_testbench\venv\lib\site-packages\voltcraft\pps.py", line 137, in voltage
    self._query("VOLT%03d" % voltage)
  File "C:\Users\larochelle\code\seizure_detection_testbench\venv\lib\site-packages\voltcraft\pps.py", line 119, in _query
    raise serial.SerialTimeoutException()
serial.serialutil.SerialTimeoutException

The following solutions could be considered:

  • Adding an element for the minimum allowed voltage in the PPS_MODELS tuples and enforcing this minimum in the voltage() function (either silently or explicitly)
  • Adding a note in the PPS documentation to advise user to set reset=False for certain devices.

First option seems to be ideal, I would wait for your feedback before proposing a pull request.

Cheers,
Jonathan

ap-- commented

Hi @jonathanlarochelle

option (1) sounds good to me! You could add something like

PPS_MIN_VOLTAGE = {
    "PPS16005": 0.8,
}

And use PPS_MIN_VOLTAGE.get(self._model, 0) in the code.

PRs are welcome ❤️

ap-- commented

Closed via #22