Jump to content

Recommended Posts

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


Link to comment
Share on other sites

  • MVP 2021

Please see this topic

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.

Link to comment
Share on other sites

  • MVP 2021
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.

Link to comment
Share on other sites

  • MVP 2021

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.

You didn't upload your program so we can really see what you're doing (please do upload it) so I'll take a guess based on your comments regarding inHg and Bar.

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.






  • Like 1
Link to comment
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....

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.

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...