11-10-2014 01:18 PM
Jeff,
I also use MAX to configure devices, and use named Tasks to get all that messy DAQmx stuff out of my code (I just want to do a Start, Read/Write, and Stop most of the time, without having to mess with "settings").
I've got a particular instance where I have two testing stations, each with a 6501, and two UltraBooks that run these stations (we're doing behavioral training). Each PC has the same executable, and the users don't know LabVIEW (it functions as a "turnkey" system). As long at PC 1 is associated with Station 1 and USB-6501-1, everything is good. But if PC 1 is "busy" (or having its battery recharged), I can't substitute PC 2, as it is configured with USB-6501-2, hence my dilemma.
After playing around with some of the DAQmx functions, and finding they really didn't work well for me, I think I've figured out a solution that works for me. I use the DAQmx System function to get all of the Devices, then filter out those that are "compatible" (in my case, USB-6501 and USB-6009). I then "pick 1" (the first one in the list), concatenate the lines that I need (e.g. /port0/line0), and return an array of Device Names that I can wire to my Start Task functions.
I do agree, however, that your proposed "allow run-time swapping" idea has merit, so its Kudo count is now incremented. I'm glad I'm not the one who would be tasked to figure out how to make it work ...
BS
11-10-2014 01:31 PM - edited 11-10-2014 01:50 PM
That 6009/6501 filter would work well with a custom DEVMON executable to rename the alias when inserted. Then keep your DAQmx'y stuff in the Project so you can edit <MyApp>\Data\NI-DAQ.ini if you ever need to change settings and don't want your users to fiddle with MAX.
And yes a "Typical" AE looks like this:
The silly cDAQ AI (4-20mA) wouldn't save the scales with the task on a simulated device so there is a funny work-around in applying Scales but they are saved (in MAX in this case for hardware testing and system maintainence per the client's wishes)
As an Aside: This actually saved me a long trip when some of the AO Lines were not wired correctly! (Crossed). Five minute fix from MAX Remoted in and no re-compile! And that vi serves as the only vi in an additional SFP app to calibrate the load cells! (Edit: there is a DAQmx save scale.vi call as well)
11-14-2014 01:31 PM
After a bit of playing around, I came up with the following (fairly simple) solution to my "What Device is connected to this PC?" question.
The scenario is that the PC (a laptop) is doing digital I/O -- two lines (Port 0, Line 0 and 1) go to a Relay to drive it and monitor it, and two more (Port 1, Line 0 and 1) go to two pushbuttons. The DAQmx device can be either a USB-6501 or a USB-6009 -- both have the digital I/O ports I need.
The snippet below shows how I create a cluster of 4 Task References. I structured this as a "Initialize-Once" structure using a Feedback node. I place this VI wherever I need to use one or more of the Tasks (unbundling its output to get the Task(s) I need), and the first time it is called, the code shown here runs. [The True case simply passes the Array of Tasks through to be bundled and output]. There's also a little VI called "Valid Tasks" that decides which Case to perform -- I've include a snippet for it, as well.
This is probably not as elegant as some of the suggestions here, but it works well and stays "out of the way" by being encapsulated in this VI.
Here is Valid Tasks ... Note that Error -200428 is thrown if the Task doesn't exist (which simply means we must create it again).
I'm grateful for the willingness of Jeff and others to share ideas and "expand my horizons" -- I hope this bit of code is also helpful to someone.
Bob Schor
12-04-2014 07:07 AM
This thread might not be the place to ask this question, but it contains useful information and the people seem to know quite a bit about NI-MAX. The question arises because I'm supporting multiple machines with multiple LabVIEW versions from one desktop.
Is there a way to have more than one "My System" folder in MAX?
12-04-2014 09:00 AM
@djs_at_eaton wrote:
This thread might not be the place to ask this question, but it contains useful information and the people seem to know quite a bit about NI-MAX. The question arises because I'm supporting multiple machines with multiple LabVIEW versions from one desktop.
Is there a way to have more than one "My System" folder in MAX?
But join in and vote for that excellant Idea!