Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I synchronize the counters on two different computers in the C API?

Solved!
Go to solution

I have installed M Series cards (6254) in multiple computers. I would like to synchronize the counters for each card.  The best way I came up with to do this was to have the counter inputs on each counter read a common external clock signal running at 10 KHz. I would then feed a second signal into each card and trigger the task running each counter to start when the second line goes high. 

 

Following the examples that ship with the C API it was easy to get each card to read the KHz signal, then to synchronize the counter start I tried 

 

DAQmxCfgDigEdgeStartTrig(taskHandle,inputLineStr,DAQmx_Val_Rising);

 

However this didn't work and gave me the following error: 

 

DAQmx Error: Specified property is not supported by the device or is not applicable to the task.
Property: DAQmx_StartTrig_Type

Task Name: task

Status Code: -200452
End of program, press Enter key to quit

 I know it is very simple to synchronize cards within a computer using the RTSI interface but that isn't possible as my cards must reside in different computers.

 

Is it even possible to synchronize counters across computers, and if so how can I do it with the C API?

 

 

------------------

 

 

Here is what I've written so far:


#include <stdio.h> #include <NIDAQmx.h> #define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else int main(void) { int error=0; TaskHandle taskHandle=0; uInt32 data=0; char errBuff[2048]={'\0'}; DAQmxErrChk (DAQmxCreateTask("task",&taskHandle)); DAQmxErrChk(DAQmxCreateCICountEdgesChan(taskHandle,"/Dev1/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_CountUp)); DAQmxErrChk (DAQmxConnectTerms("/Dev1/10MhzRefClock", "/Dev1/PFI8", DAQmx_Val_DoNotInvertPolarity)); DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev1/PFI14",DAQmx_Val_Rising)); DAQmxErrChk (DAQmxStartTask(taskHandle)); printf("Continuously polling. Press Ctrl+C to interrupt\n"); while( 1 ) { DAQmxErrChk (DAQmxReadCounterScalarU32(taskHandle,10.0,&data,NULL)); printf("\rCount: %u",data); fflush(stdout); } Error: puts(""); if( DAQmxFailed(error) ) DAQmxGetExtendedErrorInfo(errBuff,2048); if( taskHandle!=0 ) { /*********************************************/ // DAQmx Stop Code /*********************************************/ DAQmxStopTask(taskHandle); DAQmxClearTask(taskHandle); } if( DAQmxFailed(error) ) printf("DAQmx Error: %s\n",errBuff); printf("End of program, press Enter key to quit\n"); getchar(); return 0; }

 

 

 

0 Kudos
Message 1 of 5
(3,535 Views)

As a LabVIEW guy, I don't know the correct syntax for the C API, but I think I know the problem.

 

Counter Input tasks don't use the "regular" DAQmx Start Trigger, they use an "Arm Start" Trigger.  I suspect you must be doing a measurement task rather than a pulse generation task.

 

It's been a while now since I first got caught by that and puzzled over it, but you remind me that I'm kinda curious why the distinction hasn't been abstracted away in the API.  I recall getting similar errors for any attempt to use a "regular" Start trigger on a CTR input task where I needed to use an "Arm Start" trigger instead.  I think I remember reading that output tasks allow the use of both types of triggers simultaneously, though I don't recall what the resulting behavior will be.  I think maybe it causes the start trigger signal to have no effect until *after* the arm start trigger edge has been received? 

 

Anyway, see what you can find about the C API syntax for configuring an "Arm Start" trigger for use on any CTR input tasks.

 

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 5
(3,524 Views)

Kevin,

 

Thanks for the information about the proper trigger name as you are completely correct. In the DAQ M Series User Manual it describes exactly what needs to be done on page 7-29 (135). However extensive searches in the example files and the help files that ship with the linux c api yield no clues as to the proper syntax to use.

 

I'm thinking that I might have to implement the trigger in hardware and not software. If this is the case then the solution is as simple as routing a signal to the counter's HW Arm input and then just passing the square wave to that channel.  Either by plugging a wire into the write PFI channel or connecting the Terminal with

 

DAQmxConnectTerms()

  But I can't find anything in the docs that tell me what that channel is called. The docs for my card (6254) say it has 9 lines (Src,Gate,Aux,ARM,A,B,Z,Out,TC)  (page 7-1), however it only specifies the default connections for 7 of those line (all but Arm and TC).  

 

 

I've tried various 

If anyone knows the hardware name of the Counter n HW Arm line or which PFI line it is connected to by default I'd be very appreciate if they could share that information.

 

 

hmm.... maybe I should put the card in a Windows box and see if I get can the terminal names from MAX....

0 Kudos
Message 3 of 5
(3,515 Views)
Solution
Accepted by topic author neurostu

Hi neurostu,

 

Arm start triggers are disabled by default, so they don't have a default PFI line.

 

You'll need to set a few DAQmx properties to configure an arm start trigger. Try adding this between DAQmxCreateCICountEdgesChan() and DAQmxStartTask():

 

DAQmxSetArmStartTrigType(taskHandle, DAQmx_Val_DigEdge);

DAQmxSetDigEdgeArmStartTrigSrc(taskHandle, "/Dev1/PFI14");

DAQmxSetDigEdgeArmStartTrigEdge(taskHandle, DAQmx_Val_Rising);

 

Do you have the "NI-DAQmx C Reference Help" file? It should contain descriptions of the Trigger >> More >> Arm Start properties.

 

Brad

DAQmxCreateCICountEdgesChan
---
Brad Keryan
NI R&D
Message 4 of 5
(3,498 Views)

thanks brad, this does exactly what I need it to.  

 

 

0 Kudos
Message 5 of 5
(3,485 Views)