# Invert scale 0-990 --> 990-0

## 7 posts in this topic

Hello.

I have a D word number 0-990. I would like to convert it to 990-0.

So i need a function which shows me 0, when the D100 is 990, and shows me 0 when the D100=990. And of course for the between values also. Calculating continiusly.

Help is much appreciated :)

##### Share on other sites

I guess the function i would need, is y=(-x)+990

Is it possible to implement functions in cj2m ?

##### Share on other sites

Not per se.  However, if you create a Function Block and use the same instance name over and over, it will behave as if you had created a Function.  Meaning that it will use the same memory for all instances of the Function block with that name.  It is not an issue in this case because it is a simple math formula that always provides the same result when a particular number is input (it does not depend on past executions to determine a result).

##### Share on other sites
2 hours ago, Chickenkiller91 said:

Hello.

I have a D word number 0-990. I would like to convert it to 990-0.

So i need a function which shows me 0, when the D100 is 990, and shows me 0 when the D100=990. And of course for the between values also. Calculating continiusly.

Help is much appreciated :)

From 990, substract your value that you want to invert and output to the word you want the inverted value.

##### Share on other sites
3 hours ago, Chickenkiller91 said:

I guess the function i would need, is y=(-x)+990

Is it possible to implement functions in cj2m ?

@pfort He had already figured that out in his second post above.

##### Share on other sites
4 hours ago, Michael Walsh said:

@pfort He had already figured that out in his second post above.

Yes, I meant, no need for a function block (As I interpret his post). He only need a substraction instruction.

So, Chickenkiller, Michael is right. You said that y=(-x)+990 and I said that y=990-x. It's the same.

What I say is you only need a substraction instruction, available in any PLC.

Edited by pfort

##### Share on other sites

Use the APR instruction!!

CP1L_APR_SCALING Inverted.cxp

Edited by BITS N BYTES
See attached CXP example