02-26-2012 08:13 PM
Hi,
I am trying to measure several analog current inputs using a NI9203 module in a compactDAQ 9178 8-slot chassis. I am using DAQmx 9.4 on a Windows 7 x64 system with Excel 2010.
I get a -200077 error when trying to call:
DAQmxErrChk DAQmxReadAnalogF64(taskHandle, numSampsPerChannel, 10, fillMode, data(0), arraySizeInSamps, sampsPerChanRead, ByVal 0&)
in my program. I have been trying for ages to get this to work, but always the same error no matter what I do. Extended error info from NI I/O Trace is in the two image files attached.
Help much appreciated. Complete code for the userform also attached.
Regards,
James.
02-27-2012 04:31 PM
Hello, Hydroworks!
According to this Developer Zone article: Using NI-DAQmx in Text Based Programming Environments, the DAQmxReadAnalogF64 function requires the sampsPerChanRead to be an Int32. (It's about 2/3 of the way down, the 3rd instance of "sampsPerChanRead" if you use the "find" function on the page). I see from the code you attached that you're currently defining it as a Long (Int64). Try switching the variable definition to Integer, and see if the error persists.
If so, let us know!
02-27-2012 07:37 PM
Hi Will NI,
Thanks for your response. The function quick info in the vba editor asks for a LONG (see attached image) and throws a compile error if I try and use a different data type. Any other ideas? Anyway, I thought LONG was 32 bit (4 byte)?
Regards,
James.
02-28-2012 04:35 PM
Hello, Hydroworks!
In some languages Long is 4bytes, but in VBA it's actually 8bytes (which you can verify here). But it looks like that's not the problem here.
It looks like you may need to explicitly decalare a value for the sampsPerChanRead, since the code you sent only declares it as a variable (it may dafult to zero, hence the output error you saw). You'll also need to make sure that the samples per channel read isn't greater than the samps per channel value (which you currently have set to 10).
Try declaring a value, and see if that fixes the error. If not, let us know!
03-01-2012 03:37 AM
03-01-2012 03:29 PM
Hello, hydroworks!
Since you're still seeing the error, we can just check out explicitly what VBA is looking for.
This KnowledgeBase: What are the Supported Parameters for NI-DAQmx Functions in Visual Basic?, which explores the same error you're receiving, explains where to find the NIDAQmx.h header file. This will outline which integers your function is looking for, and you can then feed them explicitly.
Let me know if this helps!