07-26-2010 11:28 AM
I am using the USB-6009 to control pnuematics raising and lowering baskets into oil and water. I want to be able to control how long the baskets sit in each one and control timing for moving the basket from one to the other. Whats the best way to acheive this? Also, i want to have counters in the VI to show when each of the four switches is latched, which will also be wired into the USB-6009??
07-27-2010 04:12 PM
Hi Chris,
Do you have any code that you have been developing? Can you get 6009 do do each of these individual actions? If you have your system well documented with a state machine architecture you can easily move that into a state machine implementation in LabVIEW. Select New… VI, from Template, Frameworks, Design Patterns and then Standard State Machine to get an idea for a basic architecture. In your state machine you can implement the code to wait a certain amount of time before moving to another state.
07-27-2010 04:17 PM
Thanks! I just created my own time delay VI's inside each for loop and that works fine. The only thing i cant figure out is how to count each loop? They run in a series of 7 loops, each with their respected times, but i always get one on the indicator. Im assuming this is because I have the constant 1 wired to the N terminal but I would like it to count from start to around 1 million, for each of the 7 loops. Any suggestions?
07-27-2010 04:41 PM
Post your code. Usually if you want to see the number of loop iterations, you wire an indicator to the loop's i terminal.
07-27-2010 04:50 PM
Thats not working because its 7 "for loops" inside a larger "for loop." I need some type of counter but the ones i tried wont work. Ill attach the code so you can take a look. Thanks
07-27-2010 06:06 PM
Except for your first inside loop, the others should count fine. Put the Numeric indicator for the first loop inside the loop. They all will just count to 0 because you wired a 1 to the N. That is telling the loop to run just once (the i starts at 0). Now the outer loop will run again, but the inner loops will all start at 0.
Each loop should have a small delay, Wait(ms), in it to prevent using 100% CPU time.
You don't need a conditional stop in the for loop unless you want to abort manually before the number of cycles is reached.
There is a better way to do what you are doing. Each loop contains the exact same code except for the boolean array. If you create a 2D array from each boolean array, and pass this 2D array to just one loop, each row of the 2D array will be fed to the loop for processing. The following code will do the same as your huge block diagram.
07-28-2010 09:31 AM
Thanks I will try the other way too. It still will not keep count in the rest of the loops, the only one that works is the complete cycle indicator? Is there any other way that i could count each loop by some built in counter or anything else bc i need this to work? Thanks tbob
07-29-2010 11:00 AM
The “Count for total Cycles” indicator will tell you how many times it has already iterated, and each block of Boolean data will go once for vector of digital data you give to the DAQ assistant. There is one small error in the code posted by tbob. The constant “1” connected to the inner “for loop” will cause it to end early. If you remove this value you should get a better experience for that code.