Can't set input voltage range on VCP1000_0

Any hardware type questions or problems for all other Phidget devices.
Post Reply
wouter_minjauw
Fresh meat
Posts: 1
Joined: Mon Apr 11, 2022 6:29 am
Contact:

Can't set input voltage range on VCP1000_0

Post by wouter_minjauw »

Hi,

Setting the input voltage range of the VCP1000_0 should be straightforward, but for some reasons it either ignores the range or it throws an exception.

Here is the simplest Python code that shows the problem.

Code: Select all

#!/usr/bin/env python3
from Phidget22.Phidget import *
from Phidget22.Devices.VoltageInput import *
import time

input_1 = VoltageInput()
input_1.setHubPort(0)
input_1.openWaitForAttachment(5000)

time.sleep(1)

input_1.setVoltageRange(VoltageRange.VOLTAGE_RANGE_312_5mV)

time.sleep(1)

input_voltage_range_feedback = input_1.getVoltageRange()
if input_voltage_range_feedback == VoltageRange.VOLTAGE_RANGE_312_5mV:
    print("Input voltage range is 312.5mV")
elif input_voltage_range_feedback == VoltageRange.VOLTAGE_RANGE_40V:
    print("Input voltage range is 40V")
else:
    print("Input voltage range is unknown/unsupported")

print(input_1.getVoltage())
This code gives the following output:
Input voltage range is 312.5mV
Traceback (most recent call last):
File "./problem<dot>py", line 24, in <module>
print(input_1.getVoltage())
File "/home/me/project/venv/lib/python3.8/site-packages/Phidget22/Devices/VoltageInput<dot>py", line 284, in getVoltage
raise PhidgetException(result)
Phidget22.PhidgetException.PhidgetException: PhidgetException 0x33 (Unknown or Invalid Value)
The value is unknown. This can happen right after attach, when the value has not yet been recieved from the Phidget. This can also happen if a device has not yet been configured / enabled. Some properties can only be read back after being set.


If I remove the time.sleep() calls, then I get the following output:

Input voltage range is 312.5mV
1.9966512


Although this does not throw an exception, the output of 1.99V clearly indicates that the voltage range is not what it reports.

Does anyone know what I'm doing wrong here?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest