No announcement yet.

OBDII for ELM323

  • Filter
  • Time
  • Show
Clear All
new posts

  • OBDII for ELM323

    Maybe this time I can contribute a bit for my favorite frontend. Using Erorus's VB6 class link I was able to read OBDII data and compute some interesting values. With this implemented one can calculate MPG, HP, and Torque. I was thinking of implementing more stuff but there were some limitations.

    The limitations were the fact that OBDII communication is slow. Fastest I was able to retreive the data was around 300ms/sample. To compute MPG HP and Torque, the least information I needed was MAF, VSS, and RPM. Each data can be sampled every 900ms with current implementation. I tried 200ms/sample but this failed in long run. Maybe 250ms/sample will work... I just haven't tried yet.

    To work around this limitation I had to create the fake data(interpolation) to fill in the middle. The sampled data looked kind of like this in time (ms)..

    0____300____600____900___1200___1500___1800___2100 ___2400___2700___3000
    RPM________________RPM_________________RPM________ __________RPM________
    _____VSS_________________VSS__________________VSS_ _________________VSS
    ____________MAF_________________MAF_______________ ___MAF_______________

    Computations like MPG requires more than one parameter and it expects instantaneous values rather than delayed value. Also the fact that 300ms is quite a bit of time when it comes to accuracy of the computation (even worse when calculating HP since it requires difference of speed which is 900ms delay) forced me into doing some interpolations.

    So I worked on interpolation for a while. The attached code will collect each data in a size 8 circular FIFO. Using those 8 values interpolated values are filled in with 0.1 second resolution.

    One method I used for interpolation was using low pass filter to filter out the high frequency data (or non existing data). This generates awesome graphs, with smooth transitions. However, there was a limit for this too where data has to be band limited.... but alot of time people drive in very linear form (crusing at similar speeds... very linear which is outside of band low pass filter can be designed...). I tried this for weeks and didn't get satisfying result. Acceleration and breaking generated with low pass filter implementation worked out great, but any other times it introduced alot of ringing effects that threw off the computations.

    So I tried to use above method with piecewise linear interpolation. Anytime low pass filter is outside of two points from previous point to rest of the interpolation points to be linear line increment and decrementing constantly. However this still had quite a bit of errors in computations.... showing something like 1000HP... yay!!

    In the end I gave a simple piecewise linear interpolation a chance. Although the graphs didn't look so great, the calculations were surprisingly close to expected values. My WRX usually does 21 MPG and Max HPs are around 200s. I saw around 23 MPG for average value and 215 for my HP when I floored. There are some errors but I figured this is close enough for what I wanted.

    Maybe later I will try to add Best 0 to 60 time...

    I was able to hack the rr source code and display the Instant MPG, Average MPG, Instant Horse Power, and Instant Torque in numeric values. However due to lack of time and lack of artistic talent I only tried very few. I thought many talented people in this forum can make this look much nicer.. =)

    Here are some global values I defined for this. I made it programmable from rr.ini... but depends on how you implement this.

    obdiitimer : Interval between each data sample in milliseconds (e.g 300)
    obdiisamples : # of samples (e.g for now it needs to be 3, RPM, VSS, MAF)
    obdiiport : COMM port number for OBDII device.
    obdiimode : Interpolation method (0 for low pass filter with piecewise linear interpolation and 1 for pure linear interpolation. 1 is recommened.)
    obdiiweight : Your vehicle weight in pound. (I used car spec's weight + driver's weight + gas weight (tank size in gallons * 6.15 * some constant).)
    obdiivolume : Uses OBD VSS value instead of GPS speed value for speed attenuated volume control.

    For now I will attach the OBDII code only. Guino do you think this will be worth while to put it in to your code? I guess I can try to diff the codes. I will think of something. My code changes include OBDII integration, "Gain" speed attenuated volume control tweak, and inipath hack. Pick and choose what you like. =)

    I hope someone will find this useful.

    Attached Files

  • #2
    Attached is diff file showing what I have edited to get things working. This includes few trial fixes for "gain" mode of speed attenuation volume control and programmable inipath. I hope that was all of them.... There was an update on roadrunner source since I started working on this so I had to manually filter out things I didn't update.

    If you are using Digital FX and in the following folders,
    {Roadrunner path}\skins\DigitalFX 2.0\Menus\AnalogClock
    {Roadrunner path}\skins\DigitalFX 2.0\Menus\DigitalClock

    can be edited to display some calculated values.

    Comment out following lines.
    /L,516,4,71,25,255,255,255,16,"Arial","TEMP2","left "
    /L,408,4,101,25,255,255,255,16,"Arial","=Computer:" ,"right"
    /L,212,4,89,25,255,255,255,16,"Arial","=Interior:", "right"
    /L,311,4,87,25,255,255,255,16,"Arial","TEMP1","left "

    and add these.

    L,311,4,87,10,255,255,255,16,"Arial","AVGMPG","rig ht"
    L,428,4,100,10,255,255,255,16,"Arial","=Inst MPG:","right"
    L,536,4,80,10,255,255,255,16,"Arial","INSMPG","rig ht"
    L,3,502,100,10,255,255,255,16,"Arial","=Inst HP:","right"
    L,103,502,80,10,255,255,255,16,"Arial","INSHP","ri ght"
    L,567,502,150,10,255,255,255,16,"Arial","=Inst Torque:","right"
    L,717,502,80,10,255,255,255,16,"Arial","INSTQ","ri ght"

    I'll try out the diff file tomorrow to make sure it works with newer roadrunner...

    Attached Files


    • #3
      I'd love to see something like this integrated in RR. I have a homemade ELM327 based scan tool that is just dying to be connected to my Six. I have not used it so far because all the available software is either not touchscreen friendly is does not embed easily with RR
      The road is long but we are getting there.


      • #4
        Here are better version of diff files. I've separate them in to three files so you should be able to pick and choose the features you want to update. The original source code is based on current newest road runner (10/26/07).

        obddiff.txt is codes I've added in to original code to get OBD working.
        speedattdiff.txt contains modification to use speed attenuation with gain mode.
        inidiff.txt contains my attempt to have separate directory for ini and any config files. This may be useful for any read only drive RR installations. However, I haven't really tested any.

        To compile the RR code you will need to add the elm class and the obd form. Also if I remember right you will need mscomm.dll also.

        Attached Files


        • #5
          Thanks for the nice addition, I would like to test it.

          Originally posted by hjcho616 View Post
          The original source code is based on current newest road runner (10/26/07).
          But the latest roadrunner release dated 11/04/07 afaik. if you downloaded the source lately, probably it's the newest. Website says it's (10/26/07) but files are up to date.



          • #6
            I've downloaded it couple days ago. I hope it is the same one you will be using.