Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use an X4 (quadrature) encoder as a sample clock?

Solved!
Go to solution

I have an X4 quadrature encoder that measures position, and I'd like to take a sample in another task every time the quadrature signal counts. This would give me a [data] vs position plot instead of a [data] vs time plot. I thought you could export the "quadrature conversion event" (i.e., the event that causes the quadrature channel to count) but I can't find the documentation on that. I don't think it's the Counter n Internal Output, as the documentation says that output event fires when the counter rolls over... but one example seemed to use that anyway. Perhaps the Internal Output triggers every time a quadrature signal counts, and it's hidden away in the documentation somewhere I can't find.

 

I swear I've read this before but can't find it. My Google-fu has failed me. I've been searching and obviously there are a ton of posts and examples that show how to take data off either A or B, but not the decoded quadrature signal. Is it possible?

 

[The "what I'm actually trying to do": I need to measure the speed of a fairly slowly rotating shaft. If I sample the encoder position at x Hz, I get position vs. time but it's very noisy, as there are frequently very few (if any) encoder pulses between measurements. Slowing down my rate reduces my noise, but I don't get data as often. This method is basically "measure distance over a known time".

 

I'd prefer to just sample the internal clock every time I get a new quadrature position. That way I have a known distance traveled, and can use "measure time over known distance" which will get me the instantaneous speed every time it crosses either A or B. This doesn't work for bidirectional motion, but it works great for the unidirectional motion of my system. This method worked great in the past for measuring the time between individual photons hitting a crazy sensitive detector, but I can't figure out how to export the quadrature signal.]




Heads up! NI is moving LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 1 of 4
(214 Views)
Solution
Accepted by topic author BertMcMahan

Here's what I'd do, assuming a device that supports both quadrature and digital change detection.  (For example, X-series and most M-series, probably most cDAQ chassis from the past decade or so).

 

If you're using PCI/PCIe or PXI/PXIe, you'll likely need to parallel wire to both PFI terminals for the encoder task and also to port 0 digital terminals which don't carry a PFI designation on the boards I've been familiar with.   A cDAQ system may not need such parallel wiring.

 

You'd set up a change detection task for DI and then export the "change detection event" that the counter task would use as its sample clock.  I don't remember its polarity, but it'll be best to sample on the trailing edge to be sure the quad decode is done before the sample is latched.

 

That's the overview, post back if something doesn't go smoothly.

 

 

-Kevin P

 

[Edit] P.S.  There isn't otherwise direct access to any "quadrature state change" signal as far as I know.  This method with DI change detection acting as a CTR sample clock is the only way I know of on standard-issue NI data acq devices.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW?

(Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).



Message 2 of 4
(191 Views)
Solution
Accepted by topic author BertMcMahan

An alternative solution is to use a quadrature clock converter (LS7184) to obtain the trigger signal in X4 mode. This circuit can also be used for filtering. I have used this method in many projects.

Message 3 of 4
(182 Views)

Ah, thanks for the info. I could've sworn there was a way to export the quadrature clock. I threw up an idea in the exchange, though I doubt this would be a very popular feature:

 

https://forums.ni.com/t5/Data-Acquisition-Idea-Exchange/Allow-export-of-quot-Quadrature-conversion-q...

 

I'll look into the chip, and will maybe just live with a lower sample rate. Thanks for the help.




Heads up! NI is moving LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 4
(170 Views)