LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview program not running continuously when placed in while loop

Hello,

 

I am a graduate student and for my thesis I am building a bearing test rig. For the data aquisistion and control I am using labview in combination with a NI compactDAQ (NIcDAQ-9174). I am acuiring a signal obtained from a inductive sensor using a NI 9203. I also use a voice coil actuator connected to a NI 9264. For commisioning this rig I use a signal generator to generate a sine wave which is used as input for the voice coil actuator (he voice coil output should be the sine wave). The motion of the voice coil is measured with the inductive sensor. So I am expecting to see the same sine wave with the inductive sensor. For this I made a very simple and straight forward VI. I'm just using 2x a DAQassistant to accuire and generate a signal. The signal is generated with a signalgenerator VI. Both of the DAQassistant channels are set to continious sampling whith a sampling frequency of 1 kHz. All this is placed in a while loop. However the problem that I encounter is that the voice coil is following the sine wave for a amount of periods and then stops for a few seconds before it starts again. Because of the fact that is it placed in a while loop I expected it to run untill i stop the vi.

 

I think the vi is generating data and send it to the voice coil then stops to store this data (the voice coil stops) and then starts again. Am i right? and how can I solve this problem?

 

Kind regards,

Erik

 

Ps. I am not able to include the VI because labview is not running on this pc. I will include it as soon as possible if neccesary.

 

0 Kudos
Message 1 of 6
(3,747 Views)

Hi Erik,

 

simple solution: get rid of the ExpressVIs (aka DAQAssistent) and use "real" DAQmx functions.

 

You find a lot of examples in the LabVIEW example finder and the basics are explained very well here!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(3,730 Views)

I agree with Gerd (and have cited the same White Paper numerous times in this Forum -- it really taught me How To Use DAQmx).  Another "trick" is to create a Task (either with MAX or within your Project -- you are using LabVIEW Project, aren't you?) for configuring your DAQmx tasks, as you can bundle most or all of the configuration "details" (particularly the ones that are fixed, or constant, in your code) and get them out of the Block Diagram and into a defined Task Constant.

 

As for helping you find why your code is mis-behaving, it's pretty difficult to do so without seeing the code.  Do you have a Flash Drive (a.k.a. USB "stick")?  Copy the VI (or if you have several related VIs in a folder, compress the folder and copy the resulting .ZIP file) to the Flash Drive, take the Drive to the computer that you used to post the question, and now you can attach the file!  And we can make "informed" suggestions.

 

Bob Schor

0 Kudos
Message 3 of 6
(3,696 Views)

You're essentially trying to time your acquisition with that while loop.  Windows might not enjoy that.  Is there anything else running on your PC at the same time that could take precedence over your VI running and cause the behavior you're seeing?

0 Kudos
Message 4 of 6
(3,663 Views)

Hi Erik,

 

Some code would be useful here if you can upload it. Are you running the code using the run continuously button or the standard run arrow? If you are running with it on continuous then there may be issues with the DAQ task restarting if the while loop is set to stop.

 

Is the signal generation generating a signal that can match the acquisition rate of the program?

 

Another thing to try is using seperate loops for the signal generation and the signal acquisition so they are not waiting for one another.

 

Look forward to hearing from you

 

Pete

NI Applications Engineer

Certified LabVIEW Architect
0 Kudos
Message 5 of 6
(3,637 Views)

Hello,

 

The problem was indeed the DAQassistant configuration. So I solved it by using DAQmx code and minimize the tasks that are conducted in the while loop.

 

Thanks for the support!

 

Erik

0 Kudos
Message 6 of 6
(3,614 Views)