LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How would I implement a FOR loop in real time?

I am using a cRIO and would like to have several processes running in parallel.  A main functin will have a loop in it which will count up and an certain time intervals pass data to a parallel process.  I am not sure how LV will check the current time value and determine if it is time to send the parallel process information (it will send the parallel process a command to start at time X and stop at time Y).  I see the code in C as:

 

 

for (i; i <= 60; i++)

{

     if (i==30)

     {

        Function(1); //send "1" to function to  start action, equivalent of setting a variable in LV and continuously reading that variable in the parallel function

     }

 

     if(i==45)

    {

        Function(0); //send "0" to function to stop condition

    }

    delay(1second);

}

 

I am confused about how to create a loop that has a predetermined (changeable) time period that allows me to compare the timer to set times (i.e. 30 and 45) and perform a function if they are equal.  I can handle that compare part but I am not sure how to implement the loop.  Any help would be greatly appreciated.

0 Kudos
Message 1 of 2
(2,564 Views)

Hi,

 

Why don't you use "Elapsed time.vi" ? Compare it with the time you require. Also you can use register event function to let the other process know a certain condition has occurred.

 

 

 

 

Gaurav k:smileyhappy:

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 2 of 2
(2,551 Views)