Torque

Forums

Forums

Guest  

Show or hide header
Welcome Guest, posting in this forum require registration.




Torque » Torque OBD ECU Scanner » Torque Discussion / Ideas » Formula Precision or Calculation Issue

Pages: [1]
Author Topic: Formula Precision or Calculation Issue
sshawn09
Member
Posts: 4
Post Formula Precision or Calculation Issue
on: November 10, 2022 (GMT)

I created a 3rd order formula and made a custom pid to output the results. The answer was incorrect and I went through each step to see what was going on. The display showed all correct calculations but the final result was wrong. It showed that the final calculation in “testing PID” list was:

=-0.000013*2303236.5471191406+0.005697*17440.50390625-0.50338*132.0625+14.399741

Plugging into excel, the answer is correctly 17.3378
Result in torque is -11.460886

What can be wrong here?

If needed, the PID formula is:
= -0.000013*((((A*256)+B)*(1/64))^3) + 0.005697*((((A*256)+B)*(1/64))^2) – 0.50338*(((A*256)+B)*(1/64)) + 14.399741
Where from OBD:
A=33
B=4

Thanks in advance.

Torque Pro 1.12.100

moreause
Member
Posts: 637
Post Re: Formula Precision or Calculation Issue
on: November 11, 2022 (GMT)

i tried your formula in excel

= -0.000013*((((A*256)+B)*(1/64))^3) + 0.005697*((((A*256)+B)*(1/64))^2) >>>>>>–<<<<<< 0.50338*(((A*256)+B)*(1/64)) + 14.399741

The second minus does work in excel
it show’s up like a longer minus sign =-– that is what i get in excel the first minus vs the second

weird

cintakc
Member
Posts: 1661
Post Re: Formula Precision or Calculation Issue
on: November 11, 2022 (GMT)

I came across this, try replacing exponentiation with a simple multiplication
for some reason android incorrectly raises to a power

sshawn09
Member
Posts: 4
Post Re: Formula Precision or Calculation Issue
on: November 14, 2022 (GMT)

<div class=”quote”><p>Quote from moreause on November 11, 2022

i tried your formula in excel

= -0.000013*((((A*256)+B)*(1/64))^3) + 0.005697*((((A*256)+B)*(1/64))^2) >>>>>>–<<<<<< 0.50338*(((A*256)+B)*(1/64)) + 14.399741

The second minus does work in excel
it show’s up like a longer minus sign =-– that is what i get in excel the first minus vs the second

weird

</p></div>

Interesting find! I’ll toy around with that and report back. How the heck did it come out like that, so strange!
Shawn

sshawn09
Member
Posts: 4
Post Re: Formula Precision or Calculation Issue
on: November 14, 2022 (GMT)

<div class=”quote”><p>Quote from cintakc on November 11, 2022
I came across this, try replacing exponentiation with a simple multiplication
for some reason android incorrectly raises to a power</p></div>

How do you mean, making the formula longer and repeating the equation? Such as…. 2^3 but instead 2*2*2? Or do you mean similar to other languages, like 2**3?

Shawn

sshawn09
Member
Posts: 4
Post Re: Formula Precision or Calculation Issue
on: November 14, 2022 (GMT)

Woohoo I figured it out! The weird minus didn’t make any change but it got me thinking about spacing and perhaps it has an affect on what gets calcd first. To clean it up I changed the equation to this and waalaa…

(-1*0.000013)*((((A*256)+B)*(1/64))^3) + (1*0.005697)*((((A*256)+B)*(1/64))^2) + (-1*0.50338)*(((A*256)+B)*(1/64)) + 14.399741

Basically I did a+b+c+d and used -1* for the negative numbers.

Thanks for everyone’s help!

Shawn

Vasilich
Member
Posts: 218
Post Re: Formula Precision or Calculation Issue
on: November 14, 2022 (GMT)

I assume that following simplified formula will also work:

((-0.000013)*((((A*256)+B)/64)^3)) + (0.005697*((((A*256)+B)/64)^2)) – (0.50338*(((A*256)+B)/64)) + 14.399741

Surely you can simplify it even further, but for the sake of understanding what’s going on there it could be less effective then.

Just out of interest – what is the reason to make such a complex formulas? I haven’t seen any PID having polynomial formulas yet …

Pages: [1]
WP-Forum by: Fredrik Fahlstad, Version: 2.4
Page loaded in: 0.027 seconds.

  Follow me on twitter