Showing results for 
Search instead for 
Did you mean: 

Configuring DAQmx to generate fixed cycles of Pulses.

Hello all,


I'm using NI 9472 to generate a Digital Pulse.


The expected pulse involves sequence of High and Low level which is to be repeated number of times(cycle). The number of Repetition or number of cycles of the sequence is fixed. I can generate the expected Digital Pulse by configuring DAQmx in either Continuos or Finite Sample Mode.


Continous Sampling Mode - In this mode i can pass the data of one cycle to DAQmx and it will continuosly generate the sequence repeatedly unless i stop it. My concern here is how will i keep the track of number of cycles been generated because i have to generate the sequence for a fixed number of cycles.


Finite Sampling Mode- In this mode i can the pass the whole data(required number of cycle of sequence) at once to the DAQmx so that it will generate the fixed number of cycles of the sequence and stop. My concern here is that the data which i'm passing to DAQmx is becoming very large since the whole pulse is of around 44 hours long. Can't i pass data of only once sequence to the DAQmx and configure it to repeat it for a fixed number of cycles?


Please suggest what should be the best timing mode in this case. I have tried my best to explain my question, if you are unable to understand any part of it please reply to this post.



0 Kudos
Message 1 of 5

I would be tempted to suggest that you use the Continuous Sampling (since your timespan is very large), and make use of the "Total Samples Per Channel Generated" property of the DAQmx Write class.


You can wire a property node with the "DAQmx Write" class and then find this under Status > Total Samples Per Channel Generated".

That might give you what you want?




GCentralI'm attending the GLA Summit!
0 Kudos
Message 2 of 5

Will "Total Samples Per Channel Generated" property of the DAQmx Write class truly give the total number of samples generated from the start of task even if the task is continuosly generating pulses for a very large time span?


The output of this Property can be compared with total number of pulses expected. And the moment it exceeds the the target number of pulses the task can be stopped. This sounds good but there are chances that the task will be stopped after some extra pulses are given ? Can we stop the task instantly once the target number of pulses are generated ?

0 Kudos
Message 3 of 5

If the number of samples that you write at once is sufficiently large, then you should be able to check and stop correctly (i.e. if you don't write more than expected).

However, the property node in my screenshot might not be the best choice - it looks like it depends on the number of samples that have actually been output.


With some more testing, I'd guess the "Current Write Position" might be a more useful property (so sorry for the bad suggestion). That value increments when you write the samples using DAQmx Write, not when they actually "come out" of the terminal, so if the chunk size is at least a few hundred milliseconds I'd guess (no promises) you'd be ok.


If the samples you're generating are multiple repetitions of the same values, you can use the Regeneration Mode (I think this defaults to Allowed/On on hardware that supports it) to avoid having to repeatedly call DAQmx Write, and instead just write once and keep reading the number of samples written.

If you do this, take care to avoid an unnecessarily greedy loop (i.e. no waiting, just checking the counter over and over, burning 100% CPU on one core...).


GCentralI'm attending the GLA Summit!
0 Kudos
Message 4 of 5

Yes, i have to generate multiple repetitions of the same value. Please refer below image to get more clearity on it



As can be seen above one cycle will involve around 23,530 sample value. I want to generate around 20,000 repetition of the same data. The total number of samples generated for 20,000 repetitions will be around 457,200,000.

My requirement is to stop the Task when all the samples corresponding to 20,000 repetitions are generated.

I'm not sure but if 457,200,000 sample values can be passed to the Write in one go by setting the DAQmx in Finite mode then my problem is solved. Otherwise as you said i have to configure in continuous Mode and allow Regeneration.


I cannot interpret how i can use Current Write position property because it points to buffer position. Can you please post an example of it for the current case?


Although trial needs to be taken but i feel TotalSamplePerChannelGenerated Property can give satisfactory Result. I have used this property in the image.


0 Kudos
Message 5 of 5