01-24-2012 01:48 PM
I am trying to use sine and cosine in a Labview program. It seems to be working for the most part with one major execption which is when I give the Sine and Cosine VIs (the indivual ones the one with both) an angle of PI (PI/2, PI, 3PI/2, 2PI, 5PI/2, etc..) When I do this, the value that should go to 0 instead goes to some number either greater than 1 or less than -1. However, when I'm 1 degree off, the values are correct as they should be. My code is not complex at all.
Here is an example of an angle of 540 (3*PI) where Cosine should be -1 and Sine be 0. Notice that Cosine is correct but Sine is not 0:
Here is the same example but 1 degree less:
same example but with 1 degree more than 3*PI:
Here is the code I am using:
Is there a way to correct this or is there a better way I should be doing this?
Solved! Go to Solution.
01-24-2012 02:04 PM
Try making your numeric indicators wider, or change the numeric formatting to show less resolution. Somewhere off to the right of the numeric value should be a large negative exponent, such that the value is actually very, very close to 0. You're not the first person to see this: http://forums.ni.com/t5/LabVIEW/Sine-and-Cosine-calculations/m-p/130502
01-24-2012 02:09 PM
Thanks! That was it. Must have missed that article.