disabling Voltage input collection...

Supporting 2.7 and 3.2+
Post Reply
john14519
Phidgetsian
Posts: 6
Joined: Sat Jan 11, 2020 10:59 am
Contact:

disabling Voltage input collection...

Post by john14519 »

Is there a simple way to totally disable further data collection on a VoltageInput device?
I used voltageInput0.setOnVoltageChangeHandler(onVoltageChange) to set the handler, and then set the data rate, but at some point I want to turn off the data collection.
I will try setting the VoltageChangeHandler to a dummy function, but this seems a bit crude. Is there a way to just say: stop all collection, no matter what? Or do I just have to close it?
thanks,
John
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: disabling Voltage input collection...

Post by mparadis »

If you want to keep the channel open but suspend data events temporarily, the easiest way would be to set the VoltageChangeTrigger to 5. As long as the voltage value was not 0.0V or 5.0V, it will be impossible for another event to occur until the change trigger is set back to 0. If the voltage value was 0 or 5V, then you could theoretically still get an event if the voltage goes from 0 to 5 or 5 to 0.

Another solution would be to create a simple global variable in your program that you can set to true or false. Then in the change handler, only do stuff with the data if the variable is set to true.

You could also just close and reopen the channel, since I can't think of any reason you'd want the channel to stay open if you're not interested in the data coming in for that period of time.
john14519
Phidgetsian
Posts: 6
Joined: Sat Jan 11, 2020 10:59 am
Contact:

Re: disabling Voltage input collection...

Post by john14519 »

Actually, I am using VCP1001_0, which has a +- 40 V input. Should I then set the voltage change to 40V?
The API says: "The channel will not issue a VoltageChange event until the voltage value has changed by the amount specified by the VoltageChangeTrigger."
I assumed this really meant by an amount greater than the VoltageChangeTrigger, since that made more sense to me. Is that right?
Thanks,John
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: disabling Voltage input collection...

Post by mparadis »

If you're using the VCP1001, the maximum change trigger is 80V, since it senses from -40 to +40.

Yes, you're correct that a voltage change greater than or equal to the change trigger will cause a data event.
User avatar
Patrick
Lead Developer
Posts: 634
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: disabling Voltage input collection...

Post by Patrick »

Actually, setting the voltage change handler to None is perfectly valid - the library will see that a handler isn't registered anymore, and stop calling it.

voltageInput0.setOnVoltageChangeHandler(None)

Although if you don't need voltages anymore, you could also just close the channel.

-Patrick
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests