LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

use a loop to calculate the rms voltage of a sine wave

i had to write a programme that displays one cycle of a sine wave with amplitude 1 I managed to do that i think, the problem am having is I have to use a loop to calculate the RMS VOLTAGE but I shouldn't use any built in functions such as square, triangle, saw-tooth etc

I have attached  part of my programme

0 Kudos
Message 1 of 3
(3,221 Views)
Just use the RMS VI and be done with it.
But if you insist on doing it the hard way, by definition you square each value, do an average of the squared values, and then take the square root of the mean. No loop is actually needed to do this.

GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(3,206 Views)

It sounds like this might be an exercise to teach you some things about LabVIEW.

 

- The stop condition >= 6 does not give you a complete cycle. The sine function requires the input to be in radians. For one complete cycle the final value needs to be two pi radians larger than Initial x.

 

- The use of Build Array inside a loop is generally not a good practice. Why? Because it causes frequent re-allocations of memory as the array grows. It will work OK with the small arrays you are using but learning to do it properly will help you avoid problems later. You can calculate the exact array size before the loop starts so you can use a for loop with autoindexing or Initialize Array, a shift register, and Replace Array Subset in either a for loop or a while loop.

 

- As crossrulz pointed out, you do not need a loop (unless you want to generate the X-array that way). All the numeric functions you need such as Sine and Square Root are polymorphic. That means they will work on arrays as well as scalars.

 

Lynn

0 Kudos
Message 3 of 3
(3,185 Views)