Welcome to the MP3Car.com forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact us.
|
08-28-2005, 05:16 PM
|
#16
|
|
See me in my wet t-shirt.
Join Date: Aug 2003
Location: Warwickshire, UK
Vehicle: Ford Focus MP3
Posts: 1,909
|
Quote: Originally Posted by Erorus
PHP Code:
Function GetMPG(tMAF As Variant, tSpeed As Variant, tLTFuelTrim As Variant) As Variant
''MAF is maf_air_flow sensor. To convert from what the OBD returns, value=OBDData * 0.01
''tSpeed is vehicle speed in MPH. To convert from what the OBD returns, value=OBDData * 0.621371192
''tLTFuelTrim is long-term fuel trim. To convert from what the OBD returns, value=0.7812 * (OBDData - 128)
If IsNull(tMAF) Or IsNull(tSpeed) Or IsNull(tLTFuelTrim) Then
GetMPG = Null
Exit Function
End If
Dim tMPG As String
'' Do MAF over an hour
tMAF = tMAF * 60
tMAF = tMAF * 60
'' Turn into KG/litre equivalent
tMAF = tMAF / 1000
'' Get petrol flow based on 14.7:1
tMAF = tMAF / 14.7
'' convert litres to gallons
tMAF = tMAF * 0.219969157
'' convert long term fuel trim to percentage
tLTFuelTrim = (tLTFuelTrim / 100) + 1
'' Calculate MPG
tMPG = (tSpeed / tMAF) * tLTFuelTrim
GetMPG = FormatNumber(tMPG, 1, True, False, False)
End Function
The problem I have with this is the air flow sensor is very optimistic, and you probably run richer than this formula indicates. It says I average around 60-90MPG when cruising on the hwy and up to 200+ MPG when coasting. However, it does change when you have the pedal down, etc. I forget where I stole this code from.
It looks like my botched attempt at MPG conversion I think.
I didn't think it was accurate as it could be either, and haven't actually used it in real-life.
Any idea what could be done using the OBD to get a more accurate measure?
|
|
|
07-15-2007, 10:57 PM
|
#17
|
|
Newbie
Join Date: Jun 2007
Posts: 16
|
does anyone have this class working?
If so, could you post a sample app to be looked at?
Thanx
|
|
|
07-16-2007, 07:09 AM
|
#18
|
|
Newbie
Join Date: Aug 2005
Location: Ohio
Vehicle: 2005 Mazda 6s
Posts: 11
|
Quote: Originally Posted by takissd 
great! will that work with vb.net??? if yes, how?
You can attempt to convert it into .NET. But its very possible it will get botched up. At least that's been my experience with most of the .NET conversions I've done.
|
|
|
07-17-2007, 07:43 AM
|
#19
|
|
Newbie
Join Date: Jul 2006
Posts: 52
|
Hi guys, I am programmer too. While I am mostly involved in database/plsql programming I have fooled around with C/C++ and some VB. Assembly too!
Can anyone tell me if there would any substantial performance difference between a typical serial communication tool for OBDII written in C/C++ versus VB/.net ? Think CAN too.
|
|
|
07-17-2007, 04:43 PM
|
#20
|
|
Newbie
Join Date: Jun 2007
Posts: 16
|
Sample app that I am trying to get to work with this class, I am not sure how to "pass a mscomm control, the port number, and a timer control to it" ?
Can some one help get me started with this?
|
|
|
07-20-2007, 03:10 PM
|
#21
|
|
Low Bitrate
Join Date: Feb 2005
Location: NEPA
Vehicle: 2002 Mitsubishi Eclipse
Posts: 100
|
I wrote this class back in the day.. Basically, once you create mscomm1 and timer1 you'll never need to touch those controls. When you use
dim withevents elm as clselm323
then you should see "elm" as a control in the code window with its own events. Those events fire whenever things happen with that class. So you don't have to handle mscomm1_oncomm at all.
Let's say that your elm323 is on com2.
strReturn$ = elm.openELM(mscomm1, 2, timer1)
if strReturn$ = "" then
msgbox "opened successfully"
else
msgbox "open error: " & strReturn$
end if
private sub elm_statusmessage(byval strMessage as string)
debug.print strMessage
end sub
private sub elm_OBDReturn(ByVal bMode As Byte, ByVal bPID As Byte, ByVal strData As String, ByVal lngData As Long)
msgbox "OBD Returned mode " & cstr(cint(bMode)) & ", pid " & cstr(cint(bPID)) & ": " & cstr(lngdata)
end sub
|
|
|
10-06-2007, 04:09 AM
|
#22
|
|
Newbie
Join Date: Jul 2007
Posts: 3
|
You might want to convert tSpeed from kph to mph
Quote: Originally Posted by Erorus 
PHP Code:
Function GetMPG(tMAF As Variant,
tSpeed As Variant, tLTFuelTrim As Variant) As Variant ...
The problem I have with this is the air flow sensor is very optimistic, and you probably run richer than this formula indicates. It says I average around 60-90MPG when cruising on the hwy and up to 200+ MPG when coasting. However, it does change when you have the pedal down, etc. I forget where I stole this code from.
Quote: Originally Posted by stevieg 
It looks like my botched attempt at MPG conversion I think.
I didn't think it was accurate as it could be either, and haven't actually used it in real-life.
Any idea what could be done using the OBD to get a more accurate measure?
Last edited by skewbe : 10-06-2007 at 04:16 AM.
|
|
|
10-09-2007, 02:04 AM
|
#23
|
|
Newbie
Join Date: Jun 2003
Posts: 22
|
First of all thanks Erorus for nice class. I was able to implement OBD read VB program in few hours.
http://www.mp3car.com/vbulletin/engi...-maf-obd2.html
I tried using the MPG calculation in above thread and it seems to be pretty accurate. Many constants are similar to what is shown in this thread but this thread seems to be missing pound to gallon conversion and seems to be off by 10x as well. I see that the fuel trim is used here. I'll try to apply that. Looks like it may give you better estimate for your car rather than looking for ideal values.
The equation I am using is
14.7 g of air / 1 g of gas * 6.17 lb / 1 gal * 454 g / 1 lb * VSS Km / 1 h * 1 Mi / 1.609344 Km * 1s / MAF (100g from OBD) * 100g * 1 h / 3600 s * (0.7812 * (LTFT - 128) + 1)
Which will be
710.7 * VSS / MAF * (0.7812 * (LTFT - 128) + 1)
When cruising I get about 20 MPG and when I press the clutch I get like 105MPG which kinda makes sense.... =P When I calculate MPG when I fuel my car I get about 23MPG so I think this is pretty close.
Erorus, do you know if there is a way to read the OBD data in burst fashion? Or is this the limitation of ELM chip? I tried to tune the time to read the data from OBD but reading those three data takes at least 2.5 s. I kind of want to be able to read all three at the same time to increase the accuracy. In 2.5 second many things can change.
Is there a way to read back the data more quickly?
If not I guess running average or something similar can be implemented I suppose.. =)
Regards
|
|
|
10-09-2007, 02:38 AM
|
#24
|
|
Newbie
Join Date: Jun 2003
Posts: 22
|
Actually instead of 0.7812 it should be -0.007812. I forgot this was in percentage and also positive value means on LTFT means using more fuel.
Regards
|
|
|
10-09-2007, 09:33 AM
|
#25
|
|
Newbie
Join Date: Jun 2003
Posts: 22
|
I found my error regarding data ready time. I've set the timer interval before openELM function so default must have been assigned. I was able to set it to 200ms without getting any errors. However it would still be nice if we can read the data at the same time though. Is this possible?
Regards,
|
|
|
10-28-2007, 12:39 PM
|
#26
|
|
Newbie
Join Date: May 2007
Posts: 23
|
Wouldn't it be easier to just use injector duty-cycle, engine RPM, and speed to derive this data?
|
|
|
10-28-2007, 12:40 PM
|
#27
|
|
Newbie
Join Date: May 2007
Posts: 23
|
I know nothing about PHP and I also know very little about what is avalible from the OBD2 interface, but here goes:
|
|
|
10-28-2007, 01:00 PM
|
#28
|
|
Newbie
Join Date: May 2007
Posts: 23
|
Quote: Originally Posted by Erorus 
PHP Code:
Function GetMPG(tIDC As Variant, tSpeed As Variant) As Variant
''tIDC is injector duty cycle.
''tSpeed is vehicle speed in MPH. To convert from what the OBD returns, value=OBDData * 0.621371192
''tVFF is volume fuel flow.
If IsNull(tIDC) Or IsNull(tSpeed) Then
GetMPG = Null
Exit Function
End If
Dim tMPG As String
Dim tVFF As String
'' Do VFF (gallons/minute)
tVFF = tIDC * 250 * 0.000264172051
'' Do Speed in miles/min
tSpeed = tSpeed/60
'' Calculate MPG
tMPG = (tSpeed / tVFF) * tLTFuelTrim
GetMPG = FormatNumber(tMPG, 1, True, False, False)
End Function
This is with 250cc/min injectors. Would something like this work?
Last edited by oroboros_ARR : 10-28-2007 at 01:04 PM.
|
|
|
05-05-2008, 09:32 AM
|
#29
|
|
Newbie
Join Date: May 2008
Posts: 1
|
Yes i always wanted to make one of these. But i dont know how im not that smart of a person. But i love to learn ... You people know any good places to find codes for this stuff.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:35 AM.
|
|