Monday, October 19, 2009

Porting DAQmx Task Configurations

Ever wondered what's the best way to port DAQmx task and channel configurations from one PC to another with minimal fuss? It is a problem we are faced as intergrators every day - how do we make the application easy for our client to install and maintain well into the future? We always need to have some sort of hardware configuration in our applications, but is it best to:

a) store that configuration information as an extra file, or should it be

b) integrated into the software application to minimise the number of files required on each target PC, making the installation process quicker and simpler for the client?

I like the idea of option b, however it seems a lot more work and therefore cost to code the hardware configuration into LabVIEW, rather than simply exporting the Measurement and Automation Explorer (MAX) configuration file to the target machine.

Something I have been using for a long time, which seems to be a little known feature of LabVIEW, is automatic code generation for DAQmx tasks. This feature makes it a breeze to convert your MAX task configurations into code. Using this, you can easily deploy hardware configurations inside your executables, and it is simple to add or modify those configurations in LabVIEW later.

Here is the trick....

1) Create and configure your DAQmx task in MAX

2) In LabVIEW, place a DAQmx task name constant on your block diagram

3) Pull down on the task constant and select the saved MAX task (just as if you were going to use the saved MAX configuration to run the hardware I/O functionality)








4) Right-click the task constant and select "Generate Code".

Here you have a number of options, the most usefull of which are "Configuration" and "Configuration and Example". If you have blank VI the "Configuration and Example" option is gold, as it automatically generates your while loop, stop button, graph and all those other little VIs that I always forget to include when developing DAQmx code, such as start task and stop task. It also generates a subVI, inside of which you will find all of your task configuration code. once this subVI is built, you can forget about your MAX configuration files as all the configuration information is now in your code - brilliant!

If you have already written your data acquisition code, and simply need to generate your MAX configuration code, use the "Configuration" option. This will automagtically generate a neat little subVI with a task and error output.

Go on, give it a go!




No comments:

Followers