10-04-2011 08:43 AM
Hello
I want to measure the time elapsed between activation of two boolean variables/indicators. In my code I have DAQ acquiring 2 digital signals which trigger corresponding 2 boolean indicators. Now I am trying to measure time between the event when my first boolean indicator gets the signal and the event when my second boolean gets the signal. I am attaching my code. I checked DAQ and my indicators everything works fine, but just when I try running the code with the 'elapsed time' part, its not running. Any help will be appreciated.
Thank You.
10-04-2011 09:39 AM
Any help will be appreciated.
10-04-2011 09:45 AM
So, feel free to give more detail. I'll just give you a couple thoughts:
1) The primary issue with your code is that it probably doesn't do what you think it does. How this VI will run is that it will get one data from the DAQmx routine, then pretty much stay in the inner while loop since the event structure has an indefinite timeout. Worse, I don't think changing the value of the boolean controls would trigger the value changed event anyways. In the end, you don't even need the Event Structure to do what you want to do, nor do you need the inner while loop. Just check the values for each iteration of the outer while loop instead and do what you need to do with those.
2) You are acquiring only one data point at a time. Which is OK if your events are particularly slow with respect to the effective sampling rate of the of loop (which might be able to pick up signals that change on the order of milliseconds or perhaps a bit less). If your signals are faster, you need to think about reading lots of samples at a time (arrays of booleans) and properly triggering your acquisition close to the event it needs to pick.
3) If your signal is a pulse, make sure that the pulse width of the signal is much longer than than 1 / sampling rate. If it isn't, you could miss the pulse entirely doing this approach.
4) The faster signals (as long as your have a quick enough sampling rate), the best thing is always to use a counters approach. In many of the DAQ cards and peripherals that NI offers, there are counters that can be driven with the sample clock (one of the fastest clocks on the device) or even a faster time base, and then the 'events' can be used to trigger acquisitions of the counters. Meaning you get exactly what you want: data points that correspond to times when events occur.
10-04-2011 10:04 AM
Thank you for earlier reply.
I have 2 photocells connected to a circuit board whose output goes in DAQ(NI 6212 Model). When light falls on the first photocell which is corresponding to the first boolean indicator, it shows output(i.e lights bright) which is when I want to start measuring time. Then when light falls on the second photocell , the second boolean indicator shows output and at this occurnce I want to stop measuring time.
10-04-2011 10:35 AM
Can you suggest me a different way to measure the time between occurence of the two events mentioned above.
10-04-2011 10:40 AM
What do you expect the time between the events to be and what time resolution do you want?
10-04-2011 10:42 AM
I expect the time between the two events to be around 5-10 seconds. Resolution could be 1 second.
10-04-2011 11:05 AM
I dont need to have any specific resolution. 1 second is fine.
10-04-2011 11:09 AM
Maybe something like this. I dunno if you can gets edges or not with your device. If your DAQmx Express VI can only get the current value on the DI lines, then this should do it. If it can give you a true for a positive trigger, you don't even need this much.
10-04-2011 02:08 PM - edited 10-04-2011 02:25 PM
Try something like this. Modify as needed.
Of course you might need to fine-tune it for exception cases: What should happen if LED2 goes on first? What should happen if LED1 goes on, then off, then LED2 goes on? etc.