02-24-2017 01:48 AM
Dear all,
first, I am trying to create (simulate) sine function in time. For example, when I would start a VI, the function starts to change (sine wave). After that I would need a second function, that would be dependent on the first one, but with a certain lag. For example, when first function increases, the second one would follow the first one but with the certain time lag in between.
Any ideas? I tried using while loop and a sine function, but couldn get anywhere 😕
The VI is attached.
Thanks in advance.
z
02-24-2017 02:11 AM
Hi zigolin,
After that I would need a second function, that would be dependent on the first one, but with a certain lag.
"time lag" usually means "phase shift"…
Have you tried to calculate your 2nd sine wave with a phase shift?
In general it helps to write down the math ("formulas") before starting to code them. Can you supply the needed formulas?
02-24-2017 03:27 AM
Yes, sure.
f(x) = A*sin(2*pi*freq*t)
g(x) = A*sin(2*pi*freq*t + phi)
where phi is a phase shift, freq is frequency and t is time. In attached VI, I created a cosine wave, but I have a problem running it repeatedly, so I would get more periods on graph.
Thanks.
Z
02-24-2017 03:36 AM
02-24-2017 04:04 AM
Not just that. Actually the VI now calculates only on period, I would like the it would contniouslly calculate this periods (from 0-25) until I stopped it. The I would add another wave that will be phase shifted. I guess that I have wrongly determined while loop to do so?
Thanks Z
02-24-2017 04:20 AM - edited 02-24-2017 04:22 AM
Hi zigolin,
while I usually suggest to get rid of ExpressVIs this time they are really helpful to implement your problem:
(Both ExpressVIs are set to the same settings.)
Edit: I just learned you cannot change the phase while the VI is running, by default the ExpressVI does not use an updated phase value. You need to send a TRUE to "Reset signal" too…
02-24-2017 04:22 AM
Thanks for that! Any ideas how can I get this done using my VI?
02-24-2017 04:24 AM
02-24-2017 04:39 AM
Perhaps I have asked question wrong: I would need to make it that way, that when I start the VI, the sine wave would start draw on front panel (graph), so for example, after 5 second, there would be 3 periods on the graph I if I don't press stop, it would still draw new periods.
02-24-2017 04:44 AM