Easychair Posted October 28, 2012 Report Share Posted October 28, 2012 I'm trying to accurately calculate the cosine of an integer to at least 4 decimal places. For example if I use 12000: When I use Excel with the formula =COS(12000) it returns 0.634112 When I key the values into my desktop calculator it returns 0.63411204 (must set Radian mode). In VisiLogic 9.3, I used the FP function COS and got 0.6338002. Using the Formula block with "1000 * (COS(12000))" (stored to an MI) returns 633. Can anyone share some insights? Has anyone developed a work-around? Link to comment Share on other sites More sharing options...

Damian Posted October 29, 2012 Report Share Posted October 29, 2012 Is it possible for you to normalize these values prior to the PLC operating on them? What I mean by that is 12000 radians is the same as 5.3992485942. (12000/(2PI) - INT(12000/(2PI))) * 2PI If you take the COS of 5.3992485942 in the Unitronics PLC you will get 0.6341115. Unfortunately I tried to normalize the value in the PLC first prior to putting in the COS function but the precision of the FLOAT operation required to do this are just as bad. If someone can figure out how to normalize your values in the PLC without loosing precision then you should be good. Link to comment Share on other sites More sharing options...

## Recommended Posts

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account## Sign in

Already have an account? Sign in here.

Sign In Now