LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control the number of cycles?

Solved!
Go to solution

 

I am a new user and I would like to ask a question. I am using this VI (which is attached) and I would like to control the number of cycles of the generated wave (sine, sawtooth, square, Triangle).

How can I modify the VI to do this task?

 

Best Regards

Fasial

0 Kudos
Message 1 of 7
(3,642 Views)

First start by renaming the vi!

(don't go modifying the shipping examples themselves- you may need them intact someday.  BETTER: write protect the example folder)

 

Second you have a control for Frequency (Hz) AKA Cycles per Second.  You also have control over Samples per second and number of samples.

 

Some quick math: Multiply sample rate by 1/Freq by desired cycles to get "number of samples to generate Xcycles at any freq

 

Since the example is multi channel the sample rate and the number of samples must be must be the same for all chanels so , all channels must have the same frequency as well.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 7
(3,618 Views)

You could also count zero crossings (assuming your signal crosses zero) or slope reversals and stop your loop when you have enough. (Okay, the last won't work with square waves, but he's got to have something to work on.)

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 3 of 7
(3,605 Views)

thanks, but I want the VI to stop after this number of samples.

 

For instance I would like to have 3 cycles at 5 Hz. If I did your simple math (sampling rate*1/Freq*wanted number of cycles = 1000 * 1/5 * 3 = 600).

First question where should I enter this 600 in my VI?

Second after the end of required cycles the VI will not stop. I want the VI to stop after the specified number of cycles, How can I do that?

 

Thaks again sir for your time and efforts

0 Kudos
Message 4 of 7
(3,421 Views)
Solution
Accepted by topic author FaisalF

Hi FaisalF,

 

It sounds like you are more interested in outputting a finite amount of data. There is an example VI shipped with LabVIEW that has this functionality called Voltage - Finite Output.vi. You will then just need to create an array that will hold your 600 samples for 3 cycles of a 5 Hz wave and input that array to the DAQmx Write function in that VI.

 

Noah | Applications Engineer | National Instruments
0 Kudos
Message 5 of 7
(3,369 Views)

Thank you very much sir

 

I would like to ask how can I know and control the minimum triggering voltage that can trigger the VI? for instance I am goign to have a small voltage signal (mV) from a TTL. Is it enough to trigger the VI?

 

The other thing When I run the VI and I dont send a triggering signal I face a timeout error.

 

Error -200560 occurred at DAQmx Wait Until Done.vi:3580001

Possible reason(s):

Wait Until Done did not indicate that the task was done within the specified timeout.

Increase the timeout, check the program, and make sure connections for external timing and triggering are in place.

Task Name: _unnamedTask<1>

 

How can I increase the time out ?

 

Many thanks again for all of your generous help

 

0 Kudos
Message 6 of 7
(3,188 Views)

@FaisalF wrote:

 

How can I increase the time out ?

 


Check the function, you have a Timeout input.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(3,153 Views)