Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Quadrature generation with counter/timer card

I need to generate a quadrature output with a timer/counter card (6602,6624).  It has been done before in another test program using CVI and some other things, but I am heading up setting up a new test system based completely in LabVIEW and VeriStand.  The ultimate goal here is to have a VeriStand custom device that controls the quadrature output of these cards.  Where I am getting stuck is coming up with a way to strictly enforce a 90 degrees phase shift between the two waveforms.

 

What I have tried doing so far - in short - is use a timer delay before the second DAQmx Start Task VI (inconsistant/bad timing) so then I tried using triggers. I have the second wavform triggered based off the first waveform (triggers on a rising digital edge).  Obviously that gets the timing of the waveforms in line with each other but they are always in phase or 180 degrees out of phase (triggers on a falling edge).

 

I have tried using Initial Delay in the create channel VI and also I tried to use the Start.Delay property in the trigger property node, but I kept getting unnamed task errors and could not figure out why.  Ideally, I would like to be able to set a delay when the trigger for the second waveform occurs before the second waveform gets generated.

 

I'll take any ideas anyone might have as I have exhausted all the ones I have for today.  I have included a snippet of my code I am using to try to generate this output before putting it into a custom device.  Thanks for the help in advance.

0 Kudos
Message 1 of 12
(7,158 Views)

I have been able to create a working quadrature generation using a third counter as a timer basically... I alter the duty cycle of it and trigger the second pulse generation on the falling edge of that.  Therefore I can alter the phase.  It seems to work really well in my initial tests as far as timing and reliability go, but the problem is the use of the third counter.  The counter card has 8 channels and I need all of them to generate four sets of quadrature outputs.  So I need to find a way around this issues by using something else as a timing source to trigger things.

 

My setup right now includes a PXI-6602 in a PXI-1042 rack with a PXI-8110 controller.  I am using LabVIEW 2011 SP1 with RT and FPGA.  I included my current working code below. Thanks for the help.

 

NOTE:  I forgot to comment what channel is what in the code.  ctr0 = QA; ctr1 = QB; ctr2 = Ctr Ref

0 Kudos
Message 2 of 12
(7,145 Views)

I know that nobody's responded to this yet, but I am just keeping some thoughts flowing as I'm thinking about it and figured I'd update this.  Since this generation is ultimately going to be implemented in VeriStand - is there a clock/counter reference within VeriStand itself that I could use as a trigger?

0 Kudos
Message 3 of 12
(7,137 Views)

In case someone does take a look at this over the weekend.  I would like still like to know if there is a way, but I ended up triggering the second waveform with a hardware connection and it works just fine.  I'd prefer to do it through software if I can to avoid the extra wiring, but if not at least I have a solution.

0 Kudos
Message 4 of 12
(7,129 Views)

Joe,

 

Take a look at this community example: https://decibel.ni.com/content/docs/DOC-10321

 

Regards,

 

-Travis E

National Instruments
Product Marketer
0 Kudos
Message 5 of 12
(7,121 Views)

Thank you. That was actually quite helpful.  I didn't think of using one start task VI for both of them so that they start at the same time.  I still have a lot to learn.

 

One question I do have that maybe you can answer.  What is the difference between an ARM trigger and a non-ARM trigger?

 

Thanks again!

0 Kudos
Message 6 of 12
(7,114 Views)

Joe,

 

The difference in the triggers is based in the functionality of the hardware. The regular start trigger is meant for Analog and Digital I/O while the Arm start trigger is meant for counter tasks. When we configure a start trigger on an AI task, data is gathered onto the FIFO of the DAQ device as soon as the Start Task VI is called, but it is overwritten continuously until the start trigger is received.  The trigger causes the data to be transferred from the FIFO to the PC buffer and then into LabVIEW memory. 

 

Counters have no FIFO and unless you configure an Arm Start Trigger, a counter task will execute as soon as the task is started.  The Arm Start Trigger tells the counter when to start counting, but does not tell it when to pass the values along to PC memory. The gate signal is used to trigger the buffering of the data on a count edges task, for example.

 

National Instruments
Product Marketer
Message 7 of 12
(7,091 Views)

Thank you, I appreciate the explanation.  It makes sense and that example really helped out.  I was able to take that and modify it slightly for my needs.  Now I have a quad output that can change direction, phase, frequency, and duty cycle with the use of a set control.  It works out pretty well so far.

0 Kudos
Message 8 of 12
(7,081 Views)

I'm also trying to generate a quadrature signal from two counters on my 6624 and I found this thread.  But I'm still fuzzy on how to time the two signals with one DAQmx Start.  My requirements are slightly different.  I need to be able to change the frequencies on the fly using a loop.  Can I stop the signals, use a property node to change the frequency, and then re-start them?  If so, what would the property node look like? 

 

Also I need to be able to change the two counters seperately in order to induce failures.  Can this be done after I've linked the two together in one task?  If so, how do I do this and then link them back together again.

 

 

0 Kudos
Message 9 of 12
(6,826 Views)

You can create a task for each counter and start them at the same time using a dummy AI task. Now in each task you can place a write VI to update the counter frequency. Here are two examples that touch on each of those topics:

 

Synchronize Two Counter Output Tasks Using a Dummy AI Task

https://decibel.ni.com/content/docs/DOC-11755

 

Change Counter Output Frequency on the Fly

http://zone.ni.com/devzone/cda/epd/p/id/5493

 

I hope this is useful!

 

Regards,

 

-Travis E

National Instruments
Product Marketer
0 Kudos
Message 10 of 12
(6,778 Views)