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

4-Channel CAN Router with Data Logger
Locked
Dominik M.
Posts: 14
Joined: Mon 27. Jan 2020, 09:58

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

Post by Dominik M. » Mon 17. Feb 2020, 17:35

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.

User avatar
S.Schott
Hardware Development
Hardware Development
Posts: 32
Joined: Mon 4. Oct 2010, 16:50

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

Post by S.Schott » Tue 18. Feb 2020, 12:14

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)...
Attachments
gearbox.JPG
gearbox.JPG (53.58 KiB) Viewed 4844 times
GearBox.ppproj
(21 KiB) Downloaded 1708 times

Dominik M.
Posts: 14
Joined: Mon 27. Jan 2020, 09:58

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

Post by Dominik M. » Wed 19. Feb 2020, 18:43

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!

Locked