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: 

Building a Sin wave without Express/Signal Processing Pallete

Solved!
Go to solution

EDIT:Forgot to attach the VI. I'll do that when I get home in 45 mins 

Hey Guys,

I'm working on a lab project that is driving me insane. We're constructing a VI that builds a Sin but we're not allowed to use the Express Pallette, or SineWave Functions. So we're stuck using arrays and the Sin function. I've attached the VI if anyone can take a look at it. I would try to explain where it's going wrong but... it's everywhere so... One thing i recently broke is that the 'dynamic' wave no longer scrolls at 10Hz but I think thats an easy fix. Hopefully someone can give me some pointers on what's going wrong.

Also, I've attached a copy of the explicit assingment details in case you'd liek to see them.

Display two sine waves on a single graph. Generate the sine waves in a While Loop that updates
at 10 Hz. With each iteration, the second wave should incrementally phase shift by a specified
amount (degrees).
Have controls for frequency, displayed number of periods, displayed points, phase shift, and
offset between displayed waveforms. Make sure the time-axis shows the correct units. All
controls should be active and adjustable while the program is running.
Hint: You may find it helpful to use a Waveform Graph and the Build Waveform function.
Do not use the Express Pallet VIs for signal analysis and signal manipulation. Instead use arrays
and build arrays VIs. 

  

0 Kudos
Message 1 of 12
(3,583 Views)

OKay, sorry. This is the current iteration of the VI that i'm currently working on.

0 Kudos
Message 2 of 12
(3,566 Views)

Please do a Save for Previous version and save it back to LabVIEW 15 or older.  Not everyone has LV 16 yeet.

0 Kudos
Message 3 of 12
(3,547 Views)

Without looking at your code (Still stuck with LV12) ...

The hint for the wfrm data format guides to a nice solution:

The waveform is a cluster like construction with a t0, dt and data Y array.

you know the number of points (n)  to display , the frequency and the number of periodes , with these informations you can calculate the dt value .

With n for a loop and dt you can calculate the two sine function values,  Ah how about the phase?? 

A shift register is needed to store the old value of the scond phase for the next interation 🙂

 

Extra Kudos (Bonus points) for :

- Recalculation of the first sine only if needed...

- Instead of storing the phaseshift and reclaculate the sine .. can you create a filter that does the phase shift?

 (a simple recalculation of the second sine is (usually) faster, but hey it's academic here 😉 )

 

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 4 of 12
(3,530 Views)

Sometimes it helps to solve a simpler problem first.  I must admit that the problem, as stated, puzzles me, as I'm not sure what is meant by "a While loop that updates at 10 Hz", that is, I'm not sure whether the problem involves updating a graph at 10 Hz or generating a sinusoid by getting a new point at 10 Hz, with the total length of the waveform (i.e. the duration of the signal on the graph) fixed at, say, 30 seconds.

 

So here's a simpler problem:

"Display 30 seconds of two 0.5Hz sinusoids, with the second having a 60° phase lag with respect to the first.  Plot them on the same graph, making the first sinusoid White, the second (lagged) one Red".

 

This has no controls or adjustments, so it is simpler.  Stated this way, it also makes sense to talk about "Displayed number of periods" (something I didn't understand from the Problem Statement) and "Displayed number of points".

 

Now the 10 Hz "While loop" can be interpreted as a "sampling rate" for a continuous 0.5Hz waveform.  As I've stated the problem (and thought about it), I'm generating the entire waveform "as fast as I can" and plotting it once.  Now, the "Aha!" moment -- suppose you generated the sampled Waveform at 10Hz, i.e. one new point 10 times a second, updating the Graph as the plot evolved.  Now you can think about putting controls to "play" with the phase "inside the loop", which is probably the intent of this interesting Lab Project Assignment.

 

Go to it!  Try it my way (do the simpler problem without controls, run the loop "as fast as you can", generate the entire waveform once, plot it to make sure you understand how to plot, then go back and add the "bells and whistles".

 

Bob Schor

 

0 Kudos
Message 5 of 12
(3,512 Views)

Sorry for taking so long to respond and Thanks for all the replys! I got home and pretty much shut all school out of my mind for the evening! 

I will do this as soon as I get to the lab this afternoon

0 Kudos
Message 6 of 12
(3,494 Views)

Sorry for taking so long to respond and Thanks for all the replys! I got home and pretty much shut all school out of my mind for the evening! 

I will do this as soon as I get to the lab this afternoon

0 Kudos
Message 7 of 12
(3,493 Views)

Hi! Thanks for your reply! So, I cant put the VI compatible with older versions up until later this afternoon which you'll probably be in bed by! BUT, i think i've mostly done as you've stated. Only, I used a for loop to generate the points, then update the sin wave and threw all those into the Y data value, not the dt value. So thats not correct? Y is stricly for data points?

0 Kudos
Message 8 of 12
(3,490 Views)

Thanks for the reply! I will give this a go!

0 Kudos
Message 9 of 12
(3,489 Views)

Hey everyone, terribly sorry for the delay. I was finally able to get to my labview stuff. Here is the back compatible Vi if you'd like to take a look. I've also atatched a figure of what the final product is supposed to look like at 100Hz,3 Periods, 100 Data points, 10 degree Phase.

So, in the current iteration of the VI, you'll notice that it's not generating the correct number of periods. I know that I should be thinking of this as x~periods in y~ data points. So it should be datapoints divided by periods I beleive. I'm still working on this at the moment but if anyone can see some glaring issues please let me know!

Download All
0 Kudos
Message 10 of 12
(3,474 Views)