Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Thanks for the help. I have an elaborate test set-up build around VBA and Excel, so I have to stick with VBA. I use NI Visa to talk with insturments, and it works great. I'll buy another pressure sensor that includes logging software, and I'll have VBA open the log file peridoically and copy pressure readings. I have found that this works with other instruments when there is no NI VIsa driver.

0 Kudos
Message 11 of 17
(1,907 Views)

I found that other USB pressure transducers on the market don’t have the high temperature rating of the Honeywell/NI TJE transducer. So I’m back to trying to get this TJE transducer to work with DAQmx.

 

I found this function that should make things easier: DAQmxCreateAIPressureBridgeTwoPointLinChan.

 

However, when trying to use this function in VBA I get error message “Sub or Function Not Defined” where the top of the message box is labeled “Microsoft Visual Basics Applications”. It seems that this function is not supported in DAQmx. I upgraded to DAQmx v15.5 (the latest available), but that did not help.

 

When I highlight the function in the code and activate a list of available DAQmxCreateAI functions, DAQmxCreateAIPressureBridgeTwoPointLinChan is not listed as an option. It appears that there are no Bridge functions available for use with Visual Basic. Is there some way to get a full bridge working for a pressure transducer with another function in Visual Basic (VBA)?

0 Kudos
Message 12 of 17
(1,897 Views)

Hi Dan747,

 

I set up an example in excel and I am seeing the same thing you are. The DAQmxCreateAIPressureBridgeTwoPointLinChan works in our supported C environment (LabWindows/CVI), but since VBA isn't one of the supported environments of our DAQmx C API there is probably something with the way that and other functions are written that can't be used in VBA. The only function that is available in VBA and would output pressure explicitly is the DAQmxCreateAIMicrophoneChan, but I don’t know that this would do what you need it to. I believe you will need to use either the DAQmxCreateAIVoltageChanWithExcit or DAQmxCreateAIVoltageChan functions depending on your set up. And then, due to the fact that this does not output reading in pressure units, implement some custom scaling to transition from Voltage to Pressure.

A Johnson
Applications Engineer
National Instruments
0 Kudos
Message 13 of 17
(1,870 Views)

Thanks. I tried to use DAQmxErrChk DAQmxCreateAIVoltageChanWithExcit earlier (see March 15 post). While the function was recognized, the control parameters entered such as DAQmx_Val_FullBridge caused "Variable not defined" errors. Below I show how I added some dimensioning for parameters and now the errors are gone. But after adding the other code needed including DAQmxReadAnalogF64 to read the data, I only get back all zeros. NI Max gives actual pressure readings, so I’m not sure why I only get back zeroes from the code.

 

Option Explicit

Public DAQmx_Val_FullBridge As DAQmxBridgeConfiguration1

Public DAQmx_Val_Internal As DAQmxExcitationSource

Public DAQmx_Val_Volts As DAQmxVoltageUnits2

 

DAQmxErrChk DAQmxCreateAIVoltageChanWithExcit(taskHandle, "cDAQ1Mod1/ai0", "", DAQmx_Val_Cfg_Default, _
-100, 500, DAQmx_Val_Volts, DAQmx_Val_FullBridge, DAQmx_Val_Internal, 2.5, 1, "")

0 Kudos
Message 14 of 17
(1,860 Views)

Still trying to get basic DAQmx functions to work in VBA. This link implies VBA should work:  https://decibel.ni.com/content/docs/DOC-19654

 

For the code below, function DAQmxCreateAIVoltageChan gets an error from the ErrorHandler with message: “Error: -200077 Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.” Any ideas on how to fix this?

 

 

' ******

Option Explicit

Public taskHandle As Long

Public taskIsRunning As Boolean

Public minVal As Double

Public maxVal As Double

Public DAQmx_Val_Cfg_Default As DAQmxInputTermCfg

Public DAQmx_Val_Volts As DAQmxVoltageUnits2

 

Sub Macro_Read_Pressure_Sensor()

 

minVal = -60   ' In volts

maxVal = 60    ' In volts

 

On Error GoTo ErrorHandler

      

DAQmxErrChk DAQmxCreateTask("", taskHandle)   ' taskHandle is an output

taskIsRunning = True

       

 DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, "cDAQ1Mod1/ai0", "", _

     DAQmx_Val_Cfg_Default, minVal, maxVal, DAQmx_Val_Volts, "")

 

‘ Other DAQmx functions here …

  

StopTask

 

Exit Sub

 

' ********

0 Kudos
Message 15 of 17
(1,793 Views)

I tried out your code on my own and I didn’t receive that same error. However, there was another error with that function call related to syntax. You should make sure there is no underscore before DAQmx_Val_Cfg_Default. I don’t know if that was a typo while making the forum post or if it’s a typo in the code. Either, make sure it is removed.

 

Was there any more information that was provided with that error message? Often if a property is mentioned there will be a listing of the property name and the expected value type.

0 Kudos
Message 16 of 17
(1,775 Views)

The underscore means the code is continued on the next line in VB.

 

After more attempts I was able to read a voltage using the code below. The parameter "DAQmx_Val_VoltageUnits1_Volts" is not documneted on the NI webpage for the  DAQmxCreateAIVoltageChan function. I found it elsewhere, but it seems to work.

 

Next I'll try to read a thermocouple and then finally the pressure transducer.

 

******

Option Explicit
Public value As Double
Public taskHandle As Long
Public taskIsRunning As Boolean
Public minVal As Double
Public maxVal As Double

 

Sub Macro_Read_Pressure_Sensor()

 

On Error GoTo ErrorHandler

 

minVal = -60 ' In volts
maxVal = 60 ' In volts

DAQmxErrChk DAQmxCreateTask("", taskHandle) ' taskHandle is an output
taskIsRunning = True

DAQmxErrChk DAQmxCreateAIVoltageChan(taskHandle, "cDAQ1Mod1/ai0", "", _
DAQmx_Val_Cfg_Default, minVal, maxVal, DAQmx_Val_VoltageUnits1_Volts, "")

DAQmxErrChk DAQmxReadAnalogScalarF64(taskHandle, 10#, value, ByVal 0&)

 

ActiveCell.Activate
ActiveCell.offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = value     ' is written to Excel cell

StopTask

 

Exit Sub

******

0 Kudos
Message 17 of 17
(1,769 Views)