Page 1 of 1

channel editor

Posted: Sun Sep 10, 2017 5:31 am
by MS2tester
could the channel editor get some more attention
it,s overly sensitive to white spaces and refuses some very simple calculations

Re: channel editor

Posted: Mon Sep 11, 2017 7:56 am
by LT401Vette
In what way is it overly sensitive to white spaces?

TS does not know how to handle division by 0 as I do not know how to.
When you are attempting to divide by 0, what would be your desired behavior?
- Allow an over-ride? (It will then churn out errors to the AppDebug at runtime)
- Perhaps suggest a fix to protect against the divide by 0?

In this case, what you would perhaps want to put in that expression:

vss2 > 0 ? vss1 / vss2 : 1

That will prevent your expression from creating errors.

Re: channel editor

Posted: Mon Sep 11, 2017 11:18 am
by MS2tester
this is sort of what i mean exact the same calculations but one gives an error the other does not
not clear why
maybe this is an excel sheet background some how that gives this error when there is no data

Re: channel editor

Posted: Mon Sep 11, 2017 1:17 pm
by LT401Vette
Hmmm, now what is different where it passed the validation?

I tried:
(vss1 / vss2)
( vss1 / vss2 )
(vss1/vss2)
( vss1 / vss2 )
etc.. I haven't been able to get a valid expression based on spaces. And they really should not matter.

The only thing that should make that pass is if some how vss2 is not 0.
Which if you were online it could have a left over value of non-zero.

I am curious..

Re: channel editor

Posted: Wed Sep 13, 2017 11:15 am
by MS2tester
i guess when trying to make it work i somehow turned off my ecu while trying different ways off making the calculation work
being offline is definitely a bonus when making a custom channel
i don,t know if this is a vss specific issue or if there are more inputs affected

Re: channel editor

Posted: Wed Sep 13, 2017 11:32 am
by jsmcortina
I'm guessing that "Not a number" divided by "Not a number" is 1 ?

James

Re: channel editor

Posted: Wed Sep 13, 2017 1:41 pm
by Matt Cramer
jsmcortina wrote:I'm guessing that "Not a number" divided by "Not a number" is 1 ?

James
It depends on how big your number that is not a number is. The math parser probably doesn't understand calculus limit functions. :P

Re: channel editor

Posted: Wed Sep 13, 2017 1:47 pm
by LT401Vette
jsmcortina wrote:I'm guessing that "Not a number" divided by "Not a number" is 1 ?

James
I think that is sort of it... It the variables are non initialized and are NaN, then NaN/NaN=NaN
That doesn't cause an exception as divide by 0 does.

MS2tester wrote:i guess when trying to make it work i somehow turned off my ecu while trying different ways off making the calculation work
being offline is definitely a bonus when making a custom channel
i don,t know if this is a vss specific issue or if there are more inputs affected
I don't think you are quite getting it.. You want to listen to the errors, not find ways around them. If you make expressions with errors, then at run time TS will be churning errors and filling the AppDebug with error entries.

It seems I do need to tighten up these validations.

Re: channel editor

Posted: Wed Sep 13, 2017 11:25 pm
by MS2tester
obviously correct calculus is important
i am just a little worried that the validation will be over protective and have a "why do you want to do that!" attitude
like dividing vss1 by vss2 making no sense
but the math is correct!
so if i want to multiply the fuel pressure by rpm i am able to do so, even if there is no possible use for it

Re: channel editor

Posted: Thu Sep 14, 2017 5:36 am
by jsmcortina
Phil,
how about implementing automatic divide by zero protection? Many customers don't understand why it is a problem and will continue to trip over it.

A failsafe could be x/0 = 0

James

Re: channel editor

Posted: Thu Sep 14, 2017 5:47 am
by LT401Vette
jsmcortina wrote:Phil,
how about implementing automatic divide by zero protection? Many customers don't understand why it is a problem and will continue to trip over it.

A failsafe could be x/0 = 0

James
I'll think think about that. I am somewhat hesitant to make the TS math parse do incorrect math, perhaps make it x/0=NaN.

I could also perhaps make it automatically add/suggest the divide by 0 protection upfront.

Re: channel editor

Posted: Thu Sep 14, 2017 10:29 pm
by MS2tester
correct me if i am wrong but within megasquirt 0 will be a true value
fuel pressure will be 0 with the pump not running
wheel speed sensors will be 0 with the car not moving
pulse width will be 0 with the engine not running :?

Re: channel editor

Posted: Fri Sep 15, 2017 7:09 am
by LT401Vette
MS2tester wrote:correct me if i am wrong but within megasquirt 0 will be a true value
fuel pressure will be 0 with the pump not running
wheel speed sensors will be 0 with the car not moving
pulse width will be 0 with the engine not running :?
Yes, now you are getting it..
You don't want those in the divisor unless it is checked and handled, your expression should have protection up front like outlined above.

Re: channel editor

Posted: Sat Jul 31, 2021 4:39 am
by MS2tester
as i am currently still using wrong math , i would like to get this working with the newer firmware
tried this, is coming up invalid
= ( vss2 > 0? vss2 / vss1 > 0? vss1 )
what would not let the math channel freak out?

Re: channel editor

Posted: Sat Jul 31, 2021 8:28 am
by MS2tester
well not getting it :roll:

Re: channel editor

Posted: Sun Aug 01, 2021 8:14 am
by LT401Vette
In that last pic, start by getting rid of the != or |= up front. I don't know what that is for.

Then, what is the calc attempting to calculate? I see PropSlip, so in the end are you attempting to get vss1/vss2 with protection against divide by 0?

like this:
if( vss2 > 0, vss1 / vss2, 0)

of:

vss2 > 0 ? vss1 / vss2 : 0

Those are both the same expression, just 2 ways of doing it.

Re: channel editor

Posted: Sun Aug 01, 2021 12:12 pm
by MS2tester
yes it is a math channel to display proppelor slip on a boat by divding true speed (gps pulse per meter) by theoretical speed ( RPM pulse fed back to wheel speed input with prop pitch input)
this is what works in google spreadsheet with the correct slip numbers versus the mercury marine online slip calculator in %
now still need to test with actual pulse inputs
atleast the mathparser is satisfied now