Jump to content

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...