03-15-2018 03:23 PM
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
03-16-2018 04:12 PM
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/