Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxReadAnalogF64 error -200492 error in Excel VBA 2016

I would like to read 1536 samples on channel 1 of my USB 60001. I’m using Excel VBA 2016.

This is the code:

Private Sub CommandButton1_Click()

Dim taskHandle As Long

Dim Status As Long

Dim data(1535) As Double

Status = DAQmxCreateTask("", taskHandle)

Status = DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai1", "", DAQmx_Val_InputTermCfg_Diff, -10, 10, DAQmx_Val_VoltageUnits2_Volts, "")

Status = DAQmxCfgSampClkTiming(taskHandle, "OnboardClock", 15360, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_FiniteSamps, 1536)

Status = DAQmxReadAnalogF64(taskHandle, 1536, 10, DAQmx_Val_GroupByChannel, data(0), 1536, 1536, ByVal Nothing)

Status = DAQmxClearTask(taskHandle)

End Sub

 

Status = DAQmxReadAnalogF64(taskHandle, 1536, 10, DAQmx_Val_GroupByChannel, data(0), 1536, 1536, ByVal Nothing)

Gives error code

Error -200492

Reserved parameter must be NULL.

 

 I have tried using  ByVal 0& , ByVal Nothing and  bvNullString and none worked.

Can please somebody help?

Thanks,

Gilbert

0 Kudos
Message 1 of 2
(2,294 Views)

Hi GNKu,

 

While I am not certain what would be causing that error for you in Excel, I wanted to share a couple of examples with you for using VBA in Excel with DAQmx.

 

Hopefully, you can test these examples to make sure your system is set up correctly, and then implement them into your own code to accomplish your measurement.

 

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

 

https://forums.ni.com/t5/Example-Program-Drafts/Using-DAQmx-with-Microsoft-Excel-Visual-Basic-for-Ap...

Casey G.
0 Kudos
Message 2 of 2
(2,258 Views)