LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

different loop speeds

Hi Guys,

              i have a program that runs in a single 1 second loop, the program reads variables from a set point file and controls a system whilst recording data to a log file.

 

The variables in the setpoint file are read at intervals expressed in the file, e.g the file consists of a list of times and values the values will be read at the time spesified, so you can ramp up control signals etc....

 

one item being controled is a simple on/off solenoid valve, currently i can spesify an on and off time down to the second, but i need to be able to control this valve down to 10 or 100ms.

 

How can i do this if my main loop is 1 second, i need to find a way of updating this value every 10ms within a 1 second loop.

 

Thanks, Zac

0 Kudos
Message 1 of 10
(1,484 Views)
If you main loop is a timed loop, you can wire the period for the next iteration to the 'right data node'.
0 Kudos
Message 2 of 10
(1,476 Views)

the loop has a wait 1 second in it, but i don't want to change the itteration time of that loop as i want it to do every thing once per second, its just that i want the program to do somthing else at a higher frequency at the same time...

 

cheers zac

0 Kudos
Message 3 of 10
(1,472 Views)
Put another loop inside of it such as a for loop that runs 100 times with a 10 msec wait.
0 Kudos
Message 4 of 10
(1,466 Views)

I that case you might need two loops.

 

The first one setting you 1 second timing and the second executing a queue of commands based on the first loop.

0 Kudos
Message 5 of 10
(1,464 Views)

RavensFan,

                   if i put one inside another wont it just sit in the inner loop and never perform actions in the outer loop ?,    or is that what the 10ms wait is for ? will that allow it to come out of the inner loop and exicute the outer loop ?

 

 

jack47,

             there are a couple of things on your diagram that i am unfarmilliar with, could you name them for me so i can read up... (see attached)

 

 

cheers, zac

0 Kudos
Message 6 of 10
(1,457 Views)

Those are queue functions.  When I need to do what you are discribing, I form the queue of commands in the first loop and exectue them in the second.  Basically you add 'strings' to the queue in the order you want them exectuted in the main loop, then the top loop extracts them one at a time.  If you set each 'case' in the second loop to a 'string' that is added to the queue you can exectue the cases in different orders.

 

For example if you had a 'turn off solinoid' case, 'wait 10ms' case and a 'turn on solinoid' case.  If you wanted to wait for 20ms after turning it one your queue would be:

 

turn on solinoid

wait 10ms

wait 10ms

turn off solinoid

 

That way you could adjust the exectution with the smallest number of cases.  There is a lot of information on queue commands in the labview help.

0 Kudos
Message 7 of 10
(1,451 Views)

RavensFan,

                   if i put one inside another wont it just sit in the inner loop and never perform actions in the outer loop ?,    or is that what the 10ms wait is for ? will that allow it to come out of the inner loop and exicute the outer loop ?

 


The inner loop would be a For loop.  It will run 100 times and stop, outside the for loop but inside the outer while loop is your other code.  So the inner loop will run 100 times for each iteration of the outerloop.

 

Another alternative is to run a single loop at 10 msec.  Have you ever iteration code inside of that.  Have the code you want to run only once per second inside a case structure that only executes on every 100th iteration of the while loop.

 

These are two quick dirty ways to get something working.  They aren't necessarily the most expandable.  If your code gets more complicated, then you will need to look at more advanced program architectures.

0 Kudos
Message 8 of 10
(1,441 Views)
I added more detail to my screen capture.  Showing the enqueuing of the data.  This one also uses a cluster for the queue element so you can bundle the wait time in with the queue command
0 Kudos
Message 9 of 10
(1,440 Views)

Thanks guys,

                     i will give the soloutions a try.

 

Zac

0 Kudos
Message 10 of 10
(1,434 Views)