Gili Posted April 10, 2021 Report Share Posted April 10, 2021 what am I doing wrong? you can see that A>=B but the MB 10 is still 0. Is it possible that it because I'm comparing between MI to MF? and how to do casting if its the case. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted April 11, 2021 MVP 2022 Report Share Posted April 11, 2021 You can't compare an MF to an MI. I don't know why it let you enter that. You'll have to convert the MI to an MF register. Joe T. 1 Quote Link to comment Share on other sites More sharing options...
Gili Posted April 12, 2021 Author Report Share Posted April 12, 2021 thanks! and how am I converting the MI to an MF register? Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted April 13, 2021 MVP 2022 Report Share Posted April 13, 2021 I always tell people when they first start using PLC software to take the time to go through every menu and every sub-menu to get an idea of what's buried in there and where. It's useful where you run into a question like this you can say "I thought I saw something like that..." From ladder, look at Math -> Float -> Convert and you'll see the two blocks used for moving between floats and integers. Go into the Help and search for "float convert" and you'll see much better usage diagrams than I can go into here. What you're running into is how much of the pain in the butt it is to use floating point in a PLC. Everybody thinks they need it if there are decimals involved. You can get precision more elegantly with integers (especially longs) if you embrace the concept of a "virtual decimal point". Every number is 10, 100, 1000 times larger to accommodate the precision on the other side of the decimal and you just keep track of it. It's an easier technique you pick up with experience. Joe T. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.