From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

6534 - Having difficult time setting up simple Handshaking

Hello all,

 

I'm trying to set up the simplest of programs to read one, 16 bit digital input word when an external strobe changes state.  I have a test fixture with 16 DIP switches to set the digital value and a push button for the strobe.

 

Now using the example program - ReadDigPort.c, I can reaad in one 16-bit word successfully.  But it reads it immediately. So then I tried to modify it to trigger on PFI2 (used to be called REQ1).  I am using Ports 0 and 1 so I need to use Group 1 strobe signals.  As I under stand it the REQ1 line is now called PFI2 (true?)

 

So here is my code fragment to try and set up handshaking.  It doesn't work - I get a timeout. So what am I missing? Is there am additional function call I need to add to set up the handshaking?

 

       DAQmxErrChk (DAQmxCreateTask("Exploratory",&taskHandle));


       DAQmxErrChk (DAQmxCreateDIChan(taskHandle, \
                                       "Dev1/port0:1", \
                                       "EventWord", \
                                       DAQmx_Val_ChanForAllLines));

        DAQmxErrChk (DAQmxGetHshkStartCond(taskHandle, &startcond));

              (Note - a print out of the return value from this call is - gives a 10151 DAQmx_Val_DI )

 

        DAQmxErrChk (DAQmxGetChanType(taskHandle, "EventWord", &chantype) );

              (Note - a printout of the return value from this call is - 12550 - DAQmx_Val_WaitForHandshakeTriggerAssert)

 


        DAQmxErrChk (DAQmxCfgHandshakingTiming(taskHandle, \
                                               DAQmx_Val_FiniteSamps, \
                                               2));

 

       /*********************************************/
       // DAQmx Start Code
       /*********************************************/
       DAQmxErrChk (DAQmxStartTask(taskHandle));

       /*********************************************/
       // DAQmx Read Code
       /*********************************************/
      DAQmxErrChk (DAQmxReadDigitalU32(taskHandle,1,10.0,DAQmx_Val_GroupByChannel,&data,1,&read,NULL));

The error message (below) suggest that maybe the start trigger is not configured correctly. Have I lef tout necessary steps to do this configuration?

 

I am at a loss as to what needs to be done to get this to work. I've studied the NI-DAQ User Manual a great deal (is there a User Manual PDF for DAQmx????) and I've read a myriad of tutorials and web pages but I cannot find a discussion of how to actually select the strobe line I want to use (Group 1).

 

 

Thank you very much.

 

Gregg

 

Here is the Error Message:

 

DAQmx Error: Some or all of the samples requested have not yet been acquired.

To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger,  make sure that your start trigger is configured correctly. It is also possible that you configured the task for external timing, and no clock was supplied. If this is the case, supply an external clock.
Property: DAQmx_Read_RelativeTo
Corresponding Value: DAQmx_Val_CurrReadPos

Property: DAQmx_Read_Offset
Corresponding Value: 


Task Name: Exploratory

Status Code: -200284

 

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

Hi Gregg,

You may want to try increasing your timeout on your DAQmxReadDigitalU32 function.  You currently have it set at 10 seconds.  You can set this to -1 to make it infinite.

 

You may also want to take a look at this example for further guidance:

 

Input Digital Data from a Digital Port Upon a Handshaking Signal

 

It uses an older version of the driver but may be instructive as to the steps you must take.

 

FYI - You can find all documentation for our DAQmx C API here:

 

NI-DAQmx C Reference Help

 

Regards,

Regards,
Chris Elliott
x36772
0 Kudos
Message 2 of 2
(4,820 Views)