LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter(position) value is missing the pulse during logging

Hi,

 

I am using NI9178 chassis and NI9401 module to measure quadrature encoder.

Totally 4 encoder, so I using A & B pulses only for every measurement.

Here I cannot able to use onboard sample clock leads error. So I using counter measurement without timing source VI.

When I am using the VI(attached) loses some pulse value during logging. As far as my understating (1)for every 124 values and (2)during my next column log starting time(first element) - encoder pulse values are missing. The same logging counter values excel sheet is also attached.

 

Additional information:

3600 pulse/rev

operating at 2000rpm(values are missing even at lower speed-200)

  

Download All
0 Kudos
Message 1 of 5
(2,875 Views)

The basic problem is that you're relying on software-timed polling to gather data.  Under Windows, that software timing is not reliable and you will get occasional "blind spots" where your loop iterates much much slower than average.  In such cases, you might miss the opportunity to sample one of the encoder positions.  The counter hardware will not miss it, it's just your software polling of the position that might miss *noticing* it.

 

I've also never seen your usage of requesting a 1D array of samples from a task with no clock.  I *thought* that would produce a DAQmx error but when I did a little experiment, it appeared that it might simply do its own internal iterating to try to fill that array with software-timed samples.  I noticed that the internal iteration was faster than I could do by iterating a For Loop while reading 1 sample at a time.

 

So I learned a useful tidbit from your posted code.  Thanks!

 

 

-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 2 of 5
(2,832 Views)

Reason why I am not using sample clock is, if I am using onboard clock leads error.

If I am using same counter A pulse,i can able to read all pulse without missing. But I get 90 deg value instead of 360 deg for every 1 rotation.

Logged data attached for 1 rotation(note I am getting only 90 value).

 

Any other sample clock source can be used? If using 80MHz & 20MHz for sample clock used error is thrown "clock rate must match with internal time base"

0 Kudos
Message 3 of 5
(2,816 Views)

Hi,

I am using 9178 chassis and 9401(counter module), 9205(analog module).

For counter measurement, when I am using timing vi sample clock as:

(1)onboard clock - generate error "to choose external clock"

(2)ai, di sample clock - no sample are reading.

(3)20 MHz - error "-201002" sample clock rate must match the frequency of internal timebase specified as sample clock source.

So that I only allow to use that same PFI line used for encoder as sample clock for timing VI. This is not possible since I measuring 4 counter total 8 input are used for A & B lines of 4 encoder. When I using same input for measurement(say A pulse) and sample clock I am missing 3 pulses in every 4 pulse.

ie., why I am getting 90 deg instead of 360 deg for 1 rotation.(Logged data excel attached).

 

Any other sample clock can be used for counter measurement?

0 Kudos
Message 4 of 5
(2,811 Views)

I don't know cDAQ particulars all that well.  I'll try to help, just understand that my cDAQ info should be given some extra scrutiny and may be incorrect.

 

I *think* you've got 4 counters built into the chassis and the 9401 is just a digital module to give pin access to those chassis counters.  I also think that the chassis uses an older type of counter (similar to that in the M-series MIO boards) that requires an external sample clock scheme.  I would often generate such a clock with one counter and route it for use as a sample clock by another counter.

 

You might not have that option until/unless you get another module.  The 4 chassis counters are already occupied with encoder connections.

 

There might be a way to make a dummy ai task with your other module and then share that sample clock so it can also be used by your encoder tasks.  I don't know if your hardware has this capability for routing and timing though.

 

I see 2 possibilities for measuring 90 degrees instead of 360:

- maybe you've defined your encoder resolution wrong.  (The more common mistake would lead to measuring 4x too *many* degrees though.)

- your loop reads 900 samples per iteration when using ch A as an external sample clock.  At 3600 cycles/rev resolution, that's 90 degrees worth.  So maybe you're looking at data from only 1 iteration of the loop.

 

Summarizing:

You won't be able to use an internal timebase as a sample clock.  You'll need some kind of external clock to be the sample clock for your 4 encoder tasks and that'll probably require another cDAQ module.  The 90 degrees vs 360 degrees issue probably has a simple solution.

 

 

-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.
Message 5 of 5
(2,793 Views)