Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing NI-DAQmx Task into a VB 6.0 program

Hi,

I have created a NI-DAQmx task to measure a voltage. What I want to do now is to import or use that task in my Visual Basic 6.0 program instead of creating a task from scratch manually. I don't have Measurement Studio or Labview installed. I only have NI-DAQ software 8.0 installed that came with USB6008 DAQ. The task that I have created works, I can get the voltages at the specified channel.

 

Also following the example in C:\Program Files\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\Analog In\ I have been able to create a task from scratch to measure voltages.

 

Now I just want to try the other way of importing a task created in MAX and using it in my Visual Basic Program. Can you please let me know how it is done?

Sajjad


0 Kudos
Message 1 of 9
(4,860 Views)

Hi,

You can use the DAQmxLoadTask function to load a task from MAX into your application, and then use the start/read functions to interact with the task in the same way.

Check out the C reference help installed with NI-DAQmx, this gives the functions which are available in C and VB and will give you the function prototype and description.

Hope this helps

Hannah
NIUK & Ireland

0 Kudos
Message 2 of 9
(4,772 Views)
Hi,

I am just curious where does this task saved, I mean do we need to give the address of this task in the VB code?
Something like "DAQmxLoadTask DAQmxCreateAOChan(MyAOVoltageOutTask, taskHandle)"
This "MyAOVoltageOutTask" is the task I created, and I want to import this task into my VB program. But comes with error said it not been defined.

Appreciate it!

Kevin
0 Kudos
Message 3 of 9
(4,519 Views)

Hello Kevin,

I understand that you are trying to load a task into your VB 6.0 program that has already been made in Measurement & Automation Explorer (MAX). To load a task that has already been made, you can use the DAQmxLoadTask function. In your case, the function would look something like “DAQmxErrChk DAQmxLoadTask(“MyAOVoltageOutTask”, taskHandle)” within your VB 6.0 program. You should not have to include the DAQmxCreateAOChan function if you are loading a task that has already been made and configured for analog output in MAX. It appears that you may just have incorrect syntax and that it is not recognizing the function you are giving it. Another thing to remember is to include the DAQmx C API within your project references by going to Project » References and placing a check next to DAQmx C API. If you can open a DAQmx example in VB 6.0, such as one found at C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\Visual Basic 6.0\Analog Out\Generate Voltage, you can simply replace the DAQmxCreateTask function with the DAQmxLoadTask function. Please let me know if this helps or let me know the specifics of whatever error you are receiving. Thanks,

Daniel S.
National Instruments
Message 4 of 9
(4,486 Views)
Hi I've been following this question with interest as I also are attempting to run a program set up in MAX via VB6. In VB the load task and clear task run without showing any errors but nothing appears to happen with the task set up in MAX. What am I missing here?
0 Kudos
Message 5 of 9
(4,266 Views)

The previous discussion was about using a task that already exists in MAX.  If you want to use VB to create a task in MAX, you need to use the normal API functions to create/modify a task and then use int32 __CFUNC     DAQmxSaveTask                  (TaskHandle taskHandle, const char saveAs[], const char author[], uInt32 options);

 

This function will save the task such that it will show up in MAX.

Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 6 of 9
(4,257 Views)

Hello,

 

This works great to call a task, however, where is the data stored?  Is it possible to get the data as an array of values? 

 

Do I need to call alot of "DAQmxGet...." and then start the  "DAQmxReadAnalogF64" function to do this?

 

Thanks for any help.

Message Edited by medendoc on 06-15-2010 09:34 AM
0 Kudos
Message 7 of 9
(4,033 Views)

Issue Resolved....

0 Kudos
Message 8 of 9
(4,024 Views)

hello..

i'am also have the same problem to create a new task, but in case i use vb2010 and use write difital channel. I just use example from vb but i still can't understand how to create task function. When i try to create new project with same example, this program have error at mytask. someone can help me..

0 Kudos
Message 9 of 9
(3,465 Views)