From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get next samples of sampling window

Hello,

I am new to LabVIEW. I am generating Sine Wave with 12 samples/cycle. When I run VI I got 12 Samples [1 to 12]. Using for loop I want next sample window [2 to 13] and further, I want the sample window as [3 to 14] and as soon.

Download All
0 Kudos
Message 1 of 3
(2,406 Views)

you can use Phase input

 

sine.png

Message 2 of 3
(2,402 Views)

it is always a Good Idea to understand What it is you want to do, as this frequently informs How you do it.  Let me summarize what I think you want to do:

  • Generate a 12-point sinusoid.  You don't specify (in your post) the amplitude, phase, or frequency of the sinusoid, only the length (12) of its period.
  • Plot this 12-point sinusoid.
  • Keep generating points one-at-a-time, somehow "add it" to the sinusoid, and plot the most recent 12 points.

LabVIEW provides a series of Hammers, big blunt Virtual Instruments to Encourage Doing rather than Thinking, called Express VIs, and also provides an equally Evil output often associated with these Express VIs called a Dynamic Data Wire.  Your code employs both, so is unlikely to easily accomplish the task I outlined above (which, I should note, might not be what you really want to do, but it is what I understood that you wanted to do).

 

One thing that distinguishes LabVIEW from other programming environments is that it embodies the concept of Time as a primitive, so you can make your code run at a specific speed, allowing you to create a Virtual Instrument, something (in software) that behaves as hardware.

 

So let's return to the sinusoid.  How do you define a sinusoid?  Y(t) = a + b sin (2 pi f t + Phase) is one possibility.  [Note -- some would say "- Phase"].  In the Digital world, where we deal in Samples (i), we might write Y(i) = a + b sin (2 pi i / N + Phase) and know we need to output Y(i) at an interval of T/N (where T is 1/f, the period of the Sinusoid, and N, 12 in your example, is the number of points in the sinusoid).

 

So can you write a loop that has the following properties:

  1. Each time it runs, it computes a + b sin (2 pi i / N + Phase)?
  2. Can you make this loop run with a period of T/N?
  3. Can you show each point as it is generated, along with (some? all?) of the previous points?  [There is a specific LabVIEW Indicator made expressly for this purpose.  If you don't know which it is, look at the Front Panel Palettes and read the appropriate sections of the LabVIEW Tutorials to learn more].

This almost solves your problem.  One thing that will be missing is limiting the display to the last 12 points, but once you get things going, this should be an easy "tweak" to implement (Famous Last Words!).

 

If you learn to do it "the hard way" (as I'm advocating), you will learn LabVIEW and will have a much better appreciation of what is possible and how to do it.

 

Bob Schor

0 Kudos
Message 3 of 3
(2,354 Views)