Showing results for 
Search instead for 
Did you mean: 

Storing a pulse train in an array



I am trying to write a program that

1. Makes a configurable pulse train (High time period, low time period, and duty cycle are to be controlled).

2. Stores the train in an array.

3. Upon receiveing the command, sends the signal through DAQ to an output pin.


I am trying to use the pulse pattern vi and the square wave vi to generate the pulses, but as far as I can understand, the time period of the signals are not configurable. 


Is there a way to place the vi in a loop, then concatenate them, so the pulses are placed end to end, then store them in an array for later use?



0 Kudos
Message 1 of 6



There are a few ways you could go about this depending on your setup, so the following information would be useful to know:


  • What hardware are you intending to use?
  • Are you looking to output this pulse train on a digital or analogue output?

The resulting time period of the signals is usually a combination of the output sampling rate and the generated pattern. If for example you generate 100 samples which contain one square wave cycle at 50% duty (50 low, 50 high) and output this at a 100 Hz, your resulting waveform will be a 1 Hz square wave (1 second period).


All the best,

0 Kudos
Message 2 of 6

I am using a DAQmx with ni PXIE 6368.

The output port will be digital.


For the example you quoted, what samples are you generating? Are you using a file containing 1's and 0's, or the pulse pattern generator, etc? 

Personally, I would like to use a file containing 1s and 0s which would be read by the DAQmx and sent out to the port?

I am attaching my code here, but it is showing an error (something to do with buffer size). What exactly is wrong here?



0 Kudos
Message 3 of 6



The example I referred to was just a generic case of generating a bank of samples and then outputting them at a given sampling rate. I was just aiming to clarify how the resulting time period of the waveform is governed by output sampling rate.


You're reading your file on every iteration of the while loop. No need to do this, read it once before the while loop and pass the data in via a tunnel. As for the buffer size error, you'll need to provide a bit more information, i.e. code/message.

0 Kudos
Message 4 of 6

The program is showing error 200609.

The idea is, the program reads in 5000 values of 1s and 0s, outputs them at 1kHz, making the pulse train, and then the while loop repeats again.

I should be able to change the duty cycle, etc of the pulse trains by changing the value in the DAQ assistant. The measurement file reads in 5000 samples, and the output is also 5000 samples. Yet the error says that the buffer size is too small. What buffer size is it talking about?



0 Kudos
Message 5 of 6



The buffer size for a finite generation refers to the finite number of samples specified. Are you sure the number of samples being provided to the DAQ Assistant is equal to 5000 all on one channel/line? I've attached a modified version of your VI which doesn't use the file but provides a 5000 element boolean array. This runs with a simulated 6368 just fine, give it a go and see what the result is.


I'm not sure how you intend to change the duty cycle by any value in the DAQ Assistant. The duty cycle will be fixed by the pattern you have generated, all that will change is the frequency depending on the output rate.

0 Kudos
Message 6 of 6