I used the generated python code to get the signal of 2 channels, I modify it a little bit and did some calibration. Now that I have my 2 channels independently, I'd like to use them together in order to make some computation. Here is the code :
Code: Select all
from Phidget22.Phidget import *
from Phidget22.Devices.VoltageRatioInput import *
import time
import datetime
TIME_OUT = 5000 #5s before it throws a timeout exception
DATA_INTERVAL = 1000 #1000ms data interval
# Calibration factor
A0 = -6.128983223994E-06
B0 = -0.000059639277340
A1 = -6.101017778744E-06
B1 = -0.000286467338645
def onVoltageRatioChange0(self, voltageRatio):
Masse = (voltageRatio - (B0) ) / (A0)
print(str(Masse))
def onVoltageRatioChange1(self, voltageRatio):
Masse = (voltageRatio - (B1) ) / (A1)
print(str(Masse))
def main():
voltageRatioInput0 = VoltageRatioInput()
voltageRatioInput0.setChannel(0)
voltageRatioInput0.setOnVoltageRatioChangeHandler(onVoltageRatioChange0)
voltageRatioInput0.openWaitForAttachment(TIME_OUT)
voltageRatioInput0.setBridgeGain(BridgeGain.BRIDGE_GAIN_128)
voltageRatioInput0.setDataInterval(DATA_INTERVAL)
voltageRatioInput1 = VoltageRatioInput()
voltageRatioInput1.setChannel(1)
voltageRatioInput1.setOnVoltageRatioChangeHandler(onVoltageRatioChange1)
voltageRatioInput1.openWaitForAttachment(TIME_OUT)
voltageRatioInput1.setBridgeGain(BridgeGain.BRIDGE_GAIN_128)
voltageRatioInput1.setDataInterval(DATA_INTERVAL)
try:
input("Press Enter to Stop\n")
except (Exception, KeyboardInterrupt):
pass
Code: Select all
Masse0 = voltageRatioInput0.setOnVoltageRatioChangeHandler(onVoltageRatioChange0)
I am not so good with python code, and I do not know how to call each Masse from the 2 function onVoltageRatioChange0 and 1 to use them inside my main and make some computation using the 2 channels...
Thank you