Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Software for cDAQ-9171 + 9219 module + TJE Pressure Sensor

I am buying a NI cDAQ-9171 CompactDAQ 1-Slot USB Chassis and a NI 9219 module to read a Honeywell TJE pressure sensor. I plan to write Excel VBA code to have a PC periodically read the pressure values over USB from the CompactDAQ. This is all I need to do, so do I need any software package beyond what comes with the cDAQ-9171?  (I want to be sure I don’t need to buy a LabView package which can be quite expensive.)

0 Kudos
Message 1 of 17
(5,924 Views)

I did everything at the link, and in the References window I checked the NI DAQmx C API type library. But I’m unable to find VBA code examples to read the cDAQ-9171 Chassis w/ NI 9219 module. All I really need to do is read the pressure for the TJE sensor.

 

… It looks like you use the DAQmxReadAnalogF64 command after starting a task.

 

NI Max sees the sensor now, but that is no help with VBA coding.

0 Kudos
Message 3 of 17
(5,493 Views)

Have you taken a look at the Visual Basic 6.0 shipping examples? You should be able to reference these when working to create your VBA code. The files paths where you can find these are listed in this article.

0 Kudos
Message 4 of 17
(5,443 Views)

Yes, I had found those and over last weekend I converted them to VBA as best I could. I'm not having much luck getting it to work. That's  why having a real working example in VBA that runs in Excel would help a lot.

 

Normally in VBA when talking with an insturment that has a NI Visa driver, you include statements like shown below to set up the instrument. It appears when using DAQmx you don't need to do this, but it's not clear to me how the PC and software will know the address of the  CompactDAQ unit. Again, having a working VBA code example might help clear this up.

 

Set ioMgr = New VisaComLib.ResourceManager

Set instrument = New VisaComLib.FormattedIO488

Set instrument.IO = ioMgr.Open("ASRL5::INSTR")

0 Kudos
Message 5 of 17
(5,435 Views)

The device identification is specified in MAX (something like “cDAQ1Mod1”). You can use this identification string in your code when creating a channel. While we don’t have an example that is specific for your application you may want to take a look at the following example for DIO in VBA. It calls into the C API and shows how the device is specified when creating a new channel.

 

http://www.ni.com/example/25305/en/

 

Also, take a look at the following tutorial.  It has some code snippets that may be helpful examples for you as well.

 

http://www.ni.com/tutorial/5409/en/

0 Kudos
Message 6 of 17
(5,411 Views)

Thanks! Setting the physical channel to "cDAQ1Mod1/ai0" allows me to now apparently read a voltage from the CompactDAQ using DAQmxReadAnalogF64.

 

Now if I could get a command to work to config the bridge. Keep getting a "Variable not defined" error when I plug in values DAQmx_Val_FullBridge and DAQmx_Val_External like shown below. It seems like I should be able to enter these directly like shown below rather than having to create new variables.

 

DAQmxErrChk DAQmxCreateAIVoltageChanWithExcit(taskHandle, set_physicalChannel, "", DAQmx_Val_Cfg_Default, _
set_minValue, set_maxValue, "", DAQmx_Val_FullBridge, DAQmx_Val_External, 5, 1, "")

 

0 Kudos
Message 7 of 17
(5,397 Views)

I was able to take a look at the C header file, NIDAQmx.h, to see what those variables are defined as there. DAQmx_Val_External was defined as 10167 and DAQmx_Val_FullBridgeI was defined as 10183. You can try just using those values.

 

Also, you can find the header file at Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include to confirm those definitions for yourself.

0 Kudos
Message 8 of 17
(5,378 Views)

VBA doesn't have a .h file and it doesn't appear that Visual Basic has it either based on the NI example programs. So I don't know how to include  the codes that you show.

 

NI sells the TJE pressure sensor but there is no example code or desciption how to use it with DAQmx. I think it's a full bridge, but I can't find documentation that describes this or how to config the various NI function parameters. This is not looking too good becasue there are too many things that could be wrong in my set-up and software.

 

If I could find a pressure sensor that has a NI Visa driver instead of one tied into DAQmx -  that would be perfect. But I can't find any. An example of a nice USB-based pressure sensor is here:   http://www.omega.com/pptst/PXM409-USBH.html?pn=PXM409-070HGUSBH

0 Kudos
Message 9 of 17
(5,368 Views)

While VBA doesn’t have a header file I thought it might be useful to determine how those variables are enumerated for C and give those integers a try in your code.

 

Regardless, the easiest way to use your sensor would be in LabVIEW. There are a couple good tutorials about how to get started with your pressure sensor in this way.

 

http://www.ni.com/tutorial/7138/en/

https://www.youtube.com/watch?v=spTHTfjVlo8

 

However, if you didn’t want to use LabVIEW your best alternative would be C++ or VB6. VBA isn’t officially supported which is why you’re having trouble finding full blown examples.

0 Kudos
Message 10 of 17
(5,342 Views)