Our online shopping is experiencing intermittent service disruptions.

Support teams are actively working on the resolution.

FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine and Cosine Not Right in LabView

Solved!
Go to solution

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:

Front Panel 1.PNG

Here is the same example but 1 degree less:

Front Panel 3.PNG

same example but with 1 degree more than 3*PI:

Front Panel 2.PNG

Here is the code I am using:

Block diagram.PNG

Is there a way to correct this or is there a better way I should be doing this?

0 Kudos
Message 1 of 3
(5,956 Views)
Solution
Accepted by topic author william_edds

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

0 Kudos
Message 2 of 3
(3,661 Views)

Thanks! That was it. Must have missed that article.

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