Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Buffered event counting, VB6, DAQmx

I have an encoder that I would like to count the pulses per revolution on.
 
I can do this in Traditional DAQ by setting the Counter Source and Gate.  Source being the encoder pulse train, and the Gate being the index on the encoder.
 
How would I do this in DAQmx?  Every example I have seen is for event counting, but nothing to actually give you a PPR.
 
Source is channel A of encoder.
Gate is channel Z of encoder.
 
Any source code tidbits will be very much appreciated.
 
Thanks for your help.
0 Kudos
Message 1 of 4
(3,800 Views)
Big Guy,
 
In DAQmx, the source and gate pins of each counter have default values.  You can find which pins you need to use by opening up Measurement & Automation Explorer (MAX) and then navigating to Devices and Interfaces>>NI-DAQmx Devices>>(Your Device) and then right-clicking and choosing Device Pinouts.  Unless there is an absolute need to use another pin, I'd recommend using the default pins shown below.
 
Which DAQ card are you using?
 

Default NI-DAQmx Counter Terminals

Counter/Timer Signal Default Pin Number Signal Name
CTR 0 SRC 37 PFI 8
CTR 0 GATE 3 PFI 9
CTR 0 AUX 45 PFI 10
CTR 0 OUT 2 PFI 12
CTR 0 A 37 PFI 8
CTR 0 Z 3 PFI 9
CTR 0 B 45 PFI 10
CTR 1 SRC 42 PFI 3
CTR 1 GATE 41 PFI 4
CTR 1 AUX 46 PFI 11
CTR 1 OUT 40 PFI 13
CTR 1 A 42 PFI 3
CTR 1 Z 41 PFI 4
CTR 1 B 46 PFI 11
Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 2 of 4
(3,789 Views)

I am using the PXI-6602..

 

Thanks for your help.

0 Kudos
Message 3 of 4
(3,786 Views)

I remember you from another recent counter thread -- again, I'm no help on VB syntax but can describe basic ideas.

You'll be looking to configure the counter for Period measurement, as you seemed to imply.  This will give you edge counts of one signal (encoder pulses) between adjacent pairs of edges of another signal (index).  You can do this either as a single measurement or a buffered measurement.

I know that in LabVIEW, I actually find that this kind of measurement is a bit more awkward to configure with DAQmx than it used to be in traditional NI-DAQ.  I'm not sure where you'll find the similar property-setting function calls from VB, but the basic idea goes like this:

- Set period measurement units = "ticks"

- I used "channel properties" to define the terminals for both input signals.  The one for your encoder signal was mapped out as Counter Input-->General Properties-->Timebase-->Terminal.  The one for your index signal was mapped out as Counter Input-->Period-->Input Terminal.

- My call to define DAQmx Timing (for buffered measurements) was set to "Implicit (Counter)" timing, meaning that the sampling clock timing is implicitly defined by the counter's input signal for period measurement.

Hope this gives you some help at finding the appropriate DAQmx function calls from VB...

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 4
(3,751 Views)