Gentlemen,
I see that many people would like to use some sort of IF statement at the equation editor in the PID editor.
You could using boolean algebra to do that.
For example, let’s imagine that one would want to implement a RPM monitor:
The custom pid would output equation/values:
0 for RPM = 500) && ([0C] < 1000) ) {
Do equation R3*256
}
If( ([0C] >= 1000) ) {
Do equation R5*256 + R4
}
In order to do that, we must use int(), so that we only get integers, rounded down.
I am going to name those expressions bellow to make things lean:
A = int( ( [0C] ) / (int([0C]/500)*500+0.01) )
B = int( ( [0C] ) / (int([0C]/1000)*1000+0.01) )
The 0.1 is chosen randomly, just to prevent division by 0. It should be a fraction between 1 and 1, different than 0. And small enough, in order to keep the errors low.
Observe that A results in:
0, for [0C] = 0 to 500.01
1, for [0C] > 500.01
And so on
B results in:
0, for [0C] = 0 to 1000.01
1, for [0C] > 1000.01
And so on.
If we do (1A), then it equals to 1 for 0
