LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to count the number of signals has been passed

Dear Sir,

       I am developing an application to send a defined number of square waveform to DAQMx card.  If the number reaches the given value, the generator stops sending, the application will do something else.

For example the attached code will generate a square wave has freq=1 and dutycycle=50%.  If I want to send 3 waveforms to daqmx,  in principle I can stop the loop after 3 sec.  I was trying to use Elapsed time function to count time elapsed, for low freq, it sort of worked, but didn’t work at high freq.  I think it should  have easy way to handle it. I would very appreciate somebody can tell me.

 

Thanks.

 

Guang

 

0 Kudos
Message 1 of 3
(2,837 Views)

Hi Guang,

In your example code, why are you setting the sampling rate to 20000 and the number of samples to be generated to 5000?


If you want 1 complete period of the square wave to correspond to one cycle of the loop, then the number of samples generated needs to be equal to sampling rate when the frequency is 1 hertz (as in your code).


Basically, 1 hertz = 1 cycle / second.  So if the signal is being generated at 1 cycle (period) per second, and you wish to generate exactly 1 period per loop, the number of samples generated needs to be equal to the number of samples generated per second, such that samples are only generated for one second.

Does that answer your question?

Eric V
National Instruments
Applications Engineer
Certified LabVIEW Associate Developer


"I'm a Ramblin' Wreck from Georgia Tech and a helluva (NI Applications) Engineer!"
0 Kudos
Message 2 of 3
(2,820 Views)
Hi,
 
    Thanks for your response. Actually my waveform in real application is composed of 4 square waveforms. I forgot to change the sample information before I posted this simplied sample.
 
    My waveform has 8 controls, P1, P2, P3, P4 and D1, D2, D3, D4(P is time width of high and D is the width of  low (0V).
The frequency of the composed wavefor is 1/(P1+P2+P3+P4+D1+D2+D3+D4). I have set the sampl number = Sample-Rate*Frequency.  One signal should should include a compete waveform. I kind of figured out how to do it. In the loop,
 
   I figured out how it works, as you said the number of loop is the number of waveforms.
 
    Thanks.
 
   Guang
  
0 Kudos
Message 3 of 3
(2,809 Views)