LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I save the data of a while loop without affecting my PID control?

I'm developing a software for my Master Thesis to control a motion platform. The platform is actuated by an hydraulic cylinder. Due to control it I have developed a PID control. The problem is that when I try to save the analog data of the cylinder sensor from the DAQ on a .txt file, the problem doesn't work or save only one value.

 

Without the Save to ASCII/LVM vi, the program works perfectly, but when I place I have two problems:

 

If i place it inside the while loop, i get some data, but the PID stops working and the platform just move randomly. (See figure1)

If I place it outside the loop, the program works perfectly, but it only save the last value of the sensor. (See figure 2)

 

Can somebody please help me? I'm just a beginner in Labview and I will really appreciate your help.

Download All
0 Kudos
Message 1 of 4
(4,263 Views)

If it is outside the loop, you only get the last data because you are sending out the data from the last loop iteration.  The data from prior iterations are lost.  (By the way, the shift register serves no purpose in your picture.)

 

Inside the loop, you are probably getting errors due to variation in timing in how long it takes your PC to write out data to a file.  Use a producer/consumer architecture to pass data to a separate data logging loop by way of a queue.

0 Kudos
Message 2 of 4
(4,262 Views)

Wow Ravens! What a fast answer! Thank you very much.

 

So you think I should place the save vi inside the loop, right? Could you please explain me in other words what's " Use a producer/consumer architecture to pass data to a separate data logging loop by way of a queue"? Sorry for maybe asking this easy questions, but I'm a mechanical engineer and this is the first time I'm using Labview.

 

Thanks again!

0 Kudos
Message 3 of 4
(4,245 Views)

Janpros,

    As Ravens stated, your best option is to try and use a queue system. I've attached an example. The queue allows your loop with the PID controller and the loop saving your data to run independently of eachother, while still saving the data and stopping in unison. Another option, if you know how many data points you want to collect or how long you want the program to run, would be to place the data into an array (of known size), then write the entire array to a file after you exit the while loop. See if this gets ya started and let us know if it works.

0 Kudos
Message 4 of 4
(4,239 Views)