Page 1 of 1

VCP1001 Error: AttributeError: 'VoltageInput' object has no attribute 'setDataRate'

Posted: Wed Jul 20, 2022 2:19 pm
by pythoncoder2002
Trying to use the setDataRate method (per documentation), on the VCP1001 but getting the following error:

Code: Select all

voltageInput0 = VoltageInput()
voltageInput0.setHubPort(0)
voltageInput0.setOnVoltageChangeHandler(onVoltageChangePort0)
voltageInput0.setOnErrorHandler(onError)

voltageInput0.openWaitForAttachment(1000)
voltageInput0.setVoltageChangeTrigger(0.0)
voltageInput0.setDataRate(1000)

Code: Select all

AttributeError: 'VoltageInput' object has no attribute 'setDataRate'
I'm using python 3.8.10 with libphidget22-1.10.20220530 and python module v 1.6.20201024.

Any suggestions?

Re: VCP1001 Error: AttributeError: 'VoltageInput' object has no attribute 'setDataRate'

Posted: Thu Jul 21, 2022 8:54 am
by mparadis
You will need to update your phidget22 python module to a newer version, since DataRate was added more recently than 2020.

That being said, you can just use DataInterval instead, which uses milliseconds between samples instead of samples per second. DataRate was added because we're starting to come out with devices that can provide more than 1 sample per millisecond, and DataInterval is an integer so the reciprocal DataRate was needed. For devices like the VCP1001 that existed before DataRate, the two properties are interchangable (e.g., setting a DataInterval of 40ms is the same as setting a DataRate of 25Hz).