LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Linking Data Acquisition and Motor Movement

Solved!
Go to solution

Hi,

 

I am using LabView 2023 Q1 to create a motor control and start data acquisition. I am using a ThorLabs KDC101 Motor Controller and a simulated data acquisition tool through NIMAX (a USB 6361 - BNC). The general idea is: the motor will move by a set step size, the motor will stop due to a preset delay, during this delay data will be acquired and written to a file, and the cycle repeats until the end position is reached. After the end position is reached, I want to average the data values in each row of the file and obtain one vector.

I have achieved the motor movement, but the time delay I have step up between steps keeps returning an error (Thorlabs.MotionControl.DeviceManagerCLI.MoveTimeoutException. I am also struggling on how to write the data I am simulating to a file.

 

0 Kudos
Message 1 of 6
(1,054 Views)

If you could post the VI or VIs you have made so far we could give much better advice.  If you do, it's best to use File»Save for Previous Version to  save it as 2020 or earlier since a lot of us don't use the most recent version.

 

I have used Thorlabs before and the error you are mentioning usually happens because the motor move doesn't complete before the timeout you set.  The default timeout is pretty generous so if you get this error it's often because you have done an exceptionally slow and/or long distance move, or because you lowered the timeout value quite a lot.

0 Kudos
Message 2 of 6
(1,041 Views)

Thank you for your reply. I attached a zip file with my project and VI. Do you have a recommendation for how long I should set the time out?

AnnahMarie_0-1687362565801.png

 

0 Kudos
Message 3 of 6
(1,030 Views)
Solution
Accepted by AnnahMarie

Kyle97330_0-1687393227658.png

50 ms is definitely too short of a time...

 

I usually use a fairly generous timeout, something like taking the time I expect each motor move to take, then adding 5 seconds.  Generally Thorlabs will get very close to position pretty close to the expected time if you take the acceleration, deceleration, speed, and distance to move into account, but it seems like sometimes there's a bit of time at the end where it does a fine adjustment to get to the exact position, so you want to be pretty generous to give it time to correct the last few microns that it's off-position before it declares itself done moving.

Message 4 of 6
(980 Views)

Thank you very much! Follow-up question: I am attempting to save my simulated data to an excel file.

 

Currently, all simulated data is saving in one column, no matter how many iterations of measurements are taken (for example, if I set the motor step size to 1 and end position to 4, there will be 5 iterations). I would like my data to save to an excel file with iteration amount of rows and number of samples amount of columns.

 

I'm only using one channel, so if I try to use an array, I am unsure how to change it since my data is 1D.

 

AnnahMarie_0-1687466737129.png

AnnahMarie_1-1687466766719.png

 

0 Kudos
Message 5 of 6
(957 Views)

You could try wiring the waveform output to the edge of your while loop, right click the output tunnel to change it to "indexing", and then wire the 1D array of waveforms you get to this VI:

 

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/vi-lib/waveform/wdtfileio-llb/export-wavef...

 

 

0 Kudos
Message 6 of 6
(913 Views)