Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically check for DAQ card?

Hi,
 
I want to have my application set or reset a flag depending on the presence of a DAQ device.  I want this to happen as soon as the program loads.
Is this possible?
 
Max
0 Kudos
Message 1 of 13
(9,605 Views)
MadMax,

Yes, you can do what you want.

Attached is a VI I quickly created which shows how you can access the information about which DAQ devices are connected to the computer.  What you do with the information is up to you.

Have a good day,

Lorne Hengst
Application Engineer
National Instruments
0 Kudos
Message 2 of 13
(9,576 Views)

Hi Lorne,

Thanks for the VI, but I actually was looking for a VB6 example.

Max

0 Kudos
Message 3 of 13
(9,574 Views)
MadMax,

Use the functions below to get the information you need...

DAQmxGetSysDevNames
DAQmxGetDevProductType
DAQmxGetDevSerialNum

I believe you will need NI-DAQmx 7.5 in order to have access to these functions for VB.

Lorne Hengst
Application Engineer
National Instruments
0 Kudos
Message 4 of 13
(9,569 Views)

Hi Lorne,

I should have posted a little more information at first, so I apologize.  I assumed that since I was posting in the Measurement Studio for VB6 forum, it would be assumed that I was using the component works tools.

Details: PCI-6013, Visual Basic 6, Measurement Studio 6, niDAQ 6.9.3

I can and will update my niDAQ driver, however the function calls you're referring to are part of the Measurement Studio cwDAQTools object.  So, although I haven't tried the direct function calls in niDAQ 7.5, (mostly because I'm not familiar with the direct function calls), I did try the cwGetDeviceName and the cwGetDeviceSerial using the cwDAQTools object.  These generate the Run-time error '10401' (specified device is not a National Instruments product, ). 

Can you tell me if this is related to my niDAQ driver, or is there any other way that I can check for the presence of a DAQ card before calling for the code to perform operations with the card.

Basically, what I'm trying to do, is when the software starts, I want it to detect if a DAQ card is present (automatically).  If the card isn't present, then the software will go into a simulation mode.  If the software is present then the card needs to active a DIO pin immediately.  If I was able to trap for the error that is generated when the card attempts to set the DIO pin, and the card isn't present, then I could switch to Sim mode.  This would be another way to skin the cat, but I'm not aware of anyway to do this either.

Help would be greatly appreciated.

Max

 

0 Kudos
Message 5 of 13
(9,554 Views)
MadMax,

I would like to apologize for all of the confusion I created for myself.  Sometimes I look at so many postings a day that I forget to do the simple things, like check to see what forum I am in.

Well...  The error -10401 is the expected error to recieve when you try to get information from a device that is not there.  You should be able to intercept the error and use it to determine whether or not so simulate a specific device.

Can you send me the portion of your code that is supposed to handle this?  I am sure we can figure something out.

You should be able to make this work with the NI-DAQ 6.9.3 driver.  If you feel up to the work, I would recommend trying to code your program using NI-DAQmx 7.5 and use the driver's new found support for Visual Basic 6.

Lorne Hengst
Application Engineer
National Instruments
0 Kudos
Message 6 of 13
(9,540 Views)

Hi Lorne,

There's not really anything to send you because I've not managed to get anything to work.  From the Form Load procedure, I would normally be setting a port pin high:  (CWDIO.singlewrite 1) as an example.  When I do this, and no card is present I get the expected error.  I would like to trap for that error immediately and set a flag.  Lets say SimMode = True.

I'm not sure that using NI-DAQmx 7.5 is a possibility with this card.  I tried installing the driver, but it didn't list the PCI-6013.  It may have been that I didn't install the Traditional DAQ driver properly, but I know that the PCI-6013 is not supported with the mx.  So I'm not even sure that the mx function calls would be an option for me.

If you can show, or tell me how to intercept that I error, I'd greatly appreciate it.

Regards,

Max

0 Kudos
Message 7 of 13
(9,537 Views)
Max,
The PCI-6013 is supported in DAQmx -- you can see this here: http://www.ni.com/support/daq/versions_pci_pxi.htm.  I would highly recommend using the NI-DAQmx and function calls Lorne mentioned over the much older Component Works driver.  If you must use the Component Works driver, you should be able to do a simple if statement checking the error code that is returned to see if it matches the error code for when no devices are present, then act accordingly.

Doug M
Applications Engineer
National Instruments
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 8 of 13
(9,521 Views)



Hello MadMax




I also needed to check for the DAQ card in my program. What I did was check to see if properties specific to the DAQ card had been populated.




For example on a form I have to manually control the operations of the test equipment I have the following code in my timer event.





IF THISFORM.nidio.devicename <> "none"



* code to update values on form




ELSE



THIS.ENABLED = .F.



MESSAGEBOX("NO DAQ card detected!",16,"Error")



thisform.Release()



ENDIF

You could essentially do the same thing as along as a NIDaq object that requires the DAQ Card had been instantiated.

Hope this helps...
0 Kudos
Message 9 of 13
(9,461 Views)
I am having the same difficuly.  Running VB6, Measurement studio 6 (with the updates), and NI DAQmx 7.5, and PCI-6723.  The DAQTools object is unable locate the device, even though it shows up perfectly in measurement & automation explorer.  Since I can not find the device, I can not use it.  The code I use has always worked in the past with tradition NI DAQ, but somthing is different with NI DAQmx, I just have not figured it out yet.  If I do I will reply.
0 Kudos
Message 10 of 13
(9,447 Views)