Sign in to follow this  
Followers 0
Sajid

MicroLogic 1200 Float t Integer

6 posts in this topic

Hi, I am currently working on a ML1200 PLC.And as I understand it is a micro PLC, so I shouldn't expect it to match the Big PLCs with all those complex instructions and freedom to program. But my question is: If you have a float value in F8:0 say 27.6563 and want to seperate the Exponent from the mantessa (values to the right and left of the decimal point) then how would you do that without the final integer part getting rounded-off???? I have tried several methods like shifting the decimal point to the right by one place and then moving it to an integer N7.But with poor results. Since there is no TRUNCATE function in RSLogix 500, how can I get around with this?Or how do I implement one? Thanks for your suggestions and input.

Share this post


Link to post
Share on other sites
Rung 1 through 3 of THIS are the quickest thing I can think of, or well it is fresh on my mind since we were just looking at it a few days ago. Is there a certain precision you want to keep to the right or do you want to keep as much precision as possible? In fact looking a little closer at the example throw the first instruction of rung 5 in there and it looks like you have everything you need. Pretty much take all the string instructions out

Share this post


Link to post
Share on other sites
You can do with a few lines of logic move the float into a N register compare the n reg value with the original F reg If the N reg is less than the F reg use the N reg val (the N reg was not rounded up) If the N reg is greater than the F reg (the N reg was rounded up) subtract 1 from the N reg and use the result

Share this post


Link to post
Share on other sites
There is an example program of how to do this in the AB knowledgbase. http://domino.automation.rockwell.com/appl...F1?OpenDocument

Share this post


Link to post
Share on other sites
Thanks Micky and all others for your suggestions. Well, all I wanted was the un-truncated integer part.So I guess a subtracting 0.5 from the float value will do just fine. Mmmmmmm.................now I think there's more to floating point numbers than what I had previously thought. Thanks once again.

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