LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to set the code's running time to 2 sec/ 3 sec/ 5 sec

Solved!
Go to solution

Hi,

 

Sorry for disturbing you. 

 I want to introduce/control the run time of code.

 If you don't mind, could you please advise me if I want to control the code running by the time? I want to set the code's running time to 2 sec/ 3 sec/ 5 sec; for that, which subVI or function could I use?  
I attached the code (LV19) version.
 
Kind regards
Hasham
 
0 Kudos
Message 1 of 31
(766 Views)

I got solution by adding elapsed time within while loop and its working....

 

 

 

Kind regards

 

Hasham

Message 2 of 31
(737 Views)

Why do you keep attaching the same Rube Goldberg code over and over again, even though we told you how to simplify it by 90%! (... and please don't maximize the front panel and diagram to the screen!).

 

If you want to stop the loop after a certain time, it should be a while loop because you don't know the number of iterations unless you have a defined loop time. Do you? If you would define a loop time using a suitable wait, you could keep the FOR loop and calculate the number of iterations before the loop even starts. No need to even measure the time.

 

There are much easier ways to measure elapsed time than a gigantic express VI. You already measure the elapsed time, so all you need is a "greater than" comparison to stop the loop!

 

This is still an one-shot downhill program that requires the run button to start. Shouldn't this be a proper state machine instead?

Message 3 of 31
(702 Views)

Hi,

 

Thanks for your reply; yes, you are right; I tried, but I stuck to this code as it is working, and I use the elapsed time function to set the total time run and. I will also try your suggestions and share an update with you.

 

Once again, thanks.

 

Kind regards

Hasham

0 Kudos
Message 4 of 31
(669 Views)

Hasham622x_0-1720520216898.png

Hi,

 

I am using this elapsed time VI is this Ok to use with WHILE loop.

0 Kudos
Message 5 of 31
(659 Views)

Hi Hasham,

 


@Hasham622x wrote:

I am using this elapsed time VI is this Ok to use with WHILE loop.


It's "ok" as long as it works for you...

 

We still strongly recommend to cleanup your code by following our suggestions! (Cleaner code is much easier to maintain!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 31
(648 Views)

Hi,

 

Thanks for your reply and you are right. I prepared the test code by following suggestions and changes in the current code, and tomorrow, I will try that code and then share an update.

0 Kudos
Message 7 of 31
(642 Views)

Hi,

 

First of all, thanks for the guidance. I tried both options to simplify the code. A Simpler approach is working, and the best approach, unflatten/flatten subVI based, is not working in which I am making any wrong connection within a FOR loop / conditional loop due to that it is giving only for columns of an array whose all values are zeros.

I attached both codes (LV19) with this message.

 

Kind regards

Hasham 

Hasham622x_0-1720669694442.png

Hasham622x_1-1720669720889.png

Download All
0 Kudos
Message 8 of 31
(607 Views)

Hi,

 

First of all, thanks for the guidance. I tried both options to simplify the code. A Simpler approach is working, and the best approach, unflatten/flatten subVI based, is not working in which I am making any wrong connection within a FOR loop / conditional loop due to that it is giving only for columns of an array whose all values are zeros.

I attached both codes (LV19) with this message.

 

Kind regards

Hasham 

Hasham622x_0-1720669694442.png

Hasham622x_1-1720669720889.png

Download All
0 Kudos
Message 9 of 31
(606 Views)

Hi Hasham,

 


@Hasham622x wrote:

the best approach, unflatten/flatten subVI based, is not working in which I am making any wrong connection within a FOR loop / conditional loop due to that it is giving only for columns of an array whose all values are zeros.


Nobody told you to use orange wires in this conversion step: so why did you use them???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 31
(591 Views)