ponchpmorelos Posted July 6, 2012 Report Share Posted July 6, 2012 Good Day everyone I need to use float point in arithmetic operations storing and then store them in MI's. Is there any way to do this? Here is a screen shot of my program , where i Divide 132/1270 and the result is 0. I also Attached my program Encoder y Display 6 de julio.U90 Link to comment Share on other sites More sharing options...
AlexUT Posted July 8, 2012 Report Share Posted July 8, 2012 Hi, You will eliminate to use Float Point at all. Use Linearization Function (see Help for details). When X is Input, and Y is Output, linearization formula is: Y=((Ymax-Ymin)/(Xmax-Xmin))*(X-Xmin)+Ymin. When You replace Ymin and Xmin by 0, formula looks much more simple: Y=(Ymax/Xmax)*X For your case: Ymax=1050, Xmax=1270, X=132, Y=109. If you need 1 digit after decimal point - use 10 multiplier for Ymax. When Ymax=10500, Y=1091. Then display Y with 1 decimal digit. Believe this fit your needs. BR. Link to comment Share on other sites More sharing options...
Walkerok Posted July 9, 2012 Report Share Posted July 9, 2012 I attempted to attach a program file and was not able to do so....not sure what that was about. But one note of caution. Since there is no floating ability in the M90/91 you lose the remainder entirely regardles os wheather or not the remainer was a 1 or a 9. For example with one decimal in your specific example you will get 109.0 even though the actual answer should be 109.1. if you go out two decimals instead on one you will get 109.09. If you did this calculation floating then you would get a more accurate number of 109.13. The question is how accurate do you need to be? If you must show the more accurate answer of 109.1 then you are going to have to capture the remainder and do a comparison to decide if you want to round up or down on any calculation made. If you need the even more accurate 109.133 type number then you will most likely have to change PLCs from what you are using to a model that has flaoting point ability (the V120 or V130 are the lowest cost models with float ability). Also the linearization function only works using signed MI type locations so the maximum number you can have is 32767. So be careful trying to multiply by larger and larger numbers to get more decimal locations because you will end up with a number that is larger than 32767 and the linearization block will no longer work. If you must work with number larger than 32767 then there is a special SB82 bit that will allow you to combine 2 integers (called the long integer in the description for SB82). The use of SB82 has several special requirements so look in the forums and examples to get it correct if you decide you must use it. Keith Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted July 10, 2012 MVP 2023 Report Share Posted July 10, 2012 Or you could just start over with a V130 and use floating points. The Jazz/M90 Wall strikes again. The amount of time spent trying to use a pliers where you need a socket wrench can really add up. Joe T. Link to comment Share on other sites More sharing options...
MVP 2014 Simon Posted July 10, 2012 MVP 2014 Report Share Posted July 10, 2012 SI4 automatically catches the divide remainder. I have certinaly hit this wall also. Trying to hold the middle ground between overflow on large numbers and rounding errors on small numbers can be a real juggle. If you just need to file a new edge onto your pliers to use them as a socket wrench then it's not so bad, if all you have is pliers. If you find you are melting down the pliers to cast them in to the shape of a socket wrench then it has probably gone too far... Link to comment Share on other sites More sharing options...
Cara Bereck Levy Posted July 10, 2012 Report Share Posted July 10, 2012 Keith, you should be able to upload a program--please try again, and pm me if you have problems. There was a recent update of the forum platform and some resultant weird stuff happened... >If you find you are melting down the pliers to cast them in to the shape of a socket wrench then it has probably gone too far...< At that point, apply sledgehammer... Although I find some of the workarounds people come up with to be amazing. 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 accountSign in
Already have an account? Sign in here.
Sign In Now