Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate retriggerable AO waveform from quadrature ABZ encoder on LV8.0 so that Z-pulse restarts the waveform and A-B pulses clock it

Solved!
Go to solution

I am trying hard to find the solution how to use external ABZ quadrature encoder pulses to retrigger and clock same AO (and DO) waveforms repeatedly. A and B pulses should clock the AO waveform and  Z-pulse should restart the waveform from the beginning. Is it possible with 6221 card? Can you offer the example code?

I am using LV8.0

Thank you

0 Kudos
Message 1 of 11
(5,428 Views)

Hi neptun,

 

Are you trying to use the A and B signals to clock the output on one line, or will A clock one output line while B will clock the output of another line?

 

Best wishes,

Wallace F.

National Instruments
Applications Engineer
Message 2 of 11
(5,412 Views)

Hi Wallace,

Thank you for responding to my question.

Let's assume that I am only planning to use A-pulse for clocking (1024 per encoder revolution) with no B-pulse and no direction detection. Encoder's home Z-pulse (once per revolution) is my restart pulse. I woul like to continuously update same 1024-point AO pattern for single AO output, but it needs to remain synchronized with Z-pulse, which should always retrigger the entire sequence from the beginning. I am trying to avoid Stop-restart Task operations as I am worrying to loose my count.  

My rotation period is approximately 6 sec

Can I do the same thing with DI lines if my waveform is digital bit sequence?

 

Thank you,

Mikhail

0 Kudos
Message 3 of 11
(5,407 Views)

Hello neptun,

 

After looking into your question further, I was able to determine that you cannot do exactly what you are trying to accomplish in the way of using the A encoder channel as the analog output sample clock and the Z encoder channel as the retrigger pulse.  This is because National Instruments DAQ boards do not offer retriggerable analog output. The best you could do is have encoder channel A serve as the analog output clock, while encoder channel Z serves as a start trigger, but the analog generation would not be retriggerable.

 

You can, however, use the counters on your DAQ board to generate a retriggerable finite pulse train that can be used as the analog output sample clock.  There is a Developer Zone article that contains example LabVIEW code for how to do this. I encourage you to read the article titled 'NI-DAQmx: Retriggerable Analog Output - LabVIEW.'

 

Best wishes,

Wallace F.

National Instruments
Applications Engineer
Message 4 of 11
(5,383 Views)

Wallace F,

Thank you for your explanation. I modified the example you mentioned and verified that test AO waveform is now synchronized with Z.

Here is what I tried:

1. Counter set as "CO Pulse Ticks" Task with the Tick source from PFI6 (A-pulse input)

2. The trigger source is PFI5 (Z-pulse)

 

The problem is that in this configuration the minimum High and Low tick setting for CO is 2. Thus I can only obtain maximum 256 CO-generated pulses per 1024 pulse encoder.

Here is a question:

1. How to produce same number of CO pulses/rev as my A-input?

2. Can I use any other Counter task (such as "Position", Eount edges" etc) to achieve this goal?

3. Should I set my Counter Timing.vi  with samples per channel equal to number of my encoder pulses or number of CO pulses? I noticed that if there are extra samples in AO buffer (try 256 instead of 255 in my example), then synchronization blanks out every second encoder revolution. 

 

I am attaching the modified example (LV8.0). Please check if I am doing something wrong. I would like to achieve steady synchronization with 1024 pulses per sequence.

Best regards,

Mikhail

0 Kudos
Message 5 of 11
(5,369 Views)

Hi Wallace_F,

I just realized that in the example I send you, Ctr1 is reported reserved and is unvailable for other tasks, despite that I have not requested it.

What is the minimal number of counters required for retriggerable AO?

Thank you,

Mikhail

0 Kudos
Message 6 of 11
(5,356 Views)

Hello neptun,

 

After doing some more research, and thinking about your application more thoroughly, I've come to understand that what you are trying to do is next to impossible, given the way that you are trying to do it.  You can have analog output be retriggerable as long as you use a retriggerable counter task to generate the sample clock for the analog output task.  This negates using the A signal of your encoder as the sample clock for the analog output task, thus meaning that you are not synchronizing the analog output to the A signal of your encoder. Then I began to think about why you would want to use the Z signal of your encoder as the trigger source of your retriggerable analog output task when it hit me! It seems that you want to output a waveform of a finite number of samples, and you would like for this finite number of samples to be generated every time the encoder makes one complete revolution.  Is this what you are trying to do?

 

Regards,

Wallace F.

National Instruments
Applications Engineer
Message 7 of 11
(5,349 Views)

Hi Wallace_F,

I apologize for confusing way of explaining myself, but you got it right:

 

1. I am trying to retrigger (on Z signal) finite step AO waferform. I also would like to output every point of this waveform with A signal, rather then use fixed timebase.

2. Precise syncronization with A-signal is not important, but I really would like to have all my 1024 clocks/rev. 

 

In the exmple  that I attached I can only get max 256 CO pulses/rev, whick is not enough. 

If there is no way of setting counter task in a more efficient way, I probably can turn my A and B encoder pulses to 4096/rev clock with additional external quadrature decoder IC. Then my CO task will reduce them back to 1024.

This sounds dumb, but otherwise the example seems to be working.

 

Did you have a chance to look at the VI  send you? Why I can't use Ctr1 for anything else? Did Ctr1 got consumed in the retriggering task?

Thanks,

Mikhail 

0 Kudos
Message 8 of 11
(5,343 Views)

A possible solution with your M-series board would make use of digital port 0's ability to clock samples based on digital "change detection".

You would need to be able to trigger just once off the Z-index, then rely on repeatedly regenerating the same 1024-sample buffer of AO and DO from the A,B transitions alone.  You wouldn't be able to "retrigger" the task, but you probably shouldn't need to.

 

Some abbreviated step by step instructions follow:

 

1. Wire the A,B signals to line0, line1 of port 0.  You probably also want to wire them to the normal counter encoder inputs. Wire the Z-signal to the standard counter input and note the corresponding PFI designation.

2. Configure your AO, DO, and encoder position measurement tasks to use the "Change Detect Event" signal as their sampling clock.  Start these tasks first to have them ready and waiting.  The AO and DO tasks should be set for continous generation with buffer size = 1024, and allow regeneration = True.  Note that DO can only use lines 2-7.

3. Configure a DI task with "Change Detection" as the DAQmx Timing type.  Detect both rising and falling transitions on both line0 and line 1.  Configure the task to use the Z index PFI pin as its start trigger.

4. Start your DI task.

5. The next Z-index will trigger the DI task to start.  All subsequent A,B encoder transitions will generate a "change detect event" causing the AO, DO, and encoder measurement tasks to generate/acquire a sample.  Since all sample off the same clock, all data will be synced by sample #.

 

Ta Da!

 

-Kevin P.

 

P.S.  This is, by the way, a really neat capability introduced on the M-series boards circa DAQmx 8.0 or so.  It also avoids your issues with using up both counters on a retriggerable finite clock, leaving you access to your counters for taking sync'ed position measurements.

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 9 of 11
(5,334 Views)
Solution
Accepted by topic author neptun

Kevin,

Thank you for picking up the thread.

I understand your example and I already got to work direct clocking of the AO and DO waveforms using external pulses. The problem is that my application can't rely on the correct number of A-pulses as it will be running same waveform for months. I have to use Z-pulse to keep long-term synchronization. This is why the task should be retriggerable.

 

I made some progress since yesturday on using the attached example "retriggerable_ao-NI.vi" and external qudrature decoder IC, which turned two 1024 A,B encoder into flat 4096 pulses/rev. My CO task then divides this frequency back to 1024 (4 points per period). So this retriggerable AO-DO scheme generally seems to be working.

 

The problem now is that this chip needs to have a clock (~100kHz or higher) to work, and I do not want to build external generator too.

 

Is there any way of getting any high-frequency signals (100kHz, 20MHz or 20MHz timebase) signals out of USB-6221 board to any available PFI pins asuming that all my task-resource commitments in this example are required?

 

I tried lots of things yesturday but all clock signals are either committed or routes are anavailable. I cant understand why I can't tap into them?!

Any thoughts?

Mikhail 

0 Kudos
Message 10 of 11
(5,331 Views)