Discussion:
PCI-6503 callback
(too old to reply)
adifly
2008-03-26 02:40:06 UTC
Permalink
<img height="1 alt=" src="Loading Image..." width="1" border="0">

yI am trying to develop with the PCI-DIO-24 (PCI-6503) in VC6&nbsp; / Ni-DAQ version 7.4. I simply want a function to be called when a digital input goes high or low. but the callback function&nbsp;always&nbsp;be no &nbsp;response.Have anybody can help me to find what's wrong?
my code:&nbsp;basis of &nbsp;DAQTest.zip#include &lt;afx.h&gt;#include &lt;afxwin.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // MFC core and standard components#include "nidaqex.h"#include &lt;iostream&gt;using namespace std;
void __stdcall OnDataCallback(HWND handle,&nbsp;UINT msg, WPARAM wParam, LPARAM lParam) ;
void main(void){ &nbsp;&nbsp; &nbsp;int nRetCode = 0;// initialize MFC and print and error on failure&nbsp;if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))&nbsp;{&nbsp;&nbsp;cerr &lt;&lt; _T("Fatal Error: MFC initialization failed") &lt;&lt; endl;&nbsp;&nbsp;return;&nbsp;}&nbsp;&nbsp;&nbsp; i16 iStatus = 0, iRetVal = 0, iDBmodeON = 1, iDBmodeOFF = 0, iDevCode = 0;&nbsp;i16 iSampTB = 0;&nbsp;&nbsp;&nbsp; u16 uSampInt = 0;&nbsp;i16 iHalfReady = 0;&nbsp;&nbsp;&nbsp; i16 iDAQstopped = 0;&nbsp;&nbsp; u32 ulPtsTfr = 0;&nbsp;&nbsp;&nbsp; i16 iIgnoreWarning = 0;&nbsp;&nbsp;i16 iGain = 1; i16 iUnits = 0;&nbsp;&nbsp;&nbsp;&nbsp; u32 ulCount = 1000;&nbsp; f64 dSampRate = 2.0;&nbsp;static i16 piHalfBuffer[50000] = {0};&nbsp;i32 lTimeout = 180;
&nbsp;i16 iDevice = 1;&nbsp; &nbsp;iStatus = Init_DA_Brds(iDevice, &amp;iDevCode);&nbsp;iRetVal = NIDAQErrorHandler(iStatus, "Init_DA_Brds", iIgnoreWarning);
&nbsp;i16 iChan = 0;&nbsp; &nbsp;int iMode = 1;&nbsp;int iDirection = 0;&nbsp;iStatus=DIG_Prt_Config(iDevice,iChan,iMode, iDirection);&nbsp;iRetVal = NIDAQErrorHandler(iStatus, "DIG_Prt_Config", iIgnoreWarning);
&nbsp;CString strChan;&nbsp;strChan.Format("DI%-d",iChan);&nbsp;&nbsp;const int nMaxStrChan = 128;&nbsp;i8 FAR chanStr[nMaxStrChan]; memset(chanStr, 0, nMaxStrChan);&nbsp;strcpy(chanStr, (LPCSTR)strChan);
&nbsp;i16 nDAQEvent = 8, nAddMode = 1; &nbsp;&nbsp;i32 nTrigVal0 = 1, nTrigVal1=0,nIgnor = 0;&nbsp;iStatus = Config_DAQ_Event_Message( iDevice,nAddMode, chanStr,nDAQEvent, nTrigVal0, nTrigVal1, nIgnor, nIgnor, nIgnor,&nbsp;&nbsp;NULL, NULL,&nbsp; (unsigned long)(&amp;OnDataCallback));&nbsp;iRetVal = NIDAQErrorHandler(iStatus, "Config_DAQ_Event_Message", iIgnoreWarning);
&nbsp;&nbsp;i16 iGroup = 0;&nbsp;i16 iGroupsize = 1;&nbsp;static i16 portList[1] = {0};
&nbsp;iStatus = DIG_SCAN_Setup(iDevice, iGroup, iGroupsize, portList, iDirection);&nbsp;iRetVal = NIDAQErrorHandler(iStatus, "DIG_SCAN_Setup", iIgnoreWarning); &nbsp;&nbsp;static i16 piBuffer[100] = {0};//accept 100 items only&nbsp;iStatus = DIG_Block_In(iDevice, iGroup, piBuffer, 1000);&nbsp;iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_In", iIgnoreWarning);
&nbsp;&nbsp;&nbsp; printf(" Continuous acquisition has started.\n");&nbsp;&nbsp;&nbsp; printf(" HINT: You can add your own graphing calls in the while loop.\n");&nbsp;TRACE(" Continuous acquisition has started.\n");&nbsp;&nbsp;&nbsp; TRACE(" HINT: You can add your own graphing calls in the while loop.\n");&nbsp;&nbsp;&nbsp;&nbsp; while (iLoopCount &lt;10) &nbsp;{&nbsp;&nbsp;if (iLoopCount)&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;printf(" get call back %d!\n",iLoopCount);&nbsp;&nbsp;&nbsp;break;&nbsp;&nbsp;&nbsp;iLoopCount++;&nbsp;&nbsp;}&nbsp;&nbsp;::Sleep(5);&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; printf(" Continuous acquisition is done!\n");&nbsp;TRACE(" Continuous acquisition is done!\n");&nbsp;&nbsp;&nbsp; /* CLEANUP - Don't check for errors on purpose. */&nbsp;&nbsp;&nbsp; iStatus = DAQ_Clear(iDevice);&nbsp;&nbsp;&nbsp; iStatus = DAQ_DB_Config(iDevice, iDBmodeOFF);&nbsp;&nbsp;&nbsp; iStatus = Timeout_Config(iDevice, -1);}
void __stdcall OnDataCallback(HWND handle,&nbsp;UINT msg, WPARAM wParam, LPARAM lParam) { &nbsp;i32 iPattern=0;&nbsp;D
derekwu
2008-04-01 08:10:07 UTC
Permalink
I suggest you install NI-DAQmx instead of traditional DAQ.
<a href="http://digital.ni.com/public.nsf/allkb/FB26BDA52FFFD4EE86257124005C36C3" target="_blank">http://digital.ni.com/public.nsf/allkb/FB26BDA52FFFD4EE86257124005C36C3</a>
Continue reading on narkive:
Loading...