From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop iteration time more and it increases with time

Hi all,
I created the attached LabVIEW program for giving cyclic input to the Physik Instrumente actuator (M-238.5PL). I wanted to take load feedback from NI DAQ 6251 to control the motion so that the offset of the generated signal get adjusted if the load becomes zero to keep the actuator always in contact with my sample.

I am facing the following issues:

 
  1. The loop execution time is more than 160ms and it increases continuously. the loop iteration time increase to 700ms after 20 cycles (200s) This increases the set frequency also. 
  2. The actuator doesn't take position values until it finishes the first command.
  3. I am not able to stop the motion by stopping the execution.
  4. For initialization, the actuator travels to mid position and gives up-down motion with full velocity.
  5. is there any way by which I can execute the loop in 2-3ms?
  6. I tried to generate the cyclic array outside the main loop in some other while to see if I can run the main loop fast. but it did not run this loop at all. Maybe I was not able to transfer the data from one loop to another continuously. is there any possibility to write the program like this?
 
I am very new to Labview and don't understand all VIs how they work. Kindly see if you can help me in solving any of these issues.
 I am using Labview 2014 and Windows 7.
Thank you in advance and Best Regards
0 Kudos
Message 1 of 5
(2,681 Views)

I might suggest that you look at the top of this board.   There are links to training resources.  

 

Spend some quality time looking at that material.   Then ask about what isn't clear

.

 

I'm not brushing you off,  but none of us voluteers can really restate basics that already exist  in established training materials exactly and every time we reply.  

 

We will be happy to help you learn...but you need a foundation to ask meaningful questions. 

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(2,675 Views)

The increase in loop time is due to how you are saving the data. Each iteration, the Write To Measurement File has to look at the folder and figure out what the next suffix is.  The more files in the folder, the longer that discovery process will take.  Do you really want a new file for every iteration or is 1 file good enough?  From what I am seeing, just 1 file is all you really need (and want).

 

So that is one thing to look at to speed up your loop.  As Jeff said, you really need to go through the online tutorials and pick up on the basics, especially on how data flow works.  Once you get that concept, I think you will find the feedback nodes are not desired and you need to rethink your order of operations.

 

Then if you really need a loop rate boost, look at the Producer/Consumer to handle your data logging.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 5
(2,657 Views)

@crossrulz wrote:

 

As Jeff said, you really need to go through the online tutorials and pick up on the basics, especially on how data flow works. .


As a related comment, why would you place an entire array into a feedback node if all you are interested is the first element?) Also note that the array feedback node is definitely used wrong, because it delays the data written to the file by one iteration, while the other things (e.g. elapsed time, etc.) are from the current iteration. Typical race condition leading to inconsistent data. Also that silly internal pause loop is just plain ugly (and because if the above mentioned race condition, pausing like this could really mess with the validity of the saved data. It could e.g. combine an ancient array (from right before the pause) with a very long dt (from right after the pause!)). I would recommend to write a proper state machine, it's not that hard. 

 


@crossrulz wrote:

The increase in loop time is due to how you are saving the data. Each iteration, the Write To Measurement File has to look at the folder and figure out what the next suffix is.  The more files in the folder, the longer that discovery process will take.  Do you really want a new file for every iteration or is 1 file good enough?  From what I am seeing, just 1 file is all you really need (and want).

 

So that is one thing to look at to speed up your loop.


Yes, that express VI is gigantic, but it seems slightly more efficient internally than what was discussed here. 😮

 

0 Kudos
Message 4 of 5
(2,640 Views)

Thank you everyone. I was spending some time on tutorials and notes to better understand what should be done here. 

I have done following changes. Let me know if they make sense.

1. Acquire load value in a separate while loop and bring in main loop via local variable.

2. I removed the save file express vi from while loop and placed "export data to excel" at the end of the loop.

3. I removed the position feedback node and placed as input.

4. I removed the express vi for signal simulator and placed trianglur signal simulator as I need triangle wave only.

5. I removed the pause things from the loop.

 

There are few questions in my mind which I could not find solution for.

 

Can I make another while loop for signal simulator and brings the data to main VI? How can I generate more data points in the triangle signal as if I increase more than 100 samples, it creates second cycle than adding more points to first cycle. I need more points for smooth motion.

 

Thanks for your suggestions.

 

0 Kudos
Message 5 of 5
(2,574 Views)