sgull Posted June 23, 2018 Report Share Posted June 23, 2018 Would it be possible to have the option to password protect formulas in the next version of UniLogic. Regards, Denis Quote Link to comment Share on other sites More sharing options...

MVP 2023 Joe Tauser Posted June 23, 2018 MVP 2023 Report Share Posted June 23, 2018 You can password protect a function - That would be the easy way to protect your formula with the tools currently available. Joe T. Quote Link to comment Share on other sites More sharing options...

sgull Posted June 23, 2018 Author Report Share Posted June 23, 2018 Hi Joe I think this only protects the ladder and where the formula is called. The formula editor is lower down the tree and does not appear to have the protect option. Regards Denis Quote Link to comment Share on other sites More sharing options...

MVP 2023 Joe Tauser Posted June 24, 2018 MVP 2023 Report Share Posted June 24, 2018 True. But you could make your formula the old-fashioned way with ladder function blocks. This is what I was inferring. How complex of a formula are we talking about? Joe T. Quote Link to comment Share on other sites More sharing options...

sgull Posted June 25, 2018 Author Report Share Posted June 25, 2018 Thanks Joe I will need to do this now anyway. I tried to write a formula that was working in visilogic in unilogic. I tried for a few hours to get it to work but kept getting different values in the two PLC's. After submitting the project to support, they confirmed that there was an bug and would need to research this. I would advise checking the results of formulas in Unilogic for correct operation. See attached. The VLP is the formula working correctly in Visilogic The Test formula.ulpr is the one that does not work. The Test formula_ak.ulpr is the work around supplied by support. Regards Denis formula test.vlp Test Formula.ulpr Test Formula_AK.ulpr Quote Link to comment Share on other sites More sharing options...

Saragani Posted June 26, 2018 Report Share Posted June 26, 2018 I already replied the support about this issue. When writing 3738 / 100000, it performs Integer division, which in the case results 0. However adding a .0 to any of the numbers you divide will cause the number to be casted to float, and it will result the desired output. Going on the safe side, I would add a .0 to both numbers, meaning: 3738.0 / 100000.0 If either 3738 or 100000 come from parameters that change, then you can either multiple any of these parameters by 1.0 (which would cast the number to float and will force a float division. Another way to write ( 3738 / 100000 ) * A, is: ( 3738 * A / 100000 ) Since A is float, the 3738 will be cast to float, so the entire division will be a float division. // EDIT: VisiLogic and UniLogic devide differently on when to cast to float. I can give an example from VisiLogic of a similar "issues". Let's take the formula A / B If A us 5 and B is 3, the result is 1.6666666... Assuming A and B are MIs, then if we place the result into an MI, the actual result would be 1 and not 2 (even though in this case you would assume it needs to round the number) because the A and B was divided using Integers division. If however the result is stored into an MF, the result would be 1.666666666666 Now, if we repeat the test but now the formula is A / B + C, where only C is a MF, and the result is once again stored into an MI, then: if A is 5, B is 3 and C is 0, then magically, the result becomes 2. Why? because now A and B are divided using float division and not integer division. I'm not sure if VisiLogic automatically casts all the numbers to floats as soon as there is a float in either the formula or the result. (I'm guessing that digging in both VisiLogic and the PLC code would produce the answer). I'm not sure on which scenarios numbers and operations should be case to float, but if you take c# and write a code that executes the exact formula that you have, then the division will be using Integer division, since 2 integers are being divided and only then the result is being cast to float in order to be multiplied by another float. For example, taking your formula. In c#: float A = 10; var result = Math.Exp(1.45723 + ((3738 / 100000) * A) - (0.000153067 * (Math.Pow(A, 2))) + (0.000000676029 * (Math.Pow(A, 3))) - (0.00000000257604 * (Math.Pow(A, 4)))); var resultF = Math.Exp(1.45723 + ((3738.0 / 100000.0) * A) - (0.000153067 * (Math.Pow(A, 2))) + (0.000000676029 * (Math.Pow(A, 3))) - (0.00000000257604 * (Math.Pow(A, 4)))); result = 4.2315720565926735 resultF = 6.149517162661482 So Microsoft is wrong to? 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.