From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggered Analog Output with Counter on PFI0

Solved!
Go to solution

Hey everyone,

 

This one has me stumped. I've done many triggered AIs, but never an AO quite like this.

 

I have a counter output wired to PFI0. I wrote a little state machine to adjust the counter output so I can modulate frequency and the duty cycle. I need the duty cycle control so the off delay is long enough to stabilize the output signal that the analog output triggers.

 

So the little program attached works, but the output inverts only every few clocks of the counter, and it's never periodic. It's random like the analog out trigger isn't catching all the rising edges.

 

I need the Analog out to flip polarity on the rising edge (5V out, then -5V, etc.). Something else is triggered on the falling edge (hence the need for control of the duty cycle).

 

Any ideas? I've tried this on a PCI-6259 and a USB DAQ (forget the model but it's one of the higher end ones).

 

Thanks in advance. This is LabVIEW 2018 BTW.

 

TR

><><><><><><
Tommy R.
><><><><><><
0 Kudos
Message 1 of 5
(2,463 Views)
Solution
Accepted by trouinky

Correct me if I'm wrong, but it sounds like you just want an analog output to toggle between 5 and - 5 V on every rising edge of a sample clock, right?

 

If so, just make a normal continuous output AO task.  Set the sample clock to be your counter's output (PFI0 or the internal output if you want to get fancy).  Don't use a trigger VI at all on this task.  Write only two samples (+5 and -5) to the AO buffer, and then start the task.  The buffer will automatically be circular, so you never have to write again.  Just let the task play out until you exit your main counter loop, and then clear the AO task.

Message 2 of 5
(2,366 Views)

I have a the counter internally routed to PFI0. All I had to do to solve it was to loop a "Task Done?" function so the AO task catches the edges.

 

Your method sounds interesting, I'll try it. Everything is tied to the rising and falling edges of the counter, so it makes sense to use that as the clock.

 

Thanks for the insight.

><><><><><><
Tommy R.
><><><><><><
0 Kudos
Message 3 of 5
(2,353 Views)

Your method works perfectly and is much more elegant and easy to terminate. Just used a notifier to end task when the main loop is terminated. AO sets output to 0V they at the end and all is good. Thanks for the tip!

><><><><><><
Tommy R.
><><><><><><
0 Kudos
Message 4 of 5
(2,323 Views)

Glad to hear it!  Please mark the solution post as correct so the thread appears solved on the main forum page 🙂

0 Kudos
Message 5 of 5
(2,316 Views)