Page 1 of 1

Changing sample frequency of acquisition

Posted: Mon Nov 18, 2019 9:53 am
by YLM
Hi,

Maybe stupid question (hope someone did not answer in the topic, I did not find it...).

I am using the python code automatically generated for the PhidgetBridge 4-Input.

Code: Select all

from Phidget22.Phidget import *
from Phidget22.Devices.VoltageRatioInput import *
import time


def onVoltageRatioChange(self, voltageRatio):
	print("VoltageRatio [" + str(self.getChannel()) + "]: " + str(voltageRatio))

def main():
	voltageRatioInput0 = VoltageRatioInput()
	voltageRatioInput1 = VoltageRatioInput()
	voltageRatioInput2 = VoltageRatioInput()
	voltageRatioInput3 = VoltageRatioInput()

	voltageRatioInput0.setChannel(0)
	voltageRatioInput1.setChannel(1)
	voltageRatioInput2.setChannel(2)
	voltageRatioInput3.setChannel(3)

	voltageRatioInput0.setOnVoltageRatioChangeHandler(onVoltageRatioChange)
	voltageRatioInput1.setOnVoltageRatioChangeHandler(onVoltageRatioChange)
	voltageRatioInput2.setOnVoltageRatioChangeHandler(onVoltageRatioChange)
	voltageRatioInput3.setOnVoltageRatioChangeHandler(onVoltageRatioChange)

	voltageRatioInput0.openWaitForAttachment(5000)
	voltageRatioInput1.openWaitForAttachment(5000)
	voltageRatioInput2.openWaitForAttachment(5000)
	voltageRatioInput3.openWaitForAttachment(5000)

	try:
		input("Press Enter to Stop\n")
	except (Exception, KeyboardInterrupt):
		pass

	voltageRatioInput0.close()
	voltageRatioInput1.close()
	voltageRatioInput2.close()
	voltageRatioInput3.close()

main()
I would like to set the sample frequency of the acquisition. I thought it was the 5000 but it is not (btw I do not understand what this 5000 do, when I changed it I do not see any change).
Does someone know how to change the sample frequency ? Is there a method of the Phidget22 library that I need to use ?

Thank you

Re: Changing sample frequency of acquisition

Posted: Mon Nov 18, 2019 3:47 pm
by mparadis
The "5000" in this case is the timeout in milliseconds for openWaitforAttachment. This means that it will try to find a voltageRatioInput channel for 5 seconds before it gives up and throws a timeout exception.

In order to change the data interval for each channel, use setDataInterval. You can find more information about this method on our api page.

Re: Changing sample frequency of acquisition

Posted: Tue Nov 19, 2019 2:12 am
by YLM
perfect, thank you