topic Re: VI to plot sine waveform on a chart giving wrong plot in LabVIEW
https://forums.ni.com/t5/LabVIEW/VI-to-plot-sine-waveform-on-a-chart-giving-wrong-plot/m-p/2375726#M738834
<BLOCKQUOTE><HR /><LI-USER uid="256760"></LI-USER> wrote:<BR />
<P><SPAN style="line-height: 15px;">I have converted all the values to radians and used while loop as per the question.</SPAN></P>
<HR /></BLOCKQUOTE>
<P><SPAN style="line-height: 15px;">(This part is not related to LabVIEW)</SPAN></P>
<P><SPAN style="line-height: 15px;"> </SPAN></P>
<P><SPAN style="line-height: 15px;">First, it doesn't make sense to convert 't' into radians. Think of the units: A sine wave is represented by </SPAN><EM>sin(</EM><SPAN style="line-height: 15px;"><EM>ωt+</EM><EM>θ)</EM>, where ω is [rad/s], t is [s], and θ is [rad]. So, when multiplying, ω*t is [rad/s * s] = [rad].</SPAN></P>
<P><SPAN><SPAN> </SPAN></SPAN></P>
<P><SPAN><SPAN>In your code, however, <EM>w*t</EM> is [rad/s * rad] = [rad<SUP>2</SUP>/s] -- wrong units.</SPAN></SPAN></P>
<P> </P>
<P>Secondly, remember that in a computer, you're dealing with discrete (sampled) waveforms. Ask yourself:</P>
<OL>
<LI>What is your sampling frequency? How many samples are there in 1 second?</LI>
<LI><SPAN style="line-height: 15px;">What is your sampling period? How many seconds are in between 2 consecutive samples?</SPAN></LI>
<LI><SPAN style="line-height: 15px;">How many samples are there in 1 sine period?</SPAN></LI>
</OL>
<P><SPAN style="line-height: 15px;">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.</SPAN></P>
<BLOCKQUOTE><HR /><LI-USER uid="256760"></LI-USER> wrote:<BR />
<P> </P>
<P>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?</P>
<HR /></BLOCKQUOTE>
<P>(This part is related to LabVIEW)</P>
<P><SPAN style="line-height: 15px;"> </SPAN></P>
<P><SPAN style="line-height: 15px;">Right-click the chart -> Properties -> Scales</SPAN></P>
<P> </P>
<P>If you set the "Multiplier" of the X-axis to your sampling period, the chart will convert the sample-number back to seconds</P>Thu, 04 Apr 2013 05:50:55 GMTJKSH2013-04-04T05:50:55ZVI to plot sine waveform on a chart giving wrong plot
https://forums.ni.com/t5/LabVIEW/VI-to-plot-sine-waveform-on-a-chart-giving-wrong-plot/m-p/2370526#M737817
<P>Hello everyone,</P>
<P> </P>
<P>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 <SPAN>attached</SPAN> 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.</P>
<P> </P>
<P>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?</P>
<P> </P>
<P>Please reply soon.<SPAN style="line-height: 15px;"> </SPAN></P>Sat, 30 Mar 2013 14:47:28 GMThttps://forums.ni.com/t5/LabVIEW/VI-to-plot-sine-waveform-on-a-chart-giving-wrong-plot/m-p/2370526#M737817Amitech2013-03-30T14:47:28ZRe: VI to plot sine waveform on a chart giving wrong plot
https://forums.ni.com/t5/LabVIEW/VI-to-plot-sine-waveform-on-a-chart-giving-wrong-plot/m-p/2375726#M738834
<BLOCKQUOTE><HR /><LI-USER uid="256760"></LI-USER> wrote:<BR />
<P><SPAN style="line-height: 15px;">I have converted all the values to radians and used while loop as per the question.</SPAN></P>
<HR /></BLOCKQUOTE>
<P><SPAN style="line-height: 15px;">(This part is not related to LabVIEW)</SPAN></P>
<P><SPAN style="line-height: 15px;"> </SPAN></P>
<P><SPAN style="line-height: 15px;">First, it doesn't make sense to convert 't' into radians. Think of the units: A sine wave is represented by </SPAN><EM>sin(</EM><SPAN style="line-height: 15px;"><EM>ωt+</EM><EM>θ)</EM>, where ω is [rad/s], t is [s], and θ is [rad]. So, when multiplying, ω*t is [rad/s * s] = [rad].</SPAN></P>
<P><SPAN><SPAN> </SPAN></SPAN></P>
<P><SPAN><SPAN>In your code, however, <EM>w*t</EM> is [rad/s * rad] = [rad<SUP>2</SUP>/s] -- wrong units.</SPAN></SPAN></P>
<P> </P>
<P>Secondly, remember that in a computer, you're dealing with discrete (sampled) waveforms. Ask yourself:</P>
<OL>
<LI>What is your sampling frequency? How many samples are there in 1 second?</LI>
<LI><SPAN style="line-height: 15px;">What is your sampling period? How many seconds are in between 2 consecutive samples?</SPAN></LI>
<LI><SPAN style="line-height: 15px;">How many samples are there in 1 sine period?</SPAN></LI>
</OL>
<P><SPAN style="line-height: 15px;">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.</SPAN></P>
<BLOCKQUOTE><HR /><LI-USER uid="256760"></LI-USER> wrote:<BR />
<P> </P>
<P>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?</P>
<HR /></BLOCKQUOTE>
<P>(This part is related to LabVIEW)</P>
<P><SPAN style="line-height: 15px;"> </SPAN></P>
<P><SPAN style="line-height: 15px;">Right-click the chart -> Properties -> Scales</SPAN></P>
<P> </P>
<P>If you set the "Multiplier" of the X-axis to your sampling period, the chart will convert the sample-number back to seconds</P>Thu, 04 Apr 2013 05:50:55 GMThttps://forums.ni.com/t5/LabVIEW/VI-to-plot-sine-waveform-on-a-chart-giving-wrong-plot/m-p/2375726#M738834JKSH2013-04-04T05:50:55Z