Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading NI 9203 module in cDAQ-9178 chassis using VB6

Hi guys.  Need some help.  I am using your Acq-Int Clk.vbp example project to communicate with several different modules.  I can talk to the Analog Voltage In (NI 9201) and Thermocouple (NI 9211) modules successfully using the following commands:

 

DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, "cDAQ1Mod1/ai0:7", "", DAQmx_Val_Cfg_Default, 0, 10, DAQmx_Val_VoltageUnits2_Volts, "")

DAQmxErrChk DAQmxCreateAIThrmcplChan(taskHandle, "cDAQ1Mod3/ai0:3", "", 0, 400, DAQmx_Val_DegF, DAQmx_Val_ThermocoupleType1_J_Type_TC, DAQmx_Val_CJCSource1_BuiltIn, 0#, "")

 

My problem is with the Analog Current In module (NI 9203).  I'm reading a Rosemount transducer that outputs a 4-20 mA output signal.  Im getting an "Error: 13 Type mismatch" error when using the following code and cannot figure out what I am doing wrong.  I assume the problem is with my min and max numbers, but I have tried every format I can think of without success:

 

DAQmxErrChk DAQmxCreateAICurrentChan(taskHandle, "cDAQ1Mod2/ai0:7", "", DAQmx_Val_Cfg_Default, 0.004, 0.02, DAQmx_Val_CurrentUnits2_Amps, DAQmx_Val_CurrentShuntResistorLocation1_Internal, "", "")

 

MAX of course can read it sucessfully so I know it is at least working.  Any help would be greatly appreciated.

0 Kudos
Message 1 of 14
(8,381 Views)

Really??? Nothing at all?  I thought this would be fairly easy to answer for an engineer but I guess not.  Did I post this to the wrong forum?  Can someone at least tell me where else I can go with this so I might get some kind of response???  Thanks

0 Kudos
Message 2 of 14
(8,349 Views)

Hi Chris,

 

There does not seem to be anything obvious in your code, hence leading me to think it may be a less noticeable issue.  Please try running the Current example as is to ensure there is not a setting that has been accidentally overlooked.  Do you receive the same error with the example?

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 3 of 14
(8,341 Views)

Thanks for your response.  Unless I'm missing something there isn't a current example for VB6.  I see there is one for vb.net and I do have VB 2010 installed, but Measurement Studio doesn't support it so the examples did not load.  Can you possibly send me a direct link to the current project itself so I can download it.  I'm sure I can open it in VB2010, I just need the files.  Thanks

0 Kudos
Message 4 of 14
(8,329 Views)

This is getting very frustrating.  Can someone please help me?  Attached is my project.  Comment out the DAQmxCreateAICurrentChan line and the code works great.  Uncomment and it results in a type mismatch error.  Any input/help would be greatly appreciated!

0 Kudos
Message 5 of 14
(8,298 Views)

The type library is based on the DAQmx C API library as explained here.  There is a current example called "Continuously Acquire 20mA Current Samples - Internal Clock" that can be referenced.  Also please be aware that NI-DAQmx 7.5 through NI-DAQmx 9.0.2 officially support VB6 via an included type library. The type library offers full support of the NI-DAQmx C API functions.  Installing the NI-DAQmx C API for later versions of NI-DAQmx will still provide the function calls and examples; however, not tested in VB6.

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 6 of 14
(8,275 Views)

I have NI-DAQmx 9.2.2 installed.  You're telling me that only up to version 9.0.2 supports VB6?  Is that my problem?  If so how can I get version 9.0.2?

0 Kudos
Message 7 of 14
(8,241 Views)

Hi Chris,

 

Only through DAQmx 9.0.2 has official support for VB6 which means it was tested.  Post DAQmx 9.0.2 the DAQmx C API should be used as described in the previously linked documents.  While this should work, it has not been tested and there may be bugs that are usually caught during the testing process.  You may download DAQmx 9.0.2 from Drivers and Updates.  As you have a later version of the driver already installed, it will need to be uninstalled prior to installing DAQmx 9.0.2.  All supported programming ADEs, hardware, and operating system information can be found in the readme files of the drivers.

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 8 of 14
(8,219 Views)

Thanks for the info.  I uninstalled all NI software via Add/Remove Programs, which was a 4 hour process, and rebooted.  I then reinstalled NI Measurement Studio 8.1.2 for Visual Studio 6.0, followed by NI-DAQmx 9.0.2, and rebooted, which took a total of over 3 hours.  I reopened the same project which I attached earlier in this thread and I still get the type mismatch error.  If the above software was tested and bug free I cannot understand why I continue to get this message.  Can you please have one of your software engineers take my attached project and confirm that it works.  If so then it is something with my system, if you guys get the same message then it is a bug that will you guys will need to fix.  I appreciate your help and I really don't want to go to my bosses and tell them we just spent $5000 for a new DAQ system that I cannot use because of a simple type mismatch error.  We have used your DAQ products for almost 20 years and they tried to get me to switch to something else when you recently discontinued your Fieldpoint platform, which I talked them out of.  I'm at a loss here.  If I can't figure this out I may be looking for another job.

 

With all that said...Attached is a screenshot of how I have it set up in MAX.  I have the min and max set at 3 mA and 20 mA.  When you type 0.003 and 0.020 it automatically changes to 3m and 20m.  In my program I have to specify 0.003 and 0.02, it of course will not accept 3m and 20m.  Could this have anything to do with my problem?  I have a transducer connected to the Current_0 channel, which you can see is reading 4.000377m.  So we know that it is reading properly between the computer and the DAQ system.

 

Thank you for your help and I look forward to your reply.

0 Kudos
Message 9 of 14
(8,211 Views)

Hi Chris,

 

I am pleased the hardware is working without issue and hopefully this will take care of the software error so you may successfully move forward.  Below is a screenshot comparison of the DAQmx C Reference Help and the current example previously referenced parallel to your line of code.  It appears that you are passing a string in place of a number for the shunt resistor value (indicated in red).  If a number is expected and a string is passed, then I anticipate this would produce a type mismatch error like you are seeing.  Let me know if you are still experiencing difficulty after this substitution.

 

Code Comparison.png

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 10 of 14
(8,175 Views)