09-08-2011 01:23 PM
I have an encoder attached to ctr0 on a 9401 card in a cDAQ 9178 chassis. I can communicate with the encoder on-demand just fine, but now I want to sample using a clock source. The problem is every internal clock I choose seems to setup just fine, but when my program gets to DAQmx Read it just hangs. No samples are being returned. The only clock I have found that works is 100kHztimebase but I do not want to sample that fast. I want around 5KHz. Most sample code I have seen use the ctrXInternalOutput clocks. What am I missing here?
09-08-2011 02:23 PM
HI Citabria-
If you want to sample at 5Hz (or any other rate) then you'll need to specify and supply a sample clock. You are on the right track in choosing a counter output, but in order for that to be functional you need to actually supply the required sample clock. Since you are already using ctr0 for the encoder input (note that ctr0 on a module refers directly to ctr0 on the chassis; fortunately there are 4 total to work with), a better choice might be to use ctr1 or some other available counter.
Then you will need to actually generate the counter signal. Since you're in LabVIEW, you can pull up a counter example from the NI Example Finder (Help>>Find Examples) like "Gen Dig Pulse Train-Continuous.vi". Select the counter that you want to use for the clock generation, update the encoder task to use that counter's "...InternalOutput" and make sure that the encoder task is started first so that it is waiting for clocks from the other task.
You may also want to adjust your Rate (DAQmx Sample Clock) and Samples to Read (DAQmx Read) to be reasonable given the clock rate you choose.
Hopefully this helps-
06-11-2013 05:58 PM
Hello,
Would you mind expanding a little more. I have been trying to figure this out for a few days now and still cant get it to work. I am not an EE. I am used to using the daq assistant more. I used the example "counter - continuous output" as my clock source. I could not find the example you suggested. I am using the example "counter - read encoder (continuous clock)" for the encoder portion. I basically copied the 2 examples into a new .vi.
My specific questions are:
1. how to i make sure the encoder task is started before the counter task. I ran the .vi and then enabled the counter by placing it in a case structure with a button to enable after a second or so.
2. how can i tell if my counter is actually outputting the signal?
3. for this example, what is a correct arrangement of counters and terminals. I have the counter output on ctr0, via terminal PFI3 and the encoder counter set to ctr1 with input terminals PFI 4 and PFI 6, while the sample clock source is Ctr0InternalOutput.
4. what are guidelines for sample rate and samples per loop? I set the encoder to a higher sample rate (5k) than the frequency of the clock signal (1k).
file is attached and 2 screenshots below.
thanks so much!
06-11-2013 06:36 PM
I found out what was wrong just after posting, hahah :). I had set my counter output set to be from my 9401 module instead of the chassis (cDAQ1Mod5/ctr0 instead of cDAQ1/_ctr0), so there was a mismatch between what was being output and the setting for clock source in the encoder code (cDAQ1/_ctr0InternalOutput). Be careful.
thanks tom for your post.