02-15-2021 02:45 PM
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
Solved! Go to Solution.
02-16-2021 10:45 AM
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.
02-16-2021 02:43 PM
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
02-18-2021 12:57 PM
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
02-19-2021 11:44 AM
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
02-21-2021 02:05 PM
Thanks for your help, I will continue to try.