LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmx equivalent to Tranditional NI-DAQ ND_ARMED

Hi,
I'm converting a traditional NI-DAQ application to NI-DAQmx.  I'm working in Labwindows/CVI V8.1
 
I have a task that is collecting buffered edge counter data using an ArmStart trigger to synchronize 2 counters.  I need to monitor whether the trigger has happened and the data collection is started.
 
In traditional NI-DAQ I used:
 
   GPCTR_Watch (DAQ_DEVICE_NUM, ND_COUNTER_0, ND_ARMED, &isArmed0);
I'm having a heck of a time finding an equivalent for the above in NI-DAQmx.
 
Any ideas?,
Kirk
 
 
 
0 Kudos
Message 1 of 4
(4,197 Views)
Kirk,

If you are trying to check the state of the counters then, in DAQmx you can monitor the state of the counter, whether input or output using the following functions DAQmxGetCOOuputState or the DAQmxGetCIInputState.

You could also use DAQmxGetCOPulseIdleState, DAQmxSetCOPulseIdleState, DAQmxResetCOPulseIdleState, to monitor the idle state of the counter.  This function tells you what the resting state of the output terminal is. 

If you tell me a little more about your application, I could try to find an example program for you as well or a workaround.

Hope this helps.

Regards,
Raajit L
National Instruments
0 Kudos
Message 2 of 4
(4,170 Views)

Hi Raajit,

The application is a production test fixture for a resolver position feedback device.
Long story short, it uses a very accurate encoder on the same shaft as the resolver to
verify the accuracy of the resolver.
There are 4 counters involved. 0 & 1 are up/down counters that are used to keep track of the
position of the resolver and the encoder.  Counter 2 also is connected to the encoder
and is used to generate a pulse every n resolver counts.  This counter is programmed to generate
"n" pulses per revolution. Its output is wired to the gate input of 1 & 2 and is used to clock in
the samples. The gate input to counter 3 is wired to the encoder's index pulse (once every 360 degrees)
and is used to trigger the start of the data capture (Ctr 3 doesn't do any counting, just a trigger). 

***** Traditional NI-DAQ *******

Here's a snippet the old traditional NI-DAQ code used to set up one of the counters
 // ************ Configure Counter 0 to collect position information *************
 // start the counter operation
 GPCTR_Control (pSc->boardNum, pSc->counterNumber, ND_RESET);
 // set the counter for buffered event counting
 GPCTR_Set_Application (pSc->boardNum, pSc->counterNumber, ND_BUFFERED_EVENT_CNT);
 // set the data buffer and number of samples to collect
 GPCTR_Config_Buffer (pSc->boardNum, pSc->counterNumber, 0, pSc->sampleCount, pSc->positionCounterBuffer);
 // use hardware control of the direction line
 GPCTR_Change_Parameter (pSc->boardNum, pSc->counterNumber, ND_UP_DOWN, ND_HARDWARE);
 // count on falling edge
 GPCTR_Change_Parameter (pSc->boardNum, pSc->counterNumber, ND_SOURCE_POLARITY, ND_HIGH_TO_LOW);
  // Set the initial count
 GPCTR_Change_Parameter (pSc->boardNum, pSc->counterNumber, ND_INITIAL_COUNT, pSc->initialCount);
 // Set to count in synchronous mode
 GPCTR_Change_Parameter (pSc->boardNum, pSc->counterNumber, ND_COUNTING_SYNCHRONOUS, ND_YES);
 // set the counter to use a hardware trigger.
 GPCTR_Change_Parameter (pSc->boardNum, pSc->counterNumber, ND_START_TRIGGER, ND_ENABLED);
 // select the output of counter 3 ( which is the sample clocke ) as the trigger
 Select_Signal (pSc->boardNum, ND_START_TRIGGER, ND_PFI_27, ND_LOW_TO_HIGH);  
 // start the counter operation
 GPCTR_Control (pSc->boardNum, pSc->counterNumber, ND_PREPARE);

In another section of code in the traditional NI-DAQ version I used:
 GPCTR_Watch (DAQ_DEVICE_NUM, ND_COUNTER_0, ND_ARMED, &isArmed0);
to see if the data collection for that revolution had started and reported status to the screen:

QUESTION IS:  How do I accomplish the above line of code in NI-DAQmx?

***** DAQmx *******
The DAQmx setup code looks similar to:

  // create the CTR0 task
  DAQmxCreateTask("",&dthCounter0Enc);
  // Use ctr0 on the PCI-6602 to count edges from the encoder
  DAQmxCreateCICountEdgesChan ( dthCounter0Enc, appendToDeviceName( strTemp, daqDevNameStrPCI6602, "ctr0" ),"",DAQmx_Val_Falling,0,DAQmx_Val_ExtControlled );
  // Used to be called synchronous counting mode
  DAQmxSetChanAttribute (dthCounter0Enc, "", DAQmx_CI_DupCountPrevent, 1);
  // initial count
  DAQmxSetChanAttribute (dthCounter0Enc, "", DAQmx_CI_CountEdges_InitialCnt, pSc->initialCount);
  // sample on the falling edge to allow direction signal to set up
  DAQmxCfgSampClkTiming (dthCounter0Enc, appendToDeviceName( strTemp, daqDevNameStrPCI6602, "PFI38" ), MAX_EXPECTED_CNT_SAMPLE_RATE, DAQmx_Val_Falling, DAQmx_Val_FiniteSamps, pSc->sampleCount );
  // Triggering the counter requires an "arm-start" style trigger.  The next 3 calls set it up
  DAQmxSetTrigAttribute ( dthCounter0Enc, DAQmx_ArmStartTrig_Type, DAQmx_Val_DigEdge );
  // PFI27 is the source input input to CTR 3 and is used as the trigger.  It is connected to the encoder index pulse
  DAQmxSetTrigAttribute ( dthCounter0Enc, DAQmx_DigEdge_ArmStartTrig_Src, appendToDeviceName( strTemp, daqDevNameStrPCI6602, "PFI27" ) );
   // trigger on the rising edge
  DAQmxSetTrigAttribute ( dthCounter0Enc, DAQmx_DigEdge_ArmStartTrig_Edge, DAQmx_Val_Rising );
  // start the encoder counter
  DAQmxStartTask(dthCounter0Enc);

Thanks,

Kirk

0 Kudos
Message 3 of 4
(4,159 Views)
Kirk,

Since it seems like you are trying to find out exactly when the acquisition has started you could poll the Available Samples Per Channel property of the DAQmx write function.  As soon as you see any samples being read you could determine when your acquisition has started.

You could also use registering for events and use the "Ever N Samples Acquired Into Buffer" and set off an event using that.

Unfortunately there is no direct counterpart of that function.  However the above workarounds should help.

Regards,
Raajit L
National Instruments
0 Kudos
Message 4 of 4
(4,118 Views)