Milosh

APR - OUTPUT VALUE

12 posts in this topic

Hi all.

I have APR function for linear scaling.

Sample

X0=4000, Y0=80

X1=3000, Y1=82

Which would be the output Y for X=3000?!

It should be 80.

This function returns X0 if is X<X0?!

Share this post


Link to post
Share on other sites

Which PLC family?  Also, can you show the values of the control words?

 

Share this post


Link to post
Share on other sites

D650 = #201

D651 = 4000

D653 = 80

D655 = 3000

D657 = 82

APR

control word = D650

Source word = 3000

Result word = D760

 

 

Share this post


Link to post
Share on other sites
19 minutes ago, Milosh said:

D650 = #201

D651 = 4000

D653 = 80

D655 = 3000

D657 = 82

APR

control word = D650

Source word = 3000

Result word = D760

 

 

19 minutes ago, Milosh said:

Not quite correct. Only way I could make it work is if in the APR  if X1 is greater than X0.

See attached code with OP's data.

 

 

 

 

CP1L_APR_SCALING.cxp

Edited by BITS N BYTES

Share this post


Link to post
Share on other sites

Thanks a lot.

But how to convert these values to be correct. Maybe to use some NEGATE function?!

Share this post


Link to post
Share on other sites
6 minutes ago, Milosh said:

Thanks a lot.

But how to convert these values to be correct. Maybe to use some NEGATE function?!

The example I posted works correctly for the values you are asking for.

Share this post


Link to post
Share on other sites

Thanks a Lot. But what happens if I have floating numbers. Let say. D651 = 4000 and D653 = 80.45?

Share this post


Link to post
Share on other sites
38 minutes ago, Milosh said:

Thanks a Lot. But what happens if I have floating numbers. Let say. D651 = 4000 and D653 = 80.45?

which PLC? 

Floating point in APR only available on :

Single-precision floating-point data (CJ2/CS1-H/CJ1-H/CJ1M/CS1D Only)

According to APR help.

Share this post


Link to post
Share on other sites

CS1H-H CPU64. I think that Ishould use NEGL instruction to negate D651 and D655, and than it would be work?

Share this post


Link to post
Share on other sites
49 minutes ago, Milosh said:

CS1H-H CPU64. I think that Ishould use NEGL instruction to negate D651 and D655, and than it would be work?

for floating point control word bit 09 needs to be set. So:

Control word:

D651 = &512

D652/3  X0 = 3000.00

D654/5 Y0 = 80.45

D656/7 X1= 4000.00

D658/9 Y1 = 82.00

Share this post


Link to post
Share on other sites

Thanks a lot all.

I do the NEGL and everything seems to be ok.

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