elektrik85 Posted July 22, 2015 Report Share Posted July 22, 2015 Hello Everyone, I am fairly new to Visilogic. I am trying to do a simple math calculation but need to use decimal places to make it work. My first calculation is to divide 547/847 which is 0.649. The answer it gives me is 0. How do I use the number after the decimal place? I am stuck and have not been to figure it out. The final outcome of the calculation is a pressure reading. Any help would be appreciated. Thank you. I am using a V570. Link to comment Share on other sites More sharing options...

Alexander Posted July 22, 2015 Report Share Posted July 22, 2015 All math functions with whole numbers (MI, ML, DW's) can not perform true decimal point values. It is possible to convert the values to memory floats (MF's) although there may be some rounding errors over time. Please know that the format of the MF's cannot be changed and are often displayed in scientific format. This is common to all devices that use floating point math. Link to comment Share on other sites More sharing options...

Henny Posted July 22, 2015 Report Share Posted July 22, 2015 Hello How about using a formula in combination with a divide operation? It lets you enter two MI,s and for the Result a MF that you can use. Don,t know what the result is because I did not try it with a controller so it can be that the result is still 0. Kind regards Henny Link to comment Share on other sites More sharing options...

Alexander Posted July 22, 2015 Report Share Posted July 22, 2015 Yes, using a formula function block should also allow the result to be in MF format. Link to comment Share on other sites More sharing options...

Walkerok Posted July 22, 2015 Report Share Posted July 22, 2015 If you need to a small amount of math then using floats will work great. If you need to do a large number of calculations and you can accept a fixed decimal point amount in your calculation then the old school method for using integers on math calculation will work fine. In your example of 547/847 integer math is not capable of keeping decimals (by definition an integer has no decimal) so if you instead perform the operation of (547*1000)/847 the result is 645.8. With integer math the answer will always come back as 648. This would represent the decimal .648 on a screen. When multiplying this way you will want to use ML (longs) and not MIs but you have a lot of them available. You can always use floats but you only have a total of 64 of them available in any of the enhanced vision products (and they can go quickly). You have 512 longs and with the longs you have plenty of digits possible to not overrun the maximum size like and MI will when doing multiplication. As with all things there are multiple ways and choices on how to get things done. Keith Link to comment Share on other sites More sharing options...

elektrik85 Posted July 23, 2015 Author Report Share Posted July 23, 2015 Hello Everyone, Thank you for all the useful information. What I did was convert my 547 MI into a MF. From there I just used MF math functions to continue my calculation. I was able to get it working. I am requesting information from a Fireye boiler controller via Modbus RTU and I needed the calculation to display the boiler pressure. Thanks for all the feedback. Link to comment Share on other sites More sharing options...

Walkerok Posted July 25, 2015 Report Share Posted July 25, 2015 I am glad you have a solution but you should have been able to save yourself this step. The fireye boiler controller should have an address that is the scaled value of the pressure already calculated. I am curious (if you dont mind) what model of Fireye controler are you using? Keith 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 account## Sign in

Already have an account? Sign in here.

Sign In Now