Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Use NI9401 to output two PWM pulses with opposite levels simultaneously

Solved!
Go to solution

Hi all,

I just got in touch with cDAQ and NI9401. So please forgive me for the naive question.
I want to use NI9401 to send two PWM pulse signals synchronously, and the levels of the two signals are opposite. Is there a similar case that I can learn to realize this function? 

Attached is a schematic diagram of the waveform I want. 

Thanks,

Best regards,

ZK

 

0 Kudos
Message 1 of 6
(1,084 Views)

Hi ZK,

 

I believe Kevin P provided a good answer and example code for what you are looking to do here in this forum thread, where you can hardware sync two PWM pulse trains to be the inverse of one another - https://forums.ni.com/t5/LabVIEW/Mirroring-or-Time-Delaying-a-PWM-Signal/td-p/3942127?profile.langua...

 

Best Regards,
Grant M.

0 Kudos
Message 2 of 6
(1,035 Views)
Solution
Accepted by topic author zkli

The example I posted in that linked thread gets you pretty close but isn't an exact solution to your problem.  (Nor, after re-reading, is it an exact solution to that other thread.  Merely close for that poster as well.  Oops.)

 

As coded, both pulse trains are triggered to start at the same time.   For each full pulse interval, both start in their idle state and then transition to their "active" state.  Their duty cycles add up to 1.00.  However, their outputs can spend parts of each pulse cycle in the same state at the same time (some shared idle time, some shared active time).

 

What you'd need to change is to configure the 'idle state' for the two tasks to be opposite -- one low one high.  And then program both to have the *same* duty cycle.  I think that ought to to be all.

 

One subtle thing to watch out for is the possibility of an extra transtion or two when the counter task is first started and then again when it's cleared.  When the programmed idle state matches the device's hardware power-up state, there are no transitions.  When they don't match, you may get these transitions.  (But maybe not always due to a characteristic known as "lazy uncommit" which you can learn more about by searching around here.)

 

 

-Kevin P

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).
0 Kudos
Message 3 of 6
(1,026 Views)

Hi Kevin,

Thank you very much for your help. My problem has been solved very well. With the addition of trigger, the waveforms of the two channels only have a delay of 4.5ns. Has met my needs.

My other question is if I want to improve the previous program and output two finite number of waveforms (such as the pulse signal in double pulse test) through digital output. Do you have any good suggestions?
I have now implemented using one channel to emit a double pulse (as shown in attached 1), but when I add a second channel in the same way (as shown in attached 2), problems will occur.
Could you please help me check how to modify it? Thanks a lot

0 Kudos
Message 4 of 6
(982 Views)

I can't inspect your code very closely as I don't have DAQmx installed for LV 2020 here (because it won't support LV 2016 which I'm still supporting for some projects).

 

The first thing I see is that you're trying to create 2 independent hardware-clocked DO tasks. That's not supported on most of the NI DAQ hardware I'm familiari with.  Most devices have no more than 1 "timing engine" available for DO, so any DO lines that need hardware timing need to be included in 1 single task.

 

See what you get by removing the entire lower task, designating "...port0/line0:1" in the remaining task.  You'll also need to build your digital waveform differently so you can output the data for both lines simultaneously.  I can't tell you exactly how because I rarely use digital waveforms except for graphs/charts.  I was already comfortable thinking about digital in terms of booleans or bit-mapped integers before the digital waveform was introduced to LabVIEW, so that's how I still approach things.

 

 

-Kevin P

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).
0 Kudos
Message 5 of 6
(963 Views)

Thanks for your help, I will continue to try.

0 Kudos
Message 6 of 6
(942 Views)