Jump to content

Recommended Posts

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

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

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

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

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

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...