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? Quote 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. Quote Link to comment Share on other sites More sharing options...

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Note:Your post will require moderator approval before it will be visible.