Marko984 Posted November 18, 2017 Report Share Posted November 18, 2017 Hi This is my second project, and I have a question. I'm using V430-J-34 (provided by user...) Whats the best way to round up or round down decimal numbers to whole numbers? Currently I'm using simple linealization to convert result of some math to some normal number. Problem is there is whole excel table of math to do, that I am currently working on to be in plc example: Fx=IF(AND(C6>=130;C6<220);C6-20;IF(AND(C6>=220;C6<310);(C6-40)/3+G6;IF(AND(C6>=310;C6<400);(C6-40)/4+G6;IF(AND(C6>=400;C6<490);(C6-40)/5+G6;IF(AND(C6>=490;C6<=600);(C6-40)/6+G6;))))) C6 is input user makes (before in excel table, now it will be on display); G6 is just some result from previous math So for every "IF" I write conditions, then math formula. Then linearization. Then I can use that for information to compare whit encoder input to stop the motor and do some action (drill, cut, pierce...) And I still have not connected and configured encoder, but that will be question for another post if I don't figure it out.. Sorry for any mistakes, English is not my main. Best regards; Marko Link to comment Share on other sites More sharing options...
sgull Posted November 18, 2017 Report Share Posted November 18, 2017 Hi Marko Normally the decimal portion is the result of a divide function. You probably do all of your math with MI whole numbers and then divide to get the decimal portion. when you divide an MI the portion after the decimal point gets stored into SL4. You can then use a simple compare to determine if this value is big enough to be rounded up or not. You must use SL4 directly after each math function as it will be updated with each divide function. Hope this helps. Regards Denis Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted November 19, 2017 MVP 2023 Report Share Posted November 19, 2017 Can you give us an example of the decimal value you want to round? Joe T. Link to comment Share on other sites More sharing options...
Marko984 Posted November 20, 2017 Author Report Share Posted November 20, 2017 Thank you for your response. Sgull, you are right. I am using MI whole numbers. And all for decimals are result of simple divide. Joe T., Simplest example that I have is ( A - 14.1 ) / 7.2. . A is MI input from user. Result is number of pieces machine needs to make (also MI). If result is for example between 3.5 and 4.4, result should be corrected to 4 pieces. Different example is ( A - 40 ) / 3 + B ; A is MI input from user, B is result from previous math (also MI), result is place where tool should pierce the material. This will be compared whit input from encoder. Needs to be precise to about 1/10 mm. I don't know should I even try to round it up. Best Regards: Marko Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted November 21, 2017 MVP 2023 Report Share Posted November 21, 2017 I just wanted to know if there were a lot of decimal places to worry about. On 11/18/2017 at 11:02 AM, sgull said: You must use SL4 directly after each math function as it will be updated with each divide function. Example attached. Joe T. Rounding example.vlp 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