LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxRegisterSignalEvent callback not working

We are using LabWindows 2013 v 13.0.2 (278) .

We are using a small PXI-1036 chassis with Windows installed on the PXI-8820 controller.

We have a PXI-6509 DIO card in which only line 0 is being used on port 9. Other lines are being used on other ports. Port 9 line 0 is tied to our unit under test. The unit under test will pulse this line when it receives specific data from the test equipment.

 

The code that I was just given and instructed to get working within a day is:

 

 

 int StartDAQmx(char *DAQmxInstrument)
{

hPretrig = 0;                          // Pre-set handle
 char instrument[64] = {'\0'};   // Used for instrument string
 int status = 0;                        // Holds the function status

 

      sprintf(instrument, "%s/port9/line0", DAQmxInstrument);
 
      // Create the pretrigger task
      status = DAQmxCreateTask("Pretrig", &hPretrig);
      // Create the digital input channel
      status = DAQmxCreateDIChan(hPretrig, instrument, NULL, DAQmx_Val_ChanPerLine);
      // Setup change detection on the input channel, use the hardware timer (10 MHz)
      status = DAQmxCfgChangeDetectionTiming(hPretrig, NULL, instrument, DAQmx_Val_HWTimedSinglePoint, 1);
      // Disable digital input filtering
      status = DAQmxSetDIDigFltrEnable(hPretrig, instrument, 0);
      // Set the digital input minimum pulse width to 1.8 usec
//    status = DAQmxSetDIDigFltrMinPulseWidth(hPretrig, instrument, 0.0000018);
      status = DAQmxSetDIDigFltrMinPulseWidth(hPretrig, instrument, 0.0000010);
      // Enable the digital input filtering
      status = DAQmxSetDIDigFltrEnable(hPretrig, instrument, 1);
      // Register callback for change detection
      status = DAQmxRegisterSignalEvent(hPretrig, DAQmx_Val_ChangeDetectionEvent, 0, ChangeDetectionCallback, NULL);

 

      return 0;

 

 

The purpose of the callback routine is to count the number of pulses from the time we begin transmitting data to the unit under test until we stop transmitting data. I stepped through this code to verify that all of the returned statuses are zero indicating no errors with the calls. I set a breakpoint in the callback routine but the code never breaks at that location. The counter, that is incremented within the callback, never goes beyond zero. Both of these things indicate that the callback routine is never called.

 

 

int32 CVICALLBACK ChangeDetectionCallback(TaskHandle taskHandle,
  int32 signalID, void *callbackData)
{
---- some code ----
 return 0;
}

 

 

I have tried adjusting the few parameters with no luck. I have set up a pulse generator and verified that the NI-MAX test panel for the PXI-6509 detects the changes in the pulse, as indicated by the changes in the color of the light for that line. I did place the function call:

 

   ProcessSystemEvents();

 

after we quit transmitting data to determine if this helped. I had read that idea in a posting.

 

Any ideas would be appreciated. Thank you in advance for your help.

 

0 Kudos
Message 1 of 2
(4,020 Views)

I wish I could delete the post. Perhaps it will help someone else.

 

As I dug more into the code, I found, that while they were doing a DAQmxStartTask for all of the other ports they were using, they did not do it for this port.

 

My problem has been resolved.

Message 2 of 2
(4,015 Views)