# change MF format in HMI

## Recommended Posts

good morning
someone knows how to change the format of an MF when displaying it in the HMI, in order to save space, since it shows as 5 digits after the comma, but I need that space

##### Share on other sites

• MVP 2023

Why are you using MF?

##### Share on other sites

because I am doing a conversion of the MI output of the linearization with a multiplication block in float because they are numbers like 0.36 to change units from InHG to BAR and the output is given to me in float.

##### Share on other sites

• MVP 2023

Use integers with an implied decimal, then you can display on the HMI to whatever precision is appropriate. There is almost never a good reason to use MF for internal calculations involving decimals.

##### Share on other sites

I do not understand how to use the implicit decimal number, when I made calculations with MI they did not let me do multiplication by number with comma and my problem is that the Bar only reaches a range of 0 to 1.5 bar, as it should, I see that when using an MI data is lost after the comma which I need to show as well

##### Share on other sites

• MVP 2023

But if you need enter something to displayed MF (ML on display)  - maybe some add input display needed.

You can also use ML to MF conversion for this input display.  And as result correct short display on main screen.

##### Share on other sites

• MVP 2023
22 hours ago, edgar.guerra said:

I do not understand how to use the implicit decimal number, when I made calculations with MI they did not let me do multiplication by number with comma

Do not use a decimal point (comma). Just keep track in your head of where the decimal should go then display it using the HMI numeric variable that allows you to select how many decimal places and inserts the comma for you.

For example, if you want to linearize your input from 0 to 1.5 bar, then linearize it to 0 to 15, remembering that you have implied one decimal place. Keep track of that through any subsequent calculations and you can multiply or divide by whatever power of ten gets you the precision you require.

If you want the pressure displayed to two decimal places then simply linearize from 0 to 150.

You really need to fully understand this in order to do PLC programming. PLCs work well with integers, but not so well with floats. You can easily avoid floats in nearly every situation if you understand this technique.

##### Share on other sites

• MVP 2023

This is a concept newer programmers frequently have trouble with so I'm diving into it.

I almost never use MF registers in PLC calculations because there aren't a lot of available functions that use them and, as you've determined, they're a royal pain to display in the format you want.  The only time I've used them is when calculations such as SIN and COS are needed because angles are involved.

Implied decimals are a "sleight-of-hand" programming method going back decades in PLC programming.  It requires that you really understand powers of 10 and keep track of them when you multiply and divide. ML registers are your friend here, as they can hold many more digits than MIs.  As Flex says, you as the programmer have to keep track of what the value is in terms of its exponent.

This is much easier if you have your PLC in front of you so you can watch the numbers in action.  It typically starts at the analog input itself - let's say you have a transducer that produces a 10V signal at 29.92 inHG, which is a count of 16384 on a universal analog input.  You would set up your linear block like this:

So the scaled output is the value x 10^-2.   The value is implied with two decimals, or  29.92.

The formula to get bars is inHg x 0.034 or 34 x 10^-3.  You have go back and remember your algebra here - when you multiply two numbers you add the exponents to get the answer.

So at full scale, your calculator would give 29.92 x 0.034 = 1.0173.   You're thinking the PLC is a calculator.  Stop thinking this way.  A typical PLC is stupid when it comes to math - you have to hold it's little hand and do everything from an integer point of view.

Let's do this in integer land and multiply 2992 x 34.  You're the one in charge and what you're really doing is 2992 x 10^-2  X  34 x 10^-3.  Adding the exponents because we're multiplying tells us the answer will be some number x 10^-5.

You'll see here why I used an ML in the output of the MUL block - it would overrun an MI.

The result is 101728 x 10^-5, or 1.01728.  Just like the calculator!  Wow!

If you want to reduce the digit count for display on the HMI or further calculations just divide by 1000:

You'll notice this type of calculation doesn't round - it just chops.  I prefer to round the value, so you need to use what's left as the remainder to make a decision.  Fortunately, Unitronics provides this value in SL 4:

So we do one last operation to fix the value, comparing the remainder to 1/2  (500 in this case) and deciding whether to "round up".  Net 3 becomes:

Or, 1.02 bar.  Easy to put on the HMI and use in other compare blocks.

Joe T.

• 1
##### Share on other sites

• MVP 2023

Beautifully done, Joe.

This comes naturally to us old codgers who learned how to use a slide rule. It's tougher for folks who know only calculators.

##### Share on other sites

I can remember a time in the "way-back", when I had set up a control for a small machine. just a PLC with switches and lamps for the User Interface,
then they decided they needed to be able to adjust the time of a certain function, so I added some small red lion display that showed the timer preset with up/down buttons to change the value. For some reason I couldn't define the decimal position on the display, and the operator was confused by the term Implied Decimal.  I'd point to the spot and say "just pretend there is a decimal point here", he still didn't get it...

Finally, I grabbed a bottle of White-Out, and made a "dot" on the display.... Oh, now I get it....

##### Share on other sites

• MVP 2023

Thank goodness no one has asked about shifting bits left or right to multiply or divide by powers of 2.

## Create an account

Register a new account

×