Not enough sampling rate for PhidgetInterfaceKit 8/8/8

Supporting 2.7 and 3.2+
togtet
Fresh meat
Posts: 1
Joined: Fri Apr 02, 2021 11:30 am
Contact:

Not enough sampling rate for PhidgetInterfaceKit 8/8/8

Postby togtet » Fri Apr 02, 2021 11:44 am

Hi,
I'm trying to getVolatege for 4ch 200hz. Input voltage is 10hz sin curve but from received 5-10% duplicated value from getVoltage()

It's written 1000samples/s (4ch) so 250hz sampling should work.

Thanks you for your advice to fix this not enough sampling rate problem.

Best!

Code: Select all

#!/usr/bin/python3

import logging
import sys
import time

from Phidget22.Devices.Log import *
from Phidget22.Devices.VoltageOutput import *
from Phidget22.Devices.VoltageInput import *
from Phidget22.LogLevel import *
from Phidget22.Phidget import *
from Phidget22.PhidgetException import *
class getVoltage():
    def __init__(self, t):

        self_dot_ch = []
        for i in range(4):
            vinch = VoltageInput()
            vinch.setChannel(i)
            vinch.openWaitForAttachment(5000)           
            vinch.setDataInterval(1)
            if vinch.getAttached():
                self_dot_ch.append(vinch)   

        self.start_time = time.process_time()
        self.prev_time = 0

        self.t = t

    def start(self):
        while True:
            vs = []
            for i, c in self_dot_ch:
                v = c.getVoltage()
                vs[i] = v

            t = (time.process_time() - self.start_time)*1000
            logging.debug(f'v, {t:.2f}, {t-prev_time:.2f}, {vs}')
            self.prev_time = t

            time.sleep(self.t)

if __name__ == '__main__':
    hz = 200
    try:
        t = getVoltage(1/hz)
        t.start()
    except PhidgetException as err:
        logging.debug(f'PhidgetException: {err}')
        sys.exit(1)
    except KeyboardInterrupt:
        pass

User avatar
mparadis
Site Admin
Posts: 790
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Not enough sampling rate for PhidgetInterfaceKit 8/8/8

Postby mparadis » Mon Apr 05, 2021 7:42 am

Have you tried an event-driven solution using the VoltageChange event? Setting DataInterval doesn't do anything if you're polling with getVoltage.


Return to “Python”

Who is online

Users browsing this forum: No registered users and 3 guests