10-19-2012 07:01 PM
This is going to sound pretty silly to a lot of you, but I don't know how to set up a continuous output that will also monitor Analog Input channels on the same device.
I am generating two sine waves on a continuous basis. I want to add two analog inputs that will continuously monitor the scaled outputs. Also, the code I have uploaded has an untested modification (amplitude adjustment inside the While loop).
I can't test anything until I travel to the site next week, but I'd like to have the code compiled and ready to use, so I need some help.
Can I add a DAQmx Read for two Analog Inputs inside the same While loop and use the same Task?
The code is in LabVIEW 2010, by the way.
Thanks in advance,
Jeff
Solved! Go to Solution.
10-22-2012 06:10 AM
Hi Jeff,
It's definitely possible to output data from multiple analog input channels. Are you very familiar to DAQmx? If not, this is a really helpful guide: http://www.ni.com/white-paper/5434/en
This particular link goes to a video that shows you how to acquire data from an analog input in particular: http://www.ni.com/white-paper/5370/en
In order to obtain data from multiple channels, when selecting the physical channels from your DAQmx Create Channels vi, simply go to 'browse' after you've created your constant or control for selecting physical channels. Then hit 'shift' and select the channels you wanted to acquire data from. Also, for your DAQmx Read vi, you can browse to Analog->Multiple Channels->Multiple Samples and then select 2D Double (for an array output) or 1D Waveform (for a graphical output).
Hope that helps! If not, feel free to ask anything else.
10-23-2012 04:59 PM
I know how to acquire data from multiple sources (I use the MAX utility).
What I want to do, and have not found in either of my text books, is add code to the current VI (the one in the first post of this thread that generates two sine waves) so that it will monitor the signals at the outputs of the circuit I am building (the signals will be 115 Vrms) at the same time that it is generating the output signals.
When I ran the VI (using a simulated NI-6221 because I don't have the hardware available at the moment), I got an "invalid task" error (please note that I'm referring to the image attached to this post, not the VI in the original post).
In the "Conf DAQ" and "Conf DAQ Input" VIs (see attached image), I acquire two different tasks (one to Write and one to Read). Should I acquire one Task Reference for the NI-6221 and use that for all communication to the PCI-6221 (both reads and writes)?
Thanks in advance,
Jeff
10-23-2012 05:10 PM
The analog input and analog output should be separate tasks.
The error message indicates that the error is occurring inside Sine Wave Data.vi, which you didn't show us. Could you upload your VIs, instead of posting a screenshot?
10-23-2012 05:25 PM
The ZIP file in the first post contains the SubVIs, including "Sine Wave Data".
It didn't fail until I added the code to read (as shown in the bottom of the image included with my 2nd post in this thread).
Jeff
10-23-2012 05:37 PM
Please upload the code that is actually causing the error. Right now you have uploaded your initial code which you said does not generate an error but does not do what you want, and a screenshot of the code that does what you want but generates an error. You also haven't provided the analog input configuration VI. If you upload your code, then we can run it and see if we see the same error.
With the limited information you've provided, I would guess that you are doing something wrong when you configure the analog input channels - perhaps you copied the analog output setup VI and didn't change the channel or task names?
I also don't understand why you have a DAQmx Property Node inside Sine Wave Data.vi since it's not doing anything, and that's the node that generates the error (according to the error text).
10-23-2012 05:52 PM
All of the VIs are included in the attached ZIP file. As before, the code is in LabVIEW 2010.
On a side note, I have noticed a problem with the "Duplicate hierarchy to a new location" option in the Save As command; it is only copying the top level VI, not the subVIs. This worked with 8.2, and I seem to recall that it worked with 2010 when I used it last year, but it's not working now. Any ideas on how to fix that?
Thanks in advance,
Jeff
10-23-2012 08:12 PM
Careless wiring! You didn't connect the "task in" and "task out" wires to Sine Wave Data.vi, so the task input is blank, causing an error at the property node. Since you did connect the error wires, the error propagates. The task wire runs behind the subVI rather than into and out of it. Consider marking those terminals as required so that the compiler will catch this problem for you (in fact, I think it's a good idea to set the preferences option that makes all terminals default to "required" in new VIs).
10-23-2012 09:12 PM
Boy, do I feel silly. That subVI was properly wired earlier in the week. I wonder how I changed it.
Thanks for the help.
Any idea on why the "Duplicate hierarchy..." selection isn't working under Save As?
Regards,
Jeff
10-24-2012 01:44 PM
JeffinCA wrote:
Any idea on why the "Duplicate hierarchy..." selection isn't working under Save As?
Sorry, no ideas on this one, I've never seen that problem. The application builder sometimes has problems with excessively long paths, and when you duplicate a hierarchy it attempts to duplicate the folder structure, so maybe there's an issue where you're trying to save to a deeply-nested folder and when LabVIEW tries to create the folder structure inside that the path is too long and results in an error? That's a shot in the dark, nothing else comes to mind right now.