03-31-2009 12:02 AM
Is there a node or way getting an impulse from one source to stop checking the other?
03-31-2009 12:20 AM
When you read both signals, build them into an array and then use the "search 1D array" function to determine which of the signals came back "T". Then base your decision making on that (i.e. element 0 came back "T", so give the animal a treat) and use a case structure to execute the appropriate code.
03-31-2009 12:23 AM
04-01-2009 06:45 PM
04-01-2009 08:13 PM
Here is a picture showing what I suggested in my previous post. If the animal trips one of the signals, the loop will stop.
04-01-2009 09:08 PM
Currently I can only get one line in. Here are two pics, one of my current sub vI for checking the infrared set up and another for selecting between the choices
Thanks again
Josh04-01-2009 10:30 PM
Hi Josh,
Here is the reason your VI isn't working:
In order for your sub-VI (infrared checker) to stop executing, the digital line must return a value of "T". A "T" value is what stops your loop in your subVI. Therefore, in your outer loop, you have to have both of your subroutines return "T" in order for the loop to iterate. (the loop can't iterate until all of the subroutines inside of it have finished executing.) That is why the animal has to trip both lines before your outer loop will stop...both of your subVIs need to finish executing, and they can't finish executing until the digital line has returned a "T" value. Does that make sense?
In the picture I showed, both lines are read at the same time, so only one of them has to return "T" in order for the loop to iterate.
You either need to read both lines at the same time, as I showed, or you need to remove the loop from your subVI. When you remove the loop from your subVI, you'll essentially be duplicating what I showed you -- you'll just be using two tasks to accomplish what I accomplished with a single task.
To read both signals with a single task, you need to tell the task to read both lines simultaneously. I did this by specifying two digital channels: lines 0 and 1. (look at the syntax for the physical channel in my picture) Then use the same DAQmx Read instance that I used: multiple channels, single sample.
If you want to do this using a task in MAX, simply specify lines 0 and 1 (or whichever lines you're using to read your signals) as the physical channels for that task. Use <ctrl> to select multiple lines, the same way you'd use it to select multiple files in any Windows application.
Hope that makes things clear...
Diane
04-02-2009 12:53 AM
04-02-2009 09:57 AM
Good luck with your field trip. 🙂
You will want to add a small delay time to your loop, to ensure that it doesn't hog up the entire CPU. You will also want to add a "stop" button so you can exit out of your routine at will. Using the "abort" button to stop a VI is NOT good practice.
Also note that I have assumed that a returned value of "T" means that the animal tripped one of the sensors. If a "F" value means that the animal tripped one of the sensors, you will need to adjust your loop-stopping logic accordingly.
The attached picture shows the time delay and a "stop" button. I'll leave you to play with your own Boolean logic so that it fits your needs.