Showing results for 
Search instead for 
Did you mean: 

multiple TTL finite pulse trains

Go to solution

Dear NI forum members,



We just got a NI PXIe-1073 Chassis with a NI PXIe-6361 switched in PXI1Slot2 and a shielded connector box BNC-2111. Aim is to generate three TTL pulse trains to control a laser, a sound and a shock via Matlab Application. I use the NI-DAQmx C API together with Matlab MEX to integrate the C code in Matlab.

I came up with the following code from the C examples to generate a finite time-based TTL pulse train:


float64 initialDelay;
float64 lowTime;
float64 highTime;
uInt64 periodsPerTrain;
float64 taskMaxTime = (lowTime+highTime)*periodsPerTrain + 2*initialDelay;

// Configure Pulse
DAQmxErrChk(DAQmxCreateTask("", &taskHandle));
DAQmxErrChk(DAQmxCreateCOPulseChanTime(taskHandle, "PXI1Slot2/ctr0", "", DAQmx_Val_Seconds, DAQmx_Val_Low, initialDelay, lowTime, highTime));

// Configure Pulse Train
DAQmxErrChk(DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_FiniteSamps, periodsPerTrain));

// Start Train

// Wait for execution
DAQmxErrChk(DAQmxWaitUntilTaskDone(taskHandle, taskMaxTime));

// Clean up


I am stuck with two problems:

1.) PXIe-6361 has 4 counter signals ctr0-3. With the above code, I can generate separate tasks for each TTL signal and evoke them consecutively with DAQmxStartTask. But in that case I guess the tasks are not synchronized. Can I use the forth clock signal to synchronize the other 3, so the tasks on each is triggered at the same time? What will be the right way to do that with the C API? The smallest discrete time step in the exapmle is 500ms. See the attached image to check how the TTL signals should look like.


2.) What is my physical connector on the BNC2111 to outsource those signals. 

/PXI1Slot2/ctr0 -> PFI12/P2.4

/PXI1Slot2/ctr1 -> PFI13/P1.0

but what about ctr2 and ctr3? how can I set the outsource physical connector? Is there a function to specify that?


Thank you in advance for any tips, suggestions and direction!





Screen Shot 2014-02-07 at 1.49.05 PM.png


0 Kudos
Message 1 of 5

Hello go9kata,


there is a function for digital triggereing you can insert it before starting the task


1. build in the trigger function into two counters

2. configure and start the two counters, they now waiting on a trigger

3. the third counter is the master, which generates the trigger, so the counter output will

be used as a start trigger for the other two counters.


 DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev1/PFI0",DAQmx_Val_Rising));


I hope this helps you, if not please let me know.

best regards
0 Kudos
Message 2 of 5
Accepted by topic author go9kata

Hello go9kata,


to your second question with the BNC 2111. You can route the signal from the counter to

the avialable PFI lines on the BNC 2111 connector block with the following syntax


DAQmxErrChk (DAQmxSetCOPulseTerm(taskHandle,"/Dev1/PFI0"));


I hope this helps you, if not please let me know.

best regards
0 Kudos
Message 3 of 5

Hi Duffy2007!


Thanks for your input. Those were the right functions to use. Just to check up one more thing with you. When using the master-slave signal situation and they both have different delays, it is crucial to set the master signal as the one with the shortest delay and re-calculate the slave delay acordingly. Here is an example

signalA -> delayA = 0.5; signalB -> delayB = 1.0;


set signalA as Master and signalB as Slave AND update delays =>

signalA_Master -> delayA = 0.5

signalB_Slave -> delayB = delayB - delayA;


 is that the right assumption?  

0 Kudos
Message 4 of 5

Hello go9kata,



the delay should begin with the start trigger

signalA -> delayA = 0.5;

signalB -> delayB = 1.0;

so you should see the delays you set.

best regards
0 Kudos
Message 5 of 5