The MP3car.com Store  

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.

Go Back   MP3Car.com > Mp3Car Technical > Engine Management, OBD-II, Engine Diagnostics, etc.

Reply
 
Thread Tools Display Modes
Old 08-28-2005, 05:16 PM   #16
See me in my wet t-shirt.
 
stevieg's Avatar
 
Join Date: Aug 2003
Location: Warwickshire, UK
Vehicle: Ford Focus MP3
Posts: 1,909
My Photos: (0)
Quote: Originally Posted by Erorus
PHP Code:
Function GetMPG(tMAF As VarianttSpeed As VarianttLTFuelTrim As Variant) As Variant

''MAF is maf_air_flow sensorTo convert from what the OBD returnsvalue=OBDData 0.01
''tSpeed is vehicle speed in MPHTo convert from what the OBD returnsvalue=OBDData 0.621371192
''tLTFuelTrim is long-term fuel trimTo convert from what the OBD returnsvalue=0.7812 * (OBDData 128)
    
    If 
IsNull(tMAF) Or IsNull(tSpeed) Or IsNull(tLTFuelTrimThen
        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(tMPG1TrueFalseFalse)
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?
__________________
Ford Focus MP3 : www.stevieg.org/carpc
Car PC Status: COMPLETE
stevieg is offline   Reply With Quote
Sponsored Links
Old 07-15-2007, 10:57 PM   #17
Newbie
 
Join Date: Jun 2007
Posts: 16
My Photos: (0)
does anyone have this class working?
If so, could you post a sample app to be looked at?
Thanx
planethax is offline   Reply With Quote
Old 07-16-2007, 07:09 AM   #18
Newbie
 
Join Date: Aug 2005
Location: Ohio
Vehicle: 2005 Mazda 6s
Posts: 11
My Photos: (0)
Quote: Originally Posted by takissd View Post
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.
__________________
2005 Mazda 6s
2002 GMC Envoy SLT
Digital Deviation
Addict is offline   Reply With Quote
Old 07-17-2007, 07:43 AM   #19
Newbie
 
Join Date: Jul 2006
Posts: 52
My Photos: (0)
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.
It's A Honda is offline   Reply With Quote
Old 07-17-2007, 04:43 PM   #20
Newbie
 
Join Date: Jun 2007
Posts: 16
My Photos: (0)
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?
Attached Files
File Type: zip elm323class.zip (5.3 KB, 79 views)
planethax is offline   Reply With Quote
Sponsored Links
Old 07-20-2007, 03:10 PM   #21
Low Bitrate
 
Erorus's Avatar
 
Join Date: Feb 2005
Location: NEPA
Vehicle: 2002 Mitsubishi Eclipse
Posts: 100
My Photos: (0)
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
Erorus is offline   Reply With Quote
Old 10-06-2007, 04:09 AM   #22
Newbie
 
Join Date: Jul 2007
Posts: 3
My Photos: (0)
You might want to convert tSpeed from kph to mph

Quote: Originally Posted by Erorus View Post
PHP Code:
Function GetMPG(tMAF As Variant
   
tSpeed As VarianttLTFuelTrim 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 View Post
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.
skewbe is offline   Reply With Quote
Old 10-09-2007, 02:04 AM   #23
Newbie
 
Join Date: Jun 2003
Posts: 22
My Photos: (0)
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
hjcho616 is offline   Reply With Quote
Old 10-09-2007, 02:38 AM   #24
Newbie
 
Join Date: Jun 2003
Posts: 22
My Photos: (0)
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
hjcho616 is offline   Reply With Quote
Old 10-09-2007, 09:33 AM   #25
Newbie
 
Join Date: Jun 2003
Posts: 22
My Photos: (0)
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,
hjcho616 is offline   Reply With Quote
Old 10-28-2007, 12:39 PM   #26
Newbie
 
Join Date: May 2007
Posts: 23
My Photos: (0)
Wouldn't it be easier to just use injector duty-cycle, engine RPM, and speed to derive this data?
oroboros_ARR is offline   Reply With Quote
Old 10-28-2007, 12:40 PM   #27
Newbie
 
Join Date: May 2007
Posts: 23
My Photos: (0)
I know nothing about PHP and I also know very little about what is avalible from the OBD2 interface, but here goes:
oroboros_ARR is offline   Reply With Quote
Old 10-28-2007, 01:00 PM   #28
Newbie
 
Join Date: May 2007
Posts: 23
My Photos: (0)
Quote: Originally Posted by Erorus View Post
PHP Code:
Function GetMPG(tIDC As VarianttSpeed As Variant) As Variant

''tIDC is injector duty cycle

''tSpeed is vehicle speed in MPHTo convert from what the OBD returnsvalue=OBDData 0.621371192

''tVFF is volume fuel flow.
    
    If 
IsNull(tIDC) Or IsNull(tSpeedThen
        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(tMPG1TrueFalseFalse)

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.
oroboros_ARR is offline   Reply With Quote
Old 05-05-2008, 09:32 AM   #29
Newbie
 
Join Date: May 2008
Posts: 1
My Photos: (0)
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.
Dtecneon is offline   Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Able to get voltage from OBDII? aoLhaTer Engine Management, OBD-II, Engine Diagnostics, etc. 10 07-18-2007 09:26 PM
FS: OBDII diagnostic interface deskcom Classified Archive 0 12-09-2004 11:24 PM
@ Leddy OBDII gyro NeoCar Media Center 4 12-08-2004 06:43 PM
Pick my Programing class for me! Sonicxtacy02 Off Topic 14 11-23-2004 08:59 PM
1994 Saab 900 & OBDII Shark General Hardware Discussion 2 11-03-2003 08:58 AM


All times are GMT -5. The time now is 12:11 AM.


Sponsored Links
The MP3car.com Store

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright © 1999 - 2008 Mp3Car.com Inc.
Ad Management by RedTyger
Message Board Statistics