Running motor loop in parallel with data acquisition

Supporting 2.7 and 3.2+
Post Reply
gdeol
Fresh meat
Posts: 2
Joined: Mon Jul 16, 2018 12:47 pm
Contact:

Running motor loop in parallel with data acquisition

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

Re: Running motor loop in parallel with data acquisition

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests