Search the Community
Showing results for tags 'wrong'.
-
Formula block - unexpected result
Guest posted a topic in Vision & Samba PLC + HMI Controllers & VisiLogic Software
Hi, on Samba SM43-J-T20 I am using formula block to calculate simple equation "OUT = A / B * 1000000", where OUT is ML, operand A is MI (range 0 - 10000) and operand B is MI (constant 15747). Is it possible to get exact rounded integer result calculated with floating point registers without using any MF operand? In Help it says: In the following cases, controller will process the formula using floating registers: If the formula contains one or more floating operands. If a constant value in the formula is not a whole number If an operator, such as trigonometric operators, requires that the PLC use a floating register to complete its operation. If I use constant 1000000,0 or 1000,0 * 1000,0 in the formula it does not use floating point registers. For testing I have tried the following formulas (A = 5000, B = 15747): (1000,1 * ( 1000,1 * A ) ) / B result was 44772 (999,9 * ( 1000,1 * A ) ) / B result was 317521 ( ( 1000,1 * A ) / B ) * 1000,1 result was 317000 ( ( 1000,1 * A ) / B ) * 999,9 result was 317521 Can somebody explain these results and give some guidelines on how correctly use formula block. Regards, Matic