Posted 10 Apr 2017 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 this post Link to post Share on other sites
Posted 10 Apr 2017 I guess the function i would need, is y=(-x)+990 Is it possible to implement functions in cj2m ? Share this post Link to post Share on other sites
Posted 10 Apr 2017 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 this post Link to post Share on other sites
Posted 10 Apr 2017 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 this post Link to post Share on other sites
Posted 10 Apr 2017 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 this post Link to post Share on other sites
Posted 10 Apr 2017 (edited) 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 10 Apr 2017 by pfort Share this post Link to post Share on other sites
Posted 11 Apr 2017 (edited) Use the APR instruction!! CP1L_APR_SCALING Inverted.cxp Edited 11 Apr 2017 by BITS N BYTES See attached CXP example Share this post Link to post Share on other sites