06-23-2009 09:03 AM
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
06-23-2009 09:26 AM
06-23-2009 09:30 AM
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
06-23-2009 09:38 AM
06-23-2009 09:40 AM
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.
06-23-2009 09:50 AM
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
06-23-2009 09:56 AM
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.
06-23-2009 10:09 AM
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.
06-23-2009 10:09 AM
06-23-2009 10:18 AM
Thanks guys,
i will give the soloutions a try.
Zac