LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Missing counts in the encoder

I am not scared to use it. Its just that I am dealing with this encoder problem for a very long time and I want to make sure that the stuff works. So, I am just taking time to understand different avenues that I can explore before implementing anything. With having a moving average in the VI itself, I am just wondering if that will induce some delays to do that additional operation?

 

Abbishek

0 Kudos
Message 21 of 27
(995 Views)

1.  Unsure what forces you're measuring, what "features" you're looking for, or what kind of bandwith your force transducer supports.  I'd just say that in my experience, common mechanical systems that deal in forces and masses don't typically have a frequency response that justifies multi-kHz sampling.  (Vibration measurements can need high sample rates, but one wouldn't normally use a force transducer to monitor vibration.)

    It will be helpful to start bounding this problem.  Some focused work can be done to determine the frequency response of the force system you're measuring.  That's better than an approach that says, "we don't know what might be there, let's sample at a real high rate just in case".

 

2. I'd encourage you to explore the constant-rate frequency measurement mode your X-series device supports.  I've not used it myself and have only skimmed the docs enough to have a basic awareness, not detailed knowledge.   But it seems to offer a good middle ground between the precision of variable time interval measurements and the regularity of a constant sample rate.   I suspect it'll be your best method to get RPM info.

 

3. I wouldn't take that approach unless I had no other options.  All it really does is trade off position quantization for time quantization.  There isn't a net gain from that step alone.

 

Pay close attention here: quantization effects are a fundamental issue.  You simply can't do single-interval calculations and produce good results.  Your quantization error will be of the same order of magnitude as your desired single-interval result, so the single-interval results become effectively garbage.

    That's the motivation for multi-sample approaches like the moving average filter.  Other kinds of filtering and curve fitting are other options.  But all of them produce output values that depend on a *series* of input values, not just a single input.

 

Even the special constant-rate frequency-sampling mode your device supports will have quantization -- it can only update its frequency measurement when a new encoder pulse arrives.  But the quantization happens when you're already natively in the realm of a speed-related rate measurement.  That's much better than doing a numerical derivative on quantized position data because numerical derivatives tend to *amplify* noise and quantization errors.

 

 

-Kevin P

 

[Edit:  P.S. re-read the original question.  A moving average performed live in real time will indeed have some delay because it can only act on current and past data.  If you do it in post-processing, you're free to average across past and future data symmetrically and not produce a delay.]

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 22 of 27
(982 Views)

Thank you Kevin for the detailed answer. I tried a program where I post-processed a signal to get the only get the the data where the encoder signals change and get the particular time as well. It still showed a very high quantization as you suggested. I will try the moving average with the data I have as well to understand that well. 

 

I looked into the the frequency measurement mode in the web. I could not find much in there with respect to that. I tried a program which I have uploaded with this post. Here the counter to which the encoder is connected is measuring the frequency and sample rate is dictated by a counter output task. Can you let me know if I am going in the right direction with what you meant by the constant frequency measurement mode?

 

Abbishek

0 Kudos
Message 23 of 27
(971 Views)

Have a look at the shipping example named "Counter - Read Pulse Duty Cycle and Frequency (Continuous).vi".  

 

It looks like you need to specify the measurement as "CI Pulse Freq" and also read the data out of the task as the special datatype coming from "Counter 1D Pulse Freq".  It'll be an array of clusters, each cluster element contains a duty cycle and a frequency.  So you'd have to unpack that to extract just the frequencies before graphing them or doing any other calculations.

 

 

-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 24 of 27
(967 Views)

Kevin,

 

Oh ok. I got the example. In my DAQ system, I am using counter 0 as the encoder input counter. And PFI8 is where the A channel of the quadrature input is connected. The external source is set as PFI0. When I run this program, I get an error (error 200284), which says the following:

 

Some or all of the samples requested have not yet been acquired.
To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger, make sure that your start trigger is configured correctly. It is also possible that you configured the task for external timing, and no clock was supplied. If this is the case, supply an external clock.

Property: RelativeTo
Corresponding Value: Current Read Position
Property: Offset
Corresponding Value: 0

Task Name: _unnamedTask<4F>

 

So, I tried changing the sampling rate, number of samples to read and the timeout, but still got the same error. I also changed the clock source to different PFI terminals. But even that did not work. Do we have to wire the clock to some DAQ channel because I was presuming that the DAQ is internally wired? I may have misunderstood when you said use this program. Should I combine this program with a counter output task that generates TTL pulses and then use that as the clock source or should I specify the clock source in this program alone?

 

Abbishek

0 Kudos
Message 25 of 27
(956 Views)

Sorry. Here is the program with the inputs as well. 

 

Abbishek

0 Kudos
Message 26 of 27
(955 Views)

I only meant to *look at* the example to help guide you on how to modify the earlier code you posted, which looked mostly pretty ready other than the unique stuff for the new-ish "pulse frequency" measurement mode.

 

The example doesn't define a sample clock and counter input tasks can't derive them internally.   They need to get them from somewhere else, such as another counter output task as you set up in your earlier attempt.

 

Here's my quick attempt to merge them.  You'll still need to provide a live encoder signal by creating some motion.  Note: I got a couple warnings while back-saving from LV 2016 back to LV 2012, so it's possible some stuff will be broken.

 

 

-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 27 of 27
(942 Views)