# LabVIEW

cancel
Showing results for
Did you mean:

## VI to plot sine waveform on a chart giving wrong plot

Hello everyone,

I am a beginner to LabVIEW. I have to make a VI to plot a cycle of sine waveform with amplitude=1V, f=50 Hz and phase=45(in degrees). I have made the attached VI. But this is giving wrong results. I have converted all the values to radians and used while loop as per the question. Please someone have a look at my VI and please tell what is the problem.

I also wish to ask:  In each iteration of the while loop, a value is passed to the waveform chart to plot corresponding to the value of t (time) which I have incremented in each iteration by a unit degree(converted to radians) upto 2*(pie) radians. Will the plot on the chart be corresponding to the values of t as per every iteration or the chart will follow the default way of plotting for t=zero and then incrementing by one. How can we control this thing?

Message 1 of 2
(1,026 Views)

## Re: VI to plot sine waveform on a chart giving wrong plot

@Amitech wrote:

I have converted all the values to radians and used while loop as per the question.

(This part is not related to LabVIEW)

First, it doesn't make sense to convert 't' into radians. Think of the units: A sine wave is represented by sin(ωt+θ), where ω is [rad/s], t is [s], and θ is [rad]. So, when multiplying, ω*t is [rad/s * s] = [rad].

Secondly, remember that in a computer, you're dealing with discrete (sampled) waveforms. Ask yourself:

1. What is your sampling frequency? How many samples are there in 1 second?
2. What is your sampling period? How many seconds are in between 2 consecutive samples?
3. How many samples are there in 1 sine period?

If you're not asked to use a specific sampling frequency, just pick one that's much greater than 50 Hz. (In your case, 1 kHz is a good sampling frequency) Then, answer the 3 questions above and see if it becomes clearer.

@Amitech wrote:

I also wish to ask:  In each iteration of the while loop, a value is passed to the waveform chart to plot corresponding to the value of t (time) which I have incremented in each iteration by a unit degree(converted to radians) upto 2*(pie) radians. Will the plot on the chart be corresponding to the values of t as per every iteration or the chart will follow the default way of plotting for t=zero and then incrementing by one. How can we control this thing?

(This part is related to LabVIEW)

Right-click the chart -> Properties -> Scales

If you set the "Multiplier" of the X-axis to your sampling period, the chart will convert the sample-number back to seconds

Message 2 of 2
(963 Views)