Compatibility with Voltage and Temp sensor with VINT?

Supporting 2.7 and 3.2+
Post Reply
Wolfpack34
Fresh meat
Posts: 4
Joined: Thu Mar 17, 2022 3:20 pm
Contact:

Compatibility with Voltage and Temp sensor with VINT?

Post by Wolfpack34 »

I'm piecing together a project and have the motor controller, ADC, and current sensors working but as soon as I plug in the Temperature sensor the Voltage sensor doesn't seem to pull accurate data anymore.

- VINT Hub Phidget (HUB0001_0)
- DC Motor Phidget (DCC1000_0)
- Voltage Input Phidget (VCP1000_0)
- 30A Current Sensor Phidget (VCP1100_0)
- Temperature Phidget (TMP1000_0)

I'm running the code below. Even with the temperature sensor portion commented out the voltage input sensor doesn't respond with accurate data when the TMP1000 is plugged in.

Using the Phidget Control Panel, it looks like the getVoltage() command is pulling the voltage reading from the TMP1100 instead of the VCP1000.

Is there a way to force it to look at a specific port on the VINT?

Code: Select all

from Phidget22.Phidget import *
from Phidget22.Devices.DCMotor import *
from Phidget22.Devices.VoltageInput import *
from Phidget22.Devices.CurrentInput import *
from Phidget22.Devices.TemperatureSensor import *
import time

samples = 50
counter = 0

dcMotor0 = DCMotor()
dcMotor0.openWaitForAttachment(5000)
dcMotor0.setTargetVelocity(1)

voltageInput0 = VoltageInput()
voltageInput0.openWaitForAttachment(5000)

currentInput0 = CurrentInput()
currentInput0.openWaitForAttachment(5000)

# temperatureSensor0 = TemperatureSensor()
# temperatureSensor0.openWaitForAttachment(5000)

while counter < samples:
    time.sleep(0.1)
    print("Sample: " + str(counter) + " Voltage: " + str(voltageInput0.getVoltage()) + " Current: " + str(currentInput0.getCurrent()) + " Temp: " ) #+ str(temperatureSensor0.getTemperature()))
    counter += 1

counter = 0
dcMotor0.setTargetVelocity(0)

while counter < samples:
    time.sleep(0.1)
    print("Sample: " + str(counter + samples) + " Voltage: " + str(voltageInput0.getVoltage()) + " Current: " + str(currentInput0.getCurrent()) + " Temp: " ) #+ str(temperatureSensor0.getTemperature()))
    counter += 1


dcMotor0.close()
voltageInput0.close()
currentInput0.close()
# temperatureSensor0.close()
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Compatibility with Voltage and Temp sensor with VINT?

Post by mparadis »

You're right- your program will just grab the first VoltageInput object it finds, which happens to be the VoltageInput channel on the TMP1100. If you want to open a VoltageInput on a specific port, you can set the port before opening:

Code: Select all

voltageInput0 = VoltageInput()
voltageInput0.setHubPort(1)
voltageInput0.openWaitForAttachment(5000)
You can find more information about specifying which channel to open on this page.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests