BlueWave Studio forum
Formula limitation? - Printable Version

+- BlueWave Studio forum (https://bluewavestudio.io/community)
+-- Forum: OpenAuto Pro (https://bluewavestudio.io/community/forum-86.html)
+--- Forum: OBD-II (https://bluewavestudio.io/community/forum-103.html)
+--- Thread: Formula limitation? (/thread-3365.html)



Formula limitation? - JonLB - 05-09-2022

I have a vehicle that does not provide fuel economy so I've found there are some formulas to use based on other OBD2 PIDs depending on whether you have a MAF or not.  I do not so I'm using a formula based on MAP.  Here are the relevant configs:

openauto_dbd_pids.ini:
[ObdPid_1]
;Engine speed
Query=010C
Formula=(256*a+b)/4

[ObdPid_2]
;Vehicle speed
Query=010D
Formula=a

[ObdPid_3]
;Intake manifold absolute pressure
Query=010B
Formula=a

[ObdPid_4]
;Intake air temperature
Query=010F
Formula=a-40

openauto_odb_gauges.ini
[ObdGauge_11]
MinValue=0
MaxValue=100
Limit=0
Formula=((getPidValue(2)*0.6214)/(3600*1000))/((((getPidValue(1)*getPidValue(3)/getPidValue(4)/2)/60)*(70/100)*4.6*28.97/8.314)/14.7/6.17/454)
Label=MPG
Precision=1

What I'm finding is the gauge reports 0.0 as the value.  If I trim some entries out of the formula to shorten it for testing purposes, then it does provide a non-zero result (albeit an inaccurate number due to missing formula entries).  I have also checked to make sure PIDs 1, 2, 3, and 4 are non-zero individually and they all register greater than zero.

So, I'm wondering -- is there a limitation on how long the gauge formula can be?


RE: Formula limitation? - BlueWave - 05-09-2022

There should not be any limitations. Please launch the dashboard that contains gauge with mentioned formula and provide the log file located at /home/pi/.openauto/cache/openauto.log. Most probably your car does not support some pid used in the formula.


RE: Formula limitation? - JonLB - 05-09-2022

Thanks for confirming there is no length limitation in the formula. I've made some changes to it and now it's reporting non-zero numbers so it was an issue with my formula.


RE: Formula limitation? - DerTeufel - 05-25-2022

(05-09-2022, 10:54 PM)JonLB Wrote: Thanks for confirming there is no length limitation in the formula.  I've made some changes to it and now it's reporting non-zero numbers so it was an issue with my formula.

what's the correct formula?


RE: Formula limitation? - JonLB - 05-26-2022

I can't say what the "correct" formula is as I'm still sorting it out.  Right now I'm using:

[ObdGauge_11]
MinValue=0
MaxValue=100
Limit=0
Formula=(710.7*getPidValue(2))/(((getPidValue(1)*getPidValue(3)/(getPidValue(4)+273.15))/120)*(70/100)*4.6*28.97/8.314)
Label=MPG
Precision=1

It's not providing an accurate value, but it's not zero anymore. Smile