Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I specify a delay generate a counter pulse?

Solved!
Go to solution

Hi all,

  I have a question about using the counter to generate the pulse train. I don't have how to program it but I try the test panel in the MAX and I see it generates the pulse train at some rate and with some pulse duration. I am thinking if it is possible to generate only one pulse with given pulse duration at sometimes after I start the task? I have a code to output an analog waveform, the waveform lasting for 35ms. I wonder if it is possible to syncronize the output of the analog waveform as well as the counter such that at 12.5ms after the waveform output started, I send that single pulse from the counter port out. I have no idea how to do that, I am thinking to use a delay but it is hard to precisely control the time to exact 12.5ms.

0 Kudos
Message 1 of 8
(6,962 Views)

@PKIM wrote:

Hi all,

  I have a question about using the counter to generate the pulse train. I don't have how to program it but I try the test panel in the MAX and I see it generates the pulse train at some rate and with some pulse duration. I am thinking if it is possible to generate only one pulse with given pulse duration at sometimes after I start the task? I have a code to output an analog waveform, the waveform lasting for 35ms. I wonder if it is possible to syncronize the output of the analog waveform as well as the counter such that at 12.5ms after the waveform output started, I send that single pulse from the counter port out. I have no idea how to do that, I am thinking to use a delay but it is hard to precisely control the time to exact 12.5ms.


I found an example in the CVI show how to generate a single digital pulse

 

        DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
        DAQmxErrChk (DAQmxCreateCOPulseChanTime(taskHandle,chan,"",DAQmx_Val_Seconds,idle,initialdelay,lowtime,hightime));
        DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
        DAQmxErrChk (DAQmxStartTask(taskHandle));

 

I have two questions. First of all, to create a pulse, does it mean we have low state for sometimes, then high state for some times and then low state again? So why there is only two time parameters (lowtime and hightime)? Is the minimum lowtime and hightime depending on the sampling rate of the card or depending on the OS? I am using 6711 card

 

I see that I can specify initial delay, does it mean the time delay after the task just start?

0 Kudos
Message 2 of 8
(6,953 Views)
Solution
Accepted by topic author PKIM

Well assuming DAQmx_Val_Low for the idle state, upon being triggered the counter will wait for the initial delay, then generate a pulse at the high time that you have requested.  Low time isn't actually used in this single pulse example.

 

From what you have described, you should add a start trigger to your counter output task (DAQmxCfgDigEdgeStartTrig) so you can configure the counter to trigger off of the analog output start trigger.  Set the initial delay on the counter to 12.5 ms.  Start the counter task before the analog output task.  You should get your pulse 12.5 ms after the AO task has been started.

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 8
(6,943 Views)

 


@John_P1 wrote:

Well assuming DAQmx_Val_Low for the idle state, upon being triggered the counter will wait for the initial delay, then generate a pulse at the high time that you have requested.  Low time isn't actually used in this single pulse example.

 

From what you have described, you should add a start trigger to your counter output task (DAQmxCfgDigEdgeStartTrig) so you can configure the counter to trigger off of the analog output start trigger.  Set the initial delay on the counter to 12.5 ms.  Start the counter task before the analog output task.  You should get your pulse 12.5 ms after the AO task has been started.

 

 

Best Regards,


Thanks John. That's sound like what I need. So does it mean if I specify DAQmx_Val_Low and delay for 12.5ms, once the task get triggered, it will wait for 12.5ms before the first TTL high will output and lasting for the hightime, then it becomes low state again, right?

0 Kudos
Message 4 of 8
(6,936 Views)

@PKIM wrote:

 

So does it mean if I specify DAQmx_Val_Low and delay for 12.5ms, once the task get triggered, it will wait for 12.5ms before the first TTL high will output and lasting for the hightime, then it becomes low state again, right?


That's right.

 

 

Best Regards,

John Passiak
0 Kudos
Message 5 of 8
(6,927 Views)

@John_P1 wrote:

@PKIM wrote:

 

So does it mean if I specify DAQmx_Val_Low and delay for 12.5ms, once the task get triggered, it will wait for 12.5ms before the first TTL high will output and lasting for the hightime, then it becomes low state again, right?


That's right.

 

 

Best Regards,


Sorry to bug again. Forget to ask the following question. Does the time specified by higtime, lowtime and initdelay depends on the system clock or what? Can I request it to use the clock from other card so to synchronize the counter pulse to other source?

0 Kudos
Message 6 of 8
(6,919 Views)

@PKIM wrote:

 Can I request it to use the clock from other card so to synchronize the counter pulse to other source?


Yes you can do that.  You need to set the counter's timebase source (DAQmxSetCOCtrTimebaseSrc) and rate (DAQmxSetCOCtrTimebaseRate).  If you don't specify, the device will use its own internal timebase.

 

 

Best Regards,

John Passiak
0 Kudos
Message 7 of 8
(6,908 Views)

@John_P1 wrote:

@PKIM wrote:

 Can I request it to use the clock from other card so to synchronize the counter pulse to other source?


Yes you can do that.  You need to set the counter's timebase source (DAQmxSetCOCtrTimebaseSrc) and rate (DAQmxSetCOCtrTimebaseRate).  If you don't specify, the device will use its own internal timebase.

 

 

Best Regards,


That's cool. Thanks a lot 🙂

0 Kudos
Message 8 of 8
(6,904 Views)