Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to use quadrature encoder to trigger (RTSI) single point DAQ on 2 channels of E-Series DAQ, using 6602 NI-TIO for counting encoder pulses.

This is for LV6i, W2000, all PCI equipment.

Using a quadrature-measure position-VI, I get 7200 edges/rev from the encoder of my physical system. This equates to 0.05 degrees of angular displacement. This amounts to an angle stamp as opposed to a time stamp.

I need each of these 7200 edges (source: 6602 NI-TIO) to trigger (using RTSI) the acquisition of a single sample from each of 2 channels on an E-Series DAQ board (maybe more channels later). I only need/want one rev (7200 samples per channel) of data for each run of the test. As I write this I think I want pre-triggering and a little more than a rev of data. So the
re is a buffering step. Anyway, you can get the idea.

I need this angle stamp and the DAQ samples to be placed in an array and on the hard drive for graphing and other mathematical treatment, analysis, etc.

I think there must be a way to use the quadrature output of the counter/timer as a scan clock for the DAQ board, but I haven't seen an example to guide me.

It seems like all of the RTSI or other triggering examples I have seen trigger once to start a continuous scan, not a series of discrete samples repeated quickly. I am not sure how to fill an array with this data. Again, examples are for continuous sampling, not a series of discrete readings.

Any hints on any part of this task will greatly appreciated. This is my first LV project.
0 Kudos
Message 1 of 7
(4,835 Views)
Mike

I would suggest to set up your analog input acquistion to use an external clock and to use the output of the counter from the 6602 as this clock.

Take a look at the example program in LabVIEW called Acquire N Scans - ExtScanClk.vi. It has good documentation on how to use the RTSI for this.

To get the counter output to the RTSI line, use the 'Route Signal.vi.' Set the 'signal name' to RTSI x and 'signal source' to GPCTR n. Then the appropriate values.

Let me know if you have any other questions.

Brian
0 Kudos
Message 2 of 7
(4,835 Views)
Sounds like a fairly ambitious first project!

I assume your 7200 edges/rev come from an encoder with 2 channels in quadrature which each provide 1800 cycles/rev. You can clock in analog data at 1800 scans/rev with either of the two encoder channels, but will probably need an external quadrature decoder circuit to produce 7200 scans/rev. Either method can be done with screwdriver and wire or else by using another counter from the 6602 and the RTSI bus. Here are two approaches in detail, but you could mix-and-match as needed.
Note also that if you can be sure that your reference encoder will be uni-directional, you wouldn't need to measure position -- position could be determined by the array index of the analog scan data. This would simplify things greatly.

1800 scans/rev, screwdriver & wire
-------------------------------------------------
Wire both encoder channels to your 6602 breakout box and configure your counter for the 4x quadrature option. Send a wire from one of the encoder channel connections at your 6602 breakout box to a PFI pin at your E-series board breakout box. Config the analog acquisition to use an external scan clock and specify the correct PFI pin -- there are built-in examples that will guide you. Now one edge of one encoder channel acts as a scan clock for your analog acquisition. Inside the 6602 breakout box, route the same signal to one of the default gate pins and configure your encoder counter gate to use that pin as its gate signal. Note that there will be a race condition governing whether the encoder value updates from the encoder inputs before or after the value is latched by the gate.

7200 scans/rev, extra counter & RTSI
------------------------------------------------
Make sure you have a RTSI connector between your two acquisition boards inside your PC. Build a quadrature decoder circuit that will convert your two encoder channels into a clock and direction output. (Consider the LSI 7084 decoder chip or similar). Setup your "encoder" counter for buffered position measurement. Use "Counter Set Attribute" to define "up down" as "digital" (don't use it to define "encoder type"). The clock output goes to the counter SOURCE and the direction output goes to the counter UP_DOWN pin.
Use "Adjacent Counters.vi" to identify the counter considered adjacent to your encoder counter. Configure it for "retriggerable pulse generation". Use "Counter Gate (NI-TIO).vi" to specify "other counter source" as the gating signal. Configure the output pulse specs to be short duration (make sure total of delay + pulse width is less than the minimum period of the incoming encoder clock signals). Use "Route Signal.vi" to send this counter's output onto the RTSI bus, say RTSI 0.
Now configure the analog acq. to use RTSI 0 as its external scan clock. Also configure the encoder counter to use RTSI 0 as its gate signal. Voila! Now your quadrature decoder clock output acts as a scan clock for analog acquisition and a "gate" to buffer your encoder measurement. The short delay helps ensure that the clock updates the position measurement before the gate fires to latch the value.

Respond if you need clearer explanation. There's a fair amount of decent info "out there" if you scour the online help and this website. Good luck!
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 3 of 7
(4,835 Views)
Kevin-
Thanks for spending so much time on your answer.

K wrote:>I assume your 7200 edges/rev come from an encoder with 2 channels in quadrature which each provide 1800 cycles/rev.

Actually the encoder is 7200lines/rev and quadrature gets 28,800lines/rev. But most important is the Z pulse. I need to know the location of the Z for all the DAQ data. I am essentially angle stamping the data.

I am getting data in a less automated form right now. Using Aquire N Scans ExtScanClk D-Trig.vi (from examples in LV), I clock off of the encoder A or B pulses directly, and use the Z index to start the DAQ. I can pretrigger to capture the Z also. None of this involves the 6602 at all.

However, I can't look very closely at the rising and falling of my signals of interest without using X4 quadrature to clock the DAQ. I will have to try out what you describe in the last part. I don't fully understand what you said on first reading. I know one limitation is that I cannot use a pulse generation routine. I have set up a PG vi and the time for LV to make a pulse is very substantial. That defeats my purpose in marking the data by position. An external decoder circuit may be my best bet, if I can get one that has a short propagation time. My final goal is to clock at 28800lines/rev and 6000RPM. I may have to back off from that. That is 2.88M lines/second. I can only sample at 1.25MS/second. And I need to get 2 channels.

Obviously, I am not going to get that with an E-Series DAQ card.

I am looking for another way to do this. I don't really need to digitize the waveforms. That is kind of a brute strength approach. And it presents problems in postprocessing the data. If I can software trigger single point acquisitions at a particular level on the rising and falling edges of the signals of interest, then I can make some comparisons between the responses of my physical system under varying conditions. I would like to count the encoder pulses and put the actual count number into the data array with the analog data. Angle stamping again. There are problems with this because there is no way to get ATCOUT (analog trigger out) from the E-series DAQ onto the RTSI bus to activate the 6602. I am going to try and hardwire between signal conditioning accessories to do this. Meanwhile, the NI help people think there may be a way that used to work on older hardware that has never been ported upto the E-series DAQ and 6602 cards. We shall see.

At least I can collect enough data to do some "real" work analyzing results not "just" programming. The better I can automate this, more greater sampling I can do and the better I can make design decisions.
0 Kudos
Message 4 of 7
(4,835 Views)
Mike;

If I understood correctly, you need to acquire one point of the Analog Input task at each edge of the encoder pulse.

If that is correct, you will need to use the encoder pulse as the external clock of the Analog Input task, you don't need to envolve the counter on that operation.
To do that, there are some good Labview examples doing continuous acquisition with external clock.

You can wire the encoder signal to both the Analog Input Scan Clock and to the 6602 counter input, with no problem. By doing that, your encoder signal will clock the Analog Input and will be counted by the counter.

You can physically wire the encoder pulse to the AI Scan Clock connector pin, and use the RTSI bus to route that same signal to the counter source input.


I'm attaching also a good Application Note that talks about synchronization of multiple DAQ tasks, in Labview. That is a good start document to get you familiar on how the synchronizations, through RTSI, works in Labview.

Hope this helps.
Filipe
0 Kudos
Message 5 of 7
(4,835 Views)
Filipe,

I appreciate your reply. You are right on and I have been getting by using the Acquire N Scans ExtScanClk D-Trig.vi to do what you describe with some modifications.

However, I am still not achieving the goal of using quadrature to drive the acquisition. Quadrature requires that I use the 6602 first to obtain the X4 coding (an E-Series DAQ card cannot do quadrature).

There seems to be no way to trigger the AI without running a generate pulse vi. These vi's are quite slow which defeats my purpose to angle stamp the AI.

I think I may have to build a dedicated quadrature coding circuit to provide the external scan clock signal.
0 Kudos
Message 6 of 7
(4,835 Views)
Hi Kevin,
I have exactly the problem you are explaining.
But I have to confess that I am quite a bit confused about the explanation - maybe due to my little experience (I am working with LabVIEW since six months).
Actually I tried to make a small VI together with your notes, but I failed. I am not giving up and still try to succeed, but if you could give me some more detailed explanation or maybe even a small VI (which would help me really a lot) I would be really grateful.

I am using a 6602 and a MIO 16E-1

Thanks

Andreas
0 Kudos
Message 7 of 7
(4,835 Views)