# Writing math functions

## Recommended Posts

Hello,

I am a Swedish car enthusiast who has used Link products for twenty years. Right now in my own BMW E30 with a S50 engine, turbo and a Link Extreme G4X.

First of all, I want to congratulate Link for creating amazing products and software. So easy to get started and so many simple but effective tuning tools.

I have now done most of the settings including basically all functions. CLL, VVT/Vanos, Normalized knock, Idle control, Boost control and so on and therefore felt I wanted to activate the Long term function. I initially set it up by limiting it via a GP/Aux that only activates it under certain circumstances. ECT above 75 deg C, IAT above 25 deg C and TPS above 2%. But since I would like to regulate in a range and not above/below certain values, I started writing a math function. I've now come as far as I can with common sense, but would like some feedback on whether I'm on the right track? This is what I wrote (below) and the idea is that I want "1" outside the span so that I disconnect Long term then via "Disable input". I could read that "<" and ">" and so on are in the basic functions, but is it possible to write like I did to create spans?

(40>a>25)&(85>b>75)&(c>2)=0
(a is IAT, b is ECT and c is TPS)

Thank you for feedback on this

Sincerely,

/Johan Eklund, Sweden

##### Share on other sites

Hello again,

I think I figured out how to do it. The GP settings had to be the level for when Long term becomes active, while the math equation had to decide when the function should be turned off due to too high temperatures.

But, I don't know if I'm doing something wrong because even though the log for "Math Block 1 Output" indicates "1" at high temperatures, Long term remains active - even though "Disable Input" is set to "Math Block 1". See attached pic below.

##### Share on other sites

1 hour ago, Johan E said:

But, I don't know if I'm doing something wrong because even though the log for "Math Block 1 Output" indicates "1" at high temperatures, Long term remains active - even though "Disable Input" is set to "Math Block 1". See attached pic below.

Please attach the tune and log, we cant even see any statuses in the screenshot.

##### Share on other sites

Hello again,

Thanks for the reply Adam. I was probably a little too quick to make my posts and needed to think a little more first. I now think I solved it all by understanding the logic of the system better.

I did this by first letting the Long Term Fuel Trim "Disable Input" be controlled by Math Block 1, which in turn got an equation that included the result of Virtual Aux 1 - which is configured as GP Output 1.

On my test today, everything seems to be working, but of course will check this through the entire warm-up phase as well before I can be completely sure.

To summarize: I now have a Long Term Trim that starts at 25 deg IAT and 75 deg ECT. The equation in Math Block 1 turns Long Term off if the temperature exceeds 38 deg IAT or 88 deg ECT or if TPS is below 1% - or if Virtual Aux 1 is on (during warm up).

Best regards,

/ Johan

##### Share on other sites

(a<40&a>25)&(b<85&b>75)&(c>2) seems to fit in the character limit.. and it saves in the g5 version of pclink.

for an input disabled setup you want the inverse..

(a>40|a<25)&(b>85|b<75)&(c<2)

##### Share on other sites

Hello,

Thanks for your reply atlex, will test that equation. That's exactly how I wanted it but felt unsure about the syntax. Will however also test my own variant to see if it works as well. So that I know in case of other needs.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.