Page 1 of 1

How to use if equal or similar functions to set signal values?

Posted: Mon 17. Feb 2020, 17:35
by Dominik M.
Dear PEAK-Team,

I was wondering how the "if equal" and similar functions work (if less, if greater, etc.): If I understood correctly I can specify the number of functions/line which will be executed if the expression is true. And I am not defining the line number of (one) function block which will be executed:
If I would add 7 to "LinesPerformedIfTrue" the first to the seventh line would be executed and not only the 7th line, correct?

Would you mind to provide a small example how to set a signal value according to a comparison of another signal?
For example if I would have for each of the gear shift signals P,R,N,D, a single bit signal (on/off) and would like to translate it to a 2 bit signal (P = 0, R = 1, N = 2, D = 3). How could I do the comparison & value setting using the "if equal const". Or do you have a more simple solution for this example in mind?

Thank you!
Dominik M.

Re: How to use if equal or similar functions to set signal values?

Posted: Tue 18. Feb 2020, 12:14
by S.Schott
Hello.

I've made a very simple config using the IF EQUAL function,
You may also try the CHARACTERISTIC CURVE function.
See the function blocks reference manual for this (DVD or homepage)...

Re: How to use if equal or similar functions to set signal values?

Posted: Wed 19. Feb 2020, 18:43
by Dominik M.
Great,

your example helped me a lot. My mistake was the interpretation of the "PerformedLines" parameter. I thought that from the first (top) function block onwards the specified number of function blocks will be executed and not the following lines of my if function. Another mistake I made was also the function setting (mixed up input with output variable).

Thank you a lot!