03-26-2013 06:06 PM
Alrighty, I'm a total noob to LabView and the like. I'm at the point where I don't even know if what I know is relevant, so pardon if I give way too much information and probably not enough.
I've got:
cDAQ-9174 chassis
9422 module in slot #2
This 9422 module is going to be connected to a flow meter which is going to send a square wave signal. What I need is the frequency of the square wave. Trouble is, I don't have a clue how to get it.
I open a new .vi and use the DAQassist. From there I select Counter Input and then I've tried both Frequency and Edge Count.
Ultimately, either one usually gets me the following error:
Error -200284 occurred at...
Possible reason(s):
Some or all of the samples requested have not yet been acquired.
I guess the one I've researched the most is the Edge Counting. This is continuous samples because I need it to monitor the flow rate in time rather than just counting the edges from time 0 until I stop the VI. So there are various ways of handling this error which include changing the timeout value, something to do with "samples to read" and "sample rate", and then the one it would seem I need to do: Since the continuous buffered one requires an external clock, which is specified on the "Advanced Timing" tab of the DAQassist properties menu I've got a whole host of things to select from. It would seem /ai/SampleClock or /ao/SampleClock is the thing to select, but then multiple webpages keep saying to make sure that external clock is actually "running", or some word along those lines. So I figure, my external clock isn't actually doing anything and that is why the read doesn't acquire the samples. But really I'm just lost. So...
Question 1:
Is what I'm working on the best/right way to go about doing this?
Question 2:
How do I make sure this external clock is doing whatever it is supposed to be doing so that I can have continuous samples for edge counting?
Alright, my ignorance is exposed, please fire away. I've attached the .vi, though I don't think it's going to tell you anything other than I know how to click the mouse button while running LabView.
Solved! Go to Solution.
03-27-2013 11:15 AM - edited 03-27-2013 11:20 AM
The edge count is timing out since you do not have a sample clock. You can provide one from a number of sources, but in your case I'd suggest sticking to a frequency measurement task so I won't go into it right now.
The frequency task could be timing out for a number of possible reasons:
1. The external signal is not connected to the right terminal (the default GATE terminal for your chosen counter if you have not overridden it with a DAQmx property node which isn't possible in the DAQ Assistant). For the 9422:
2. The signal might be connected to the right terminal, but perhaps it does not meet the specifications of the 9422 to be detected (<5V low, 11-60V high). You can verify whether or not the signal is being detected using a test panel (counter edge counting to determine if the signal is present) in Measurement and Automation Explorer.
3. Frequency tasks are sampled off of the input signal--so if the input signal is not toggling when you start the program or if there is a long pause (longer than the timeout you specify) then you'll receive the timeout error when the read function blocks for longer than your specified timeout. You should be able to simply "handle" the timeout error so that if it occurs you can report a 0 frequency, discard the error, and try the read again. There are also other approaches like using DAQmx Events or polling Available Samples to Read, but neither of these are available via the DAQ Assistant (the idea is that you avoid making the blocking DAQmx Read call until you know there are samples to be read).
Configuring a frequency task is a better option for you as it will give more accuracy (although you can configure an edge count task to behave similarly to a frequency measurement task, it's trickier and you also cannot use the DAQ assistant). You can start out by configuring 1 Sample (On Demand) for the timing mode--this will return a single sample whenever it is available. If you put the DAQ Assistant in a loop, you will get a new sample on every iteration (or if your input signal goes away, the samples will stop coming in and you will get timeout errors instead). The downside to this is that you will not receive a sample on every edge--the input task is re-armed by software and so during this downtime between samples you will not take any new data. This should be fine for the use case you have described (periodically monitoring the frequency of a continuous square wave).
So, make sure the external signal meets the specifications of the 9422, and it is connected to the correct terminal (the PFI line that defaults to the GATE of your counter). If your external signal is below 0.2 Hz (1 sample every 5 seconds) you'll need to move away from the DAQ assistant, as it seems that it is not possible to set the read timeout using the DAQ Assistant (which is surprising). You might want to look into the lower level DAQmx API anyway--here's a simple example to get you started if so. It's really not too complicated and once you get used to it will be less cumbersome than using the DAQ Assistant.
Best Regards,
03-27-2013 02:45 PM
Thank you for pulling my head out of my sand. We're up and running!