10-17-2013 05:51 AM
I have been battling this problem for a week, and I keep think I am getting somewhere and then get caught out due to my lack of labVIEW experience.
I am using simple push to break switches and wish to find the time between taken between these switches.
I am aiming to get 10s of microsecond accuracy
I wish to use the first switch as a trigger for the system so that this is regarded as time zero.
Attached is my current vi, which has undergone many changes in the past week.
In this instance I am using a structure to continuously look at the trigger channel until it reaches a threshold voltage. When this occurs it triggers the aquisition of all other switches. (I am currently just recording this so I can look up in excel and find the time switches are made, however I eventually want labview to do this. Any help on this would also be useful). I have put a crude timing mechanism in to see the time difference between triggering and data aqcuisition starting and this give a 32 ms difference. Ideally I want this in us.
So my main question is:
Is my vi the right way to go about what I want to do? If so how could I speed up the structure.
If not what ways would you suggest for me to get the results I want?
Regards
T
10-17-2013 07:50 AM
I am not sure I understand what you are trying to do, so let me rephrase it. At some point in time, you have a switch that is being pressed. You wish to measure the time between that switch being pressed and other switches being pressed accurate to about 10µs. If this is the case, then you need to rethink how you are approaching the problem. Modern operating systems, such as Windows and Linux, are multi-tasking and do not do time intervals too well. There are too many things which can interrupt your timing. As a broad rule of thumb, do not depend upon the operating system for timing any better than about 50ms. You can get microsecond resolution by using the high performance counters of most processors, but interpreting the result can be difficult. In your case, there is a far better solution - use your DAQ board. It was designed to do such things accurately and repeatably. You have several options:
If you need more information, please let us know what type of DAQ board you are using and the signal levels of the switches.
10-18-2013 05:09 AM
Thank you for this response.
I have been using the second approach. The restraints leave me only able to grab 10s of data,(any longer and I get error messages) which is fine because I require less than 1s.
However I need to create a trigger by using the first input, which so far are surpassing my LabVIEW skills.
I am using a cDAQ-9174 with two 9223s for my switch inputs.
Currently the switches that I am using are as basic as possible and two wires connected/disconnected and I am analysing the voltage for these. (This will change when I get round to experimentation)
As you can see from my vi. I am using a somewhat brute force method to analyse the data acquired but it does the job. I am sure there is a much neater way to do this.
10-18-2013 09:55 AM
10-18-2013 10:55 AM
Use a DAQmx Trigger.vi from the DAQ palette to set up triggering on your first switch channel. I would recommend a few pretrigger points. The following code may make your switch location finding a bit easier. It relies on the threshold VI from the array palette.
10-18-2013 11:28 AM
I will attempt to use the DAQmx trigger, however I tried to use this before and I didnt think it worked with my hardware.
Would this not also add a short delay into the acquisition? even a small change could affect my results.
Thanks to both of you for your input, I will implement these ideas next week.
10-21-2013 07:59 AM
Thank you for again for the help.
I have implemented a more elegant solution to my brute force method.
I am still struggling with creating a trigger to start recording the data though.
Ideally I want to do this from the initial switch, which is an analog input. The trigger.vi does not seem to accomodate this with the 9223 module.
I have tried using the DAQ assistant trigger and gate and can use this to get a trigger from this analog input of the ni9223.
How am I able to do this but not able to do it with the trigger.vi
I do have a ni9401 module, however I am not sure I understand completely how to use it and therefore are hesitant to introduce it.
Any input would be appreciated
10-22-2013 08:42 AM
Attached is a VI with the triggering added. I believe your confusion stems from the difference of the Start trigger and Reference trigger. The Start trigger starts the clocks and data acquisition mechanism. This is when the DAQ boards start actually taking data and buffering it, but not passing it to your code. This is usually set to None, so the DAQ board starts as soon as it is initialized. The Reference trigger is the one you want. When the reference trigger is satisfied, the DAQ board acquires the number of points you specify, prepends the pretrigger points it had buffered, and passes that back to your code so that the Reference position is the trigger point you specified.
Hopefully this helps. Good luck and let us know if you need more assistance.
10-23-2013 03:16 AM
Thank you for going to the effort to write this, unfortunately I cannot get it to run.
I get an error from the trigger.vi with reference to the source being used.
Firstly it does not give me the drop-down box menu that is usual when supplying an input.
It does not accept any of the analog inputs from my 9223 modules and supplies me with the error:
Error -200265 occurred at Property Node DAQmx Timing (arg 1) in Time of arrival with sample rate with trigger (1).vi
Possible reason(s):
An attempt has been made to use an invalid analog trigger source.
Ensure that the trigger source you specify matches the name of the virtual channel in the task or matches the name of a non-scannable terminal that the device can use as an analog trigger source.
Property: Ref.AnlgEdge.Src
Corresponding Value: cDAQ2Mod1/ai0
Valid Choices: none
Device: cDAQ2
Task Name: _unnamedTask<1>
Have you encountered this before?
10-23-2013 08:06 AM
You do need to get the source exactly correct and there is no real help to do so. I filled it in based on the input channels of your system as I got them. In general, it should be DeviceName/ChannelName. You can get both of these from the list in your I/O name control you use to initialize the analog acquisition. Or you can get them from MAX.
I tested my code with simulated devices, since I do not have your hardware. It is possible that this will not show the errors you are seeing. I did see a similar error when I got the format of the trigger channel wrong, but I also got suggested Valid Choices (which, unfortunately, were not actually valid, so I would approach this with a grain of salt). In any case, you have exhausted my meager knowledge of DAQmx. I would suggest you repost your question with the latest VI on the DAQ forums. You will probably get a response very quickly. My apologies for not getting you further. Good luck!