02-24-2006 08:19 PM
02-28-2006 11:36 AM
01-06-2010 02:45 PM
I've hit the same problem that David did - has NI published anywhere the equivalent Declare statements or do I, like David, have to figure them out by trial and error?
For apps that support multiple hardware devices, including traditional and mx based systems, being able to use Declare statements is important.
Thanks,
Van
01-06-2010 04:05 PM
G'Day Van,
I don't know whether NI has done anything about the declarations, but here are the ones I put together, to save you the trouble of rediscovering them!
Cheers,
David
Declare Function DAQmxReadDigitalScalarU32 Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal timeout As Double, ByRef Value As Long, ByRef reserved As Any) As Long
Declare Function DAQmxWriteDigitalScalarU32 Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal AutoStart As Boolean, ByVal timeout As Double, ByVal Value As Long, ByRef reserved As Any) As Long
Declare Function DAQmxAddGlobalChansToTask Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal ChannelNames As String) As Long
Declare Function DAQmxGetTaskNumChans Lib "nicaiu.dll" (ByVal taskHandle As Long, ByRef data As Long) As Long
'Declare Function DAQmxCfgSampClkTiming Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal source As String, ByVal rate As Double, ByVal activeEdge As Long, ByVal samplemode As Long, ByVal sampsperchan As Currency) As Long
Declare Function DAQmxCfgSampClkTiming_VB6 Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal source As String, ByVal rate As Double, ByVal activeEdge As Long, ByVal samplemode As Long, ByVal sampsperchan As Long) As Long
Declare Function DAQmxCfgInputBuffer Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal arraySizeInSamps As Long) As Long
'Declare Function DAQmxRegisterEveryNSamplesEvent Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal everyNSamplesEventType As Long, ByVal nSamples As Long, ByVal options As Long, ByVal callbackfunction As Long, ByVal callbackdata As Any) As Long
Declare Function DAQmxRegisterEveryNSamplesEvent_VB6 Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal everyNSamplesEventType As Long, ByVal nSamples As Long, ByVal options As Long, ByVal callbackfunction As Long, ByRef callbackdata As Long) As Long
Declare Function DAQmxGetTaskDevices Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal data As String, ByVal buffersize As Long) As Long
Declare Function DAQmxGetDevIsSimulated Lib "nicaiu.dll" (ByVal device As String, ByRef data As Boolean) As Long
Declare Function DAQmxCreateTask Lib "nicaiu.dll" (ByVal taskname As String, ByRef taskHandle As Long) As Long
Declare Function DAQmxStartTask Lib "nicaiu.dll" (ByVal taskHandle As Long) As Long
Declare Function DAQmxStopTask Lib "nicaiu.dll" (ByVal taskHandle As Long) As Long
Declare Function DAQmxClearTask Lib "nicaiu.dll" (ByVal taskHandle As Long) As Long
Declare Function DAQmxGetErrorString Lib "nicaiu.dll" (ByVal errorCode As Long, ByVal errorString As String, ByVal buffersize As Long) As Long
Declare Function DAQmxCreateDIChan Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal lines As String, ByVal name As String, ByVal linegrouping As Long) As Long
Declare Function DAQmxCreateDOChan Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal lines As String, ByVal name As String, ByVal linegrouping As Long) As Long
Declare Function DAQmxReadAnalogF64 Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal numSampsPerChan As Long, ByVal timeout As Double, ByVal fillmode As Long, ByRef readArray As Double, ByVal arraySizeInSamps As Long, ByRef sampsPerChanRead As Long, ByRef reserved As Any) As Long
Declare Function DAQmxGetSysNIDAQMajorVersion Lib "nicaiu.dll" (ByRef data As Long) As Long
01-06-2010 04:33 PM
02-10-2010 09:08 AM
Indeed great work, but I'm missing the DAQmxWriteAnalogF64 declaration here. I'd figured it should be done like:
Declare Function DAQmxWriteAnalogF64 Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal numSampsPerChan As Long, ByVal autoStart As Boolean, ByVal timeout As Double, ByVal dataLayout As Boolean, ByRef writeArray As Double, ByRef sampsPerChanWritten As Long, ByVal reserved As Any) As Long
but when I call this function by using
DAQmx_ErrChk DAQmxWriteAnalogF64(taskhandle, 1000&, True, 10.0#, DAQmx_Val_GroupByScanNumber, writeArray(0), sampsPerChanWritten, byVal 0&)
my system crashes. So what went wrong?
Regards,
Charlie
06-09-2010 05:11 PM
I've hit another snag in trying to avoid the problems Dave outlined early (need to support users who use Trad NIDAQ and do not have NIDAQmx installed for a start, and even users who have no NIDAQ at all) - I've run into a function that I cannot determine the correct Declare statement for.
DAQmxCfgDigEdgeStartTrig has a definition in the c library as:
int32 DAQmxCfgDigEdgeStartTrig (TaskHandle taskHandle, const char triggerSource[], int32 triggerEdge);
So, it would seem that the VB6 declare statements would look like this:
Private Declare Function DAQmxCfgDigEdgeStartTrig Lib "nicaiu.dll" (ByVal taskHandle&, ByVal trigsource$, _
ByVal trigEdge As Long)
However, this gives me a VB "Bad DLL calling convention error" when I execute it in code, with what I believe are valid parameters.
If anyone else has successfully used this function in VB6, please let me know what the trick is!
Thanks,
Van