Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous pulse generation with external synchronization in NIDAQmx

  Hi.
  If it isn't right place for my question,
then could you please point me to the proper one.

I have PCI 6602 board, NIDAQmx and ANSI C
I would like to generate pulse series for every external pulse.

Frequency of external signal varies about 5-100 Hz

Delay from external signal and length of pulses in pulse series
  are defined interactively and should be settable  smoothly without missing any external pulse

If I am right, continuous generation use only first external pulse to start, so
I’ve found out the only solution:

DAQmxCfgDigEdgeStartTrig(); // for my external signal
DAQmxCreateCOPulseChanTime() // delay and length for every pulse in series
...
DAQmxCreateCOPulseChanTime() // delay and length for every pulse in series
DAQmxStartTask();

Then continuous loop:

while(1) {
        if (DAQmxWaitUntilTaskDone()) {
                DAQmxStopTask();
                if ( there are any interactive changes) {
                     DAQmxCreateCOPulseChanTime() //  set new delay and length
                    ...
                
   DAQmxCreateCOPulseChanTime() //  set new delay and length
                }
                DAQmxStartTask();
        } 
        respond to User Interface
}

But it works without missing external pulses only with frequencies  <5Hz
Higher speed  of external signal cause missing  in series geteration.

Any suggestion is welcome.

 


Thanks
  Andrew

0 Kudos
Message 1 of 4
(3,952 Views)

Hi Andrew, thank you for using our discussion forums.  The reason you are not able to go faster than 5Hz without missing a trigger pulse is because you are stopping and starting the task, and there is a certain amount of time needed for these steps to occur.  Also there are only a limited set of properties that can be set while counter tasks are running and setting the initial delay is not among them.  Therefore it is not possible to vary the initial delay while the task is running.  Have a look at the following Knowledge Base article.  I realize that the final solution is coded in LabVIEW, but the description is in terms of counters and what is described can be replicated in ANSI C.  This solution is similar to what you are looking. 

 

Chris_K

 

 

0 Kudos
Message 2 of 4
(3,935 Views)
 Hi Chris_K,
   thank you for your reply.
Yes,  you're right : "
This solution is similar to what you are looking."

But how "Initial Delay" is implemented ?
I suppose it should be done by software, because in other case it needs one more counter.
May be
it loads the counter with delay for the  first start triger event, then it loads the counter with low and high times
to produce all next pulses without software intervention.
But it could cause loss of start event between first and second pulses.

Where am I wrong ?

Thanks,
    Andrew



0 Kudos
Message 3 of 4
(3,920 Views)

The example I pointed you to uses a retriggerable pulse task where the pulse cycle is specified by low time and high time. By setting the low time and high time independently you can have it gate your continuous pulse train via the pause trigger.  You can then change this high time and low time to create a variable delay, and length of pulse.  I think if you use your sample clock to trigger the single pulse you should be able to achieve your application.          

0 Kudos
Message 4 of 4
(3,897 Views)