Page 1 of 1

Running motor loop in parallel with data acquisition

Posted: Thu Jul 19, 2018 9:56 pm
by gdeol
I want to move my stepper in a reciprocating motion (45 degrees to -45 degrees)

While simultaneously measuring data through a DAQ.

I have my DAQ sampling frequency set to 600[hz]

Currently I'm running the stepper in a loop something like this

motor.setTargetPosition(45)
while motor.getismoving():
acquireData()
time.wait(1)
motor.setTargetPosition(-45)
while motor.getismoving():
acquireData()
time.wait(1)

My data looks like it's being sampled at 50[Hz]. Is this because the motor phidget is checking if it's currently moving at 50[Hz]?

Is there a way to easily loop my stepper for 100000 cycles while acquiring data?

Re: Running motor loop in parallel with data acquisition

Posted: Fri Jul 20, 2018 3:14 pm
by mparadis
It's possible the other functions are slowing down the sampling. You can test this pretty easily by commenting out the motor functionality.

If you're using a Phidgets DAQ, I would recommend using events to gather data instead of polling for it. That way, the data and the motor settings will not block one another. If you're using some other library to get the data in, I would look to see if they have data events or some sort of asynchronous call in their API. If all else fails you could try using multiple python threads to accomplish the different parts of this program.