arnoldzw

Calculate exponent in FX2

8 posts in this topic

Hi All,

I need to do some math in an FX2 PLC.
I`m using GXWorks2.

What i need is the function " ** / Exponentiation "  (but in help i see this function is only available in FX3U)

For Example:
d := s1 ** s2;

The problem is my exponent is also an FLOAT value, 1.5.

What is need to calculate is:     result :=  Measurement_value ** 1.5

How can this math been done in an FX2N, hope someone can give me some advice?


Best regards,
Arnold

 

 

Edited by arnoldzw

Share this post


Link to post
Share on other sites
6 hours ago, arnoldzw said:

What is need to calculate is:     result :=  Measurement_value ** 1.5

How can this math been done in an FX2N, hope someone can give me some advice

This is an initial school arithmetic rule: Y=X**1.5=X**(1+0.5)=(X**1)*(X**0.5)=X*SQRT(X)

Edited by Inntele

Share this post


Link to post
Share on other sites
On 5-12-2019 at 9:45 PM, Inntele said:

This is an initial school arithmetic rule: Y=X**1.5=X**(1+0.5)=(X**1)*(X**0.5)=X*SQRT(X)

Thank you for you`re answer,

The SQRT instruction isn`t available in my FX2 CPU and GXWorks.

 

Searching in the manuals only gives  the SQR / SQRP / DSQR / DSQRP  instructions, but these are only for word format.

 

I need the float value, then the DESQR instruction and DESQRP are available. But these instructions only do square root operation.

I have also an float exponent (1,5)

 

Don`t know how to calulate Y="float value"**1,5

 

My math skills from school are not that good anymore :shrug:

 

Share this post


Link to post
Share on other sites

1.jpg

1 person likes this

Share this post


Link to post
Share on other sites

Sorry,  i still don`t get it when i read the example with DESQR an DEMUL as decribed above,   :stupid:

 

My base value is from an analog measurement and is an floating value.

The power raising factor is also an float value, but fixed 1,5.

 

For example:  let`s say my measurement value is 0,25.

What to calculate is:    Y = 0,25**1,5     (0,25 to the 1,5th)   or  ( in excel function   POWER(0.25;1.5)   )

 

Can someone explain how to do this in an FX2 CPU?

 

 

Share this post


Link to post
Share on other sites

EXACTLY as already shown....

 

X to power of 1.5 is same as

X to power to 3/2

which is same as X to power of (1+1/2)

which is the same as X*sqrt(X)

 

when X=0.25, using power function you get: 0.25^1.5 = 0.125

note that sqrt(0.25)=0.5 and 0.25*0.5 = 0.125

0.125 = 0.125 

it is the same result.

you just need to replace function you want with the equivalent function that you got.

and in this case that just happen to be square root and multiplication instead of power.

but result is still the same. regardless what value of X you start with. 

and here is what Excel says:

power.jpg

 

B5 cell "=POWER(A5,1.5)"

C5 cell "=A5*SQRT(A5)"

D5 cell "=ABS(B5-C5)<0.00000001"

Share this post


Link to post
Share on other sites
16 hours ago, panic mode said:

X to power of 1.5 is same as

X to power to 3/2

which is same as X to power of (1+1/2)

which is the same as X*sqrt(X)

 

when X=0.25, using power function you get: 0.25^1.5 = 0.125

note that sqrt(0.25)=0.5 and 0.25*0.5 = 0.125

 

That make sense! thank you!

Didn`t knew those where the same, only another way  of notation!

 

Have tested it, and it works now, thank you!

Share this post


Link to post
Share on other sites

that's good. should thank Inntele, he was the one to respond promptly

btw correct solution was handed months ago. if there was any doubt, why not simply try it? it would take mere minutes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now