Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter read timing with analog scan clock

I am using a counter to keep track of an encoder position. I am trying to read (probably will need to be a buffered read) a counter in sync with my analog scans (1000 Hz). I am using a 6036E board and cannot figure out how to route the scan clock to the counter gate (not 100% sure this is even the correct way to do this).

I've searched NI's examples and the only thing I have come across is using the counters to time analog input.

Any help would be greatly appreciated!

Thanks,

Jesse
0 Kudos
Message 1 of 6
(3,948 Views)
Hey Jesse,
I'm not sure if you are using Traditional NI-DAQ or DAQmx, but I am going to assume you are using DAQmx. If you take a look at the "Count Digital Events-Buffered-Continuous-Ext Clk.vi", and then look at the Timing Parameters on the front panel. You can choose the Sample Clock Source for this specific Counter. Here you can find a couple of options that you might try, such as ai/Sample Clock or ai/SampleClockTimebase or ai/Reference Trigger. You can incorporate this VI along with your Analog Input scans (AI Read). Try to take pieces of code from example programs and work them in with your program or other example programs. Hope this helps. Good Luck.

DJ
0 Kudos
Message 2 of 6
(3,928 Views)
I should have mentioned that I was using Traditional DAQ. I haven't work much with DAQmx yet - but maybe it's time I started trying to using mx.

Thanks.
0 Kudos
Message 3 of 6
(3,926 Views)
There is a lot more that you can do with the DAQmx driver. The DAQmx VI's also have a lot more options and flexibility. But if you are still wanting to use the Traditional VI's, there are some example programs for your card that you might try to use, but I would recommend using the DAQmx driver and the VI's related to mx. If you have questions related to the specific DAQmx VI's, the context help (Ctrl-H) is a great way to learn how the DAQmx VI's work and all the options they have. Well, good luck with your application. And have a great day!
0 Kudos
Message 4 of 6
(3,921 Views)
I'm trying to use the DAQmx now, but simply cannot get it to work. Individually, I can get the analog samples to work or the counter samples to work, but, when I put them together it doesnt seem to work. I know how tough it is to look at someone else's code, but I really need help with this. I have commented and organized the VI as much as I can.

Please help!

Thanks,

Jesse
0 Kudos
Message 5 of 6
(3,879 Views)
I don't exactly know what issues you're having, but here are a couple of suggestions. First, start the Counter task before starting the AI task. The way it is written now, there is a race condition where the two tasks might not start at the same time. This can happen if the the AI start trigger is received before the Counter task is started. Second, instead of using the default input, wire a value into the number of samples per channel input of the Read VI. The default of -1 means read all available samples and since the two reads are called at two different points in time, you will likely read a different number of samples for each task. This may make storage and analysis of the data trickier. If this is a problem, I would recommend wiring a constant value into each VI or calculate the size of the array returned from the AI Read and pass that size to the Counter Read.
0 Kudos
Message 6 of 6
(3,872 Views)