Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted

04-22-2019 08:58 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Labels:

Hi everyone,

I'm building this Simulate signal VI to generate waveform within a dedicated period of time determined by Elapsed TIme express VI both in the same loop. So that I can control exactly the output signal period for further application.

For instance, the simulation *signal period is 6s* and *time elapsed* for the *while loop* to run is *3s*, therefore I should always obtain 1/2 period signal generated when the while loop terminated. But somehow, the Simulate signal express VI is *by chance* over generate extra 1 point that ruins the expected output signal.

Please help me to fix this,

Thank in advance.

Solved! Go to Solution.

Highlighted
Options

04-22-2019 04:03 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Don't do it that way! Get rid of the Elapsed Time Express VI, the Simulate Signal Express VI, learn about Waveforms and use the Waveform Generation VIs, and do a little arithmetic to generate precisely the points you want. It helps to understand what LabVIEW means by a Triangle Wave, to understand what Frequency and Phase mean with such a wave, and a few other things that I don't think you fully understand.

Bob Schor

Highlighted
Options

04-23-2019 07:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Great reply sir, thank you!

But can you give me a brief example of how it can be done?

I think Waveform Generation VI is not well explained and is not commonly used. Since the timing between loop iteration and the single signal point generation is also critical to my program, this indirectly determined by the *Sample per second (Hz)* in Simulate Signal Express VI.

Highlighted
Options

04-23-2019 08:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Well, you didn't describe __what__ you wanted to do very clearly. Have you looked at the Examples that ship with LabVIEW? There are a number of examples showing Waveform Generation (some using the Waveform Generation functions, not the Express VIs) and playing them through various output devices.

Suppose you want to generate a Triangle Wave and output it at 100 points/second. I'm assuming you'll specify the waveform so that you'll get the appropriate waveform -- in your example, your rising phase lasts 1.5 seconds, or 150 points, and your falling phase is another 150 points, and if this is supposed to be one __period__ of a triangle wave, then the Wave has a non-zero offset and a phase lag of 90°. Here is a Snippet (LabVIEW 2018) that generates one cycle of a 0.33 Hz (roughly 3-second period) Triangle Wave with a 90° phase lag at 100 Hz and for 300 points. I plotted it, setting the Plot to display Relative Time (so it starts from 0) and displaying the scale as seconds (with one decimal point)(right-click the Chart and set its Properties) -- I get a Triangle Wave from -1 to 1 (I leave it as an Exercise for the Reader to modify it so it goes from 0 to 10).

So how much time does it take to do this (not counting the plotting)? About 30 __micro__seconds, i.e. 300 times faster than it takes to generate a point "in real time" (= 10 milliseconds). So you could generate a waveform, play it out "slowly" (one point every 10 milliseconds), and when you are done, generate another 300 points, play it out, generate, play, etc. Or, if you are really worried about the time to generate the points, do the following:

- Generate the first set of points.
- In a loop,
- Display (300 times slower than the generation time) a point in the waveform.
- The
__first time__(or the last time, or even__every__time) through the loop, generate the__next__set of points.

Now when your loop finishes, you have the next set of samples ready to go, so you repeat with no delay (note that if you generate during the __last__ time through the loop, you just replace the (now empty) array of data with the newly-generated "next" part of the waveform). Incidentally, what you see here, a "vague" statement of when to generate the data in the algorithm above and a "better" way to do it in the preceding sentence, is an example of "thinking while designing", and getting the main points first and letting the details "suggest themselves to you".

Bob Schor

Highlighted
Options

Solution

Accepted by topic author VD89410A

04-23-2019 10:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thank you so much for your detail explanation,

My idea is that I need the loop to run simultaneously with the point generation process. Because some code needs also to proceed inside it at the time between iterations.

So I use the sampling rate to determine the loop iteration time, then together with the period (1/frequency) to control the spacing between points and the number of the cycle that I want to generate.

Highlighted
Options

04-23-2019 01:28 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Everything is fine except for your plot. You are updating once/second, presumably by sending values to a D/A converter. This is the output you will get:

The value is 0 for a second, then 1, then 2, then 1, then 0. Is this what you want? I suspect that it is not. If you are generating a signal __digitally__, you need to think about the update rate and how you go from one point to another.

Bob Schor

Highlighted
Options

04-23-2019 02:09 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Yes, that is exactly what I need, except the number of sample per generation is 1.

I'm controlling a thermal bath by sending this kind of signal to modify its temperature that following the triangle or sine wave. The update rate and the way it goes from one point to another should be even lower (longer) more or less.

Highlighted
Options

04-23-2019 04:14 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

You might have mentioned this earlier, but if so, I didn't notice it (I apologize). Here's a "thought experiment" to consider:

- You have a very sluggish device (a water bath, say) that you want to control (its temperature, say). So you decide to give it a different temperature every second, knowing it will be sluggish, and lag behind your desired temperature. You give two "up" temperatures, and then two "down", then two "up", then two "down", and so on. Let's say you change temperature every 5 seconds.
- Suppose it takes a minute to reach the desired temperature. In that minute, you've gone up and down three times! What do you expect will happen?
- When designing a Control System, you need to think a bit more about your problem before starting to code!

Bob Schor

Highlighted
Options

04-23-2019 04:38 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

No, you did an excellent point out!

That I need to use the for loop (controllable iteration) with waveform generator VI, which allows deeper modification. Especially, the *sample rate* is actually a VI input gate, therefore I can directly intervene to change the iteration time and value (step) different between two consecutive generation points.

In the case of high thermal inertia (like a thermal bath), I can just make the iteration time extra slow (a couple of minutes perhaps). Otherwise, if it's too fast then the lag behind the desired temperature will occur.