Sign in to follow this  
Followers 0
professor_jonny

absolute value calc in floating point

5 posts in this topic

Im trying to work out the volume of a sphere filled with water and i have come up with the following equasion how do i proform an absolute value calc in floating point ? absolute basically means take the sign of the number but im not aware of a function to proform this with in the plc. IF h<=_R Vol = Vol_h – pi * ( _R².ABS(_R-h) – 1/3.ABS(_R-h)³) IF h>_R Vol = Vol_h + pi * ( _R².ABS(_R-h) – 1/3.ABS(_R-h)³)

Share this post


Link to post
Share on other sites
Maybe I missed something, but it seems like all you need to do is the (_R-h) calculation (which you'll need to do anyway) and if it is < zero then subtract it from zero

Share this post


Link to post
Share on other sites
What PLC? If a CJ2 you could do it in a structured text routine. If a CJ or CP then you could do it in an FB with ST.

Share this post


Link to post
Share on other sites
Pretty sure the PLCs have an ABS instruction.

Share this post


Link to post
Share on other sites
Don't see why the method should be different from integers. If it is negative, subtract it from zero. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0