Changing sample frequency of acquisition

Supporting 2.7 and 3.2+
Post Reply
YLM
Phidgetsian
Posts: 11
Joined: Mon Nov 18, 2019 9:38 am
Contact:

Changing sample frequency of acquisition

Post 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
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Changing sample frequency of acquisition

Post 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.
YLM
Phidgetsian
Posts: 11
Joined: Mon Nov 18, 2019 9:38 am
Contact:

Re: Changing sample frequency of acquisition

Post by YLM »

perfect, thank you
Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests