Internet PLC Forum

General => Technical support => Topic started by: scottsaunders on April 14, 2003, 04:53:47 AM

Title: Calculation with decimal point
Post by: scottsaunders on April 14, 2003, 04:53:47 AM
I want to do the calculation:

T = 25.57 - 0.01249A

I want to then store the value of T in to timer 1.

I read in the forum that only integer math is available so how do I do this?

Title: Re: Calculation with decimal point
Post by: support on April 14, 2003, 12:27:05 PM
You can use fixed point arithmatics. Assuming every unit represents 0.01:

T = 2557 - 1249*A/100000

(Make sure that  you multiply by A first before dividing by 100000)

The resulting value T is x 100.

You can store value of T in timer #1 S.V using SETTIMERSV.

You can store it in timer #1 P.V (present value using  TIMERPV[1] = T.

If you define timer #1 as High speed timer then each unit of T represent 0.01s.