04-17-2013 08:44 AM
Hello,
I want to know if it's possible to create a task within in a VI that later uses the task to write/read, and then have that VI built to an exe which is then deployed to function on a computer without MAX installed (however I would install all appropriate DAQmx drivers).
Is this possible? I tried creating a task in MAX, selecting the new task as a constant and R-clicking "Generate code" to see if the VIs in that generated code would give me an idea of how to do this but I didn't see what I was expecting in the generated code.
Thanks for any information!
-Pat
04-17-2013 08:50 AM
I'm not sure about not having MAX installed. Because inside of MAX is where you name your instrument cards. And these names are needed to point to the channels you want. But you can programatically create DAQmx tasks. Look at the DAQmx Create Virtual Channel VI. That is the what you use to add channels to a task.
04-17-2013 09:04 AM
Thanks for the quick response!
I guess I expected access to something like the devices serial number to appear as a constant somwhere in the generated code... boo hoo for me. The DAQmx Create Task.vi does not require a task as an input however the vi that accepts the task output from create task has a string input of "Dev1/port0" which tells me that the device is only identified through its name Dev1 which is asigned to it in MAX.
Thanks again
-Pat
04-17-2013 11:04 AM - edited 04-17-2013 11:07 AM
Device names can be set programmatically through the System Configuration API. You can also use the System Configuration API in place of much of the other functionality found in MAX--it is intended to be used in distributed applications when it is not desirable to include MAX.
If you're on a more recent version of DAQmx, I believe the System Configuration API is bundled with the DAQmx installer (so you shouldn't need to download the separate installer in the above link).
Best Regards,
04-17-2013 12:33 PM
Thanks for the reply and link!
I looked into some of the examples that the community page mentions (Hardware Input and Output\System Configuration\Rename Aliases.vi and some others) and I don't see the ability to create a task. I do see options for renaming, reseting, recalibrating, and running self tests, but I'm still thinking this isn't possible to generate or create a task... I'll keep looking but so far I'm not seeing it.
One thing I did find though that I think is handy is the programmatic importing of an nce file... that may be applicable for me in another application, thanks again!!
-Pat
04-17-2013 12:38 PM - edited 04-17-2013 12:40 PM
Creating tasks can be done with the regular DAQmx API:
If you need to create tasks within your program and have access to them later on (say, next time you run the program), try using DAQmx Save Task:
If you don't have MAX installed I'm not 100% sure what happens when you try to save tasks, but I wouldn't be surprised if it still worked. To be honest I usually do not use pre-configured tasks all that much.
Best Regards,
04-17-2013 12:44 PM
It's easy, you'll basically use DAQmx create task, DAQmx Virtual channel and then create the task (AI/DO or whatever) you want.
If you set a good task name, or store the one that's auto generated you can easily access it later.
/Y
04-17-2013 01:41 PM
Thanks again for the replies!
"task to copy is the name of a task to make a copy of. "
This means you already have to have a task that has a device that it is already established with?
Rereading my initial question I think I may have oversimplified my interest in task generation with my application...
My goal is to not require set up/install of MAX on a new system - rather, have the software set up the tasks on appropriate devices.
In other words I'm looking to create and define a brand new task on a system that doesnt even have a user-defined name for the device it will be setting up the task on... I beleive this ultimately means that I will need a txt file or something with the serial numbers of the USB devices so that the default generated device names "Dev1", "Dev2", etc aren't reffered to (because they seem to be generated by what was plugged in first).
Another example of how this would be useful is if a USB device went bad on a system and you swapped it out with a new one and only had to change the old serial # in a txt file to the new one...
I apologize for not being clear, I try to make most of my posts here simpler than the big picture Ive got to work with... does that make me lazy?
Thanks again for the responses, much appreciated, kudos delivered.
-Pat
04-17-2013 02:10 PM
You will probably need to install MAX anyway, since it enumrates your resources, but you dont need to setup any tasks. Actually i recommend against it!
It makes it abit messier to compile and you'll need to import the tasks on the next system. If there's several programs you might get task-conflicts.
What i do is a setup panel where you have DAQmx physical channels, named according to task, e.g. Open valve, and then i create a task with the channel name (with '/' changed for '_') and start it. Afterwards i can just grab the task, named as the channel and read/write.
/Y
04-17-2013 02:20 PM
@PatLyons wrote:
Thanks again for the replies!
"task to copy is the name of a task to make a copy of. "
This means you already have to have a task that has a device that it is already established with?
No, you don't need a task up front. That input is NOT required, it is optional.
In most of my programs, I generate a task based on a xml file stored on the PC. That can be change by any program, and the program can be moved to different PC's with different configuration files. I have build-in configurator to the program that can create or change these xml files.
How offen do you need to change USB device?
Sounds like you are thinking of changing the USB device every day or so.
You can auto detect what devices are connected to the PC, and get a list of what modules are in the devices.
Then you can setup a system to be able to select the device by itself. But again how offen do you need to change device?