KWP1281 Measuring Blocks implementation

Support in english
passuff
Posts: 97
Joined: Wed 2. Feb 2011, 11:11

KWP1281 Measuring Blocks implementation

Post by passuff »

Hello
Im wondering how much work it would be to implement VAG Measuring Blocks reading. Would be the first System on the market that does combine external and internal signals in one data aquisition system. Im active in many chiptuning boards and peaple are searching for that for years... So come on, lets develope something together....
passuff
Posts: 97
Joined: Wed 2. Feb 2011, 11:11

Re: KWP1281 Measuring Blocks implementation

Post by passuff »

I think this one should help us.. At least the ones who speak german ;)

http://www.blafusel.de/obd/obd2_kw1281.html

This is the open surce community of wbh:
http://sourceforge.net/projects/wbh-diag/
User avatar
designer2k2
Administrator
Posts: 721
Joined: Mon 31. May 2010, 20:13
Location: Innsbruck
Contact:

Re: KWP1281 Measuring Blocks implementation

Post by designer2k2 »

Hello,

with the Mega attached (viewtopic.php?f=16&t=65) enough free programm space is avaiable...

There are some Arduino-OBD Projects, like: https://code.google.com/p/opengauge/wiki/OBDuino

The task would be to take their hardware / code and combine it with the MD code. Should be not a super difficult task ;)

Bofh is working on a version with binary output from the multidisplay what can be fed into some tuning software tools, as he is hacking his ECU and tuning it himself :)
itsmyfault...
passuff
Posts: 97
Joined: Wed 2. Feb 2011, 11:11

Re: KWP1281 Measuring Blocks implementation

Post by passuff »

OBD/OBDII is not what I am after. The KWP1281 for VAG is more than the normal open source PID. Its not only the aftertreatment measuring blocks, it's a whole bag full of measuring values.. Its only for VAG CArs.
The Project on Sourceforge uses an adapter where the KWP1281 (KWP2000 for cars after 2001) is already implemented in an atmega, so you can simply send some commands and get the values back. The atmega is not open source, so we cant implement this code. But maybe we find a way that we use both atmegas in one system.. What do you think? This would be the non plus ultra Data logger for all VAG people ;)

Maybe you could ask Florian (CEO) if he is interested in merging these projects?
passuff
Posts: 97
Joined: Wed 2. Feb 2011, 11:11

Re: KWP1281 Measuring Blocks implementation

Post by passuff »

This is the code of a little programm that makes you able to read measuring block. this little tool communicates directly with atmega in the interface. so in simple, we just need to take this code and implement it in our data logging software and use the bluetooth interface of wbhdiag.. its not so beautiful, but simple ;)

Code: Select all

; This program reads data from a WBH-Diag Pro VAG KW1281 protocol chip
; http://www.blafusel.de/misc/wbhdiagpro.html

Procedure.q Hex2Dec(Hex.s)
   Protected result.q, n, temp, pow.q=1
   hex=UCase(hex)
   For n=MemoryStringLength(@Hex)-1 To 0 Step -1
      temp=PeekC(@Hex+n*SizeOf(Character))-48
      If temp >= 17 And temp <= 22
         temp-7
      ElseIf temp < 0 Or temp > 9
         Break
      EndIf
      result+temp*pow
      pow*16
   Next
   ProcedureReturn result
EndProcedure


If OpenWindow(0, 100, 150, 260, 330, "WBH-Diag Pro Demo", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
; Das Fenster wurde erfolgreich geöffnet
      If CreateGadgetList(WindowID(0)) ; ermittelt die eindeutige WindowID und erstellt
        ; auf diesem Fenster die  neue Gadgetliste
        TextGadget (7, 20, 14, 30, 20, "Port:")
        StringGadget (2, 50, 10, 50, 20, "COM17")
        TextGadget (8, 120, 14, 40, 20, "Group:")
        StringGadget (5, 160, 10, 30, 20, "05")
        ButtonGadget (1, 20, 40, 80, 20, "Connect")
        ProgressBarGadget (3, 20, 70, 220, 20,0,100)
        TextGadget (4, 20, 100, 220, 140, "",#PB_Text_Border)
        TextGadget (6, 20,260,220,280, "", #PB_Text_Center)
        If LoadFont(0, "Arial", 30)
          SetGadgetFont(6, FontID(0))   ; geladenen Arial 16 Zeichensatz als neuen Standard festlegen
        EndIf

      EndIf    
      

  Repeat
    EventID.l = WaitWindowEvent()
    If EventID = #PB_Event_Gadget
      If EventGadget() = 1
        SetGadgetText(4, "")
        SetGadgetState(3, 0)
        
        
        MyCom.s = GetGadgetText(2)+": baud=19200 parity=N Data=8 stop=1"
        Hcom.l
        Hcom = ComOpen(MyCom,#HandShakeModeNone ,255,255)
        If Hcom 
          Car.s = " "
          Ausgabe.s = ""
          
          Repeat    ; wait for ID
            MyBuffer1.s = "ati" + Chr(13)
            ComWrite(Hcom,@MyBuffer1,Len(MyBuffer1))             ;Write the data
            Delay (100)
            While ComInputBufferCount(HCom) > 0
              If ComRead(Hcom,@Car,1)
                Ausgabe = Ausgabe + Car
              EndIf
            Wend
          Until FindString(Ausgabe,"WBH-Diag Pro",1)
 ;         MessageRequester("WBH-Diag Pro",Ausgabe)

          ; try to connect to ECU
          MyBuffer1.s = "atd01" + Chr(13)   ; send ATDnn
          ComWrite(Hcom,@MyBuffer1,Len(MyBuffer1))             ;Write the data

          Ausgabe = ""
          count.I = 0
          While ComInputBufferCount(HCom) = 0
            Delay (100)
            count = count+1
            If count = 101
              count=0
            EndIf
            SetGadgetState(3, count)
          Wend

          Repeat    ; wait for connect data
            While ComInputBufferCount(HCom) > 0
              If ComRead(Hcom,@Car,1)
                Ausgabe = Ausgabe + Car
                SetGadgetText(4, GetGadgetText(4)+Car)
              EndIf
            Wend
          Until FindString(Ausgabe,Chr(13)+">",1)   ; until ">" and a CR received
          SetGadgetText(4, GetGadgetText(4)+Chr(13))
          ;MessageRequester("WBH-Diag Pro","Data: " + Ausgabe)

          Repeat    ; endless unitl window close
            Delay (100)
            If Hcom=False   ; maybe connection lost
              Hcom = ComOpen(MyCom,#HandShakeModeNone ,255,255)
            EndIf

           EventID = WindowEvent()
            ; read group
            MyBuffer1.s = "08" + GetGadgetText(5) + Chr(13)   ; read group command 08 + which group
            ComWrite(Hcom,@MyBuffer1,Len(MyBuffer1))             ;Write the data
  
            Ausgabe = ""
            count.I = 0

            Repeat    ; wait for data
              While ComInputBufferCount(HCom) > 0
                If ComRead(Hcom,@Car,1)
                  Ausgabe = Ausgabe + Car
                  SetGadgetText(4, GetGadgetText(4)+Car)
                EndIf
              Wend
            Until FindString(Ausgabe,Chr(13)+">",1)   ; until ">" and a CR received
            
            ; find Block 07 (Km/h)
            pos.I = FindString(Ausgabe,"07",1)    ; search for a block starting with 07 (vehicle speed)
            If pos>0
              ;MessageRequester ("OK", Str(pos))
              ByteA.I = Hex2Dec(Mid (Ausgabe, pos+3, 2))    ; next two bytes are the speed data
              ByteB.I = Hex2Dec(Mid (Ausgabe, pos+6, 2))
              
              ;MessageRequester ("OK", Str(ByteA)+" "+Str(ByteB)+" " +Str(0.01*ByteA*ByteB))
              SetGadgetText (6, Str(0.01*ByteA*ByteB)+" km/h")    ;calculate speed
              SetGadgetText(4, "")
           EndIf
          Until EventID = #PB_Event_CloseWindow     ; endless until window close 


          ComClose(Hcom)
        Else
          MessageRequester ("Error", "Error during open "+GetGadgetText(2)+": Port")
        EndIf        

      
      EndIf
    EndIf
  Until EventID = #PB_Event_CloseWindow
Else; Fehler beim Öffnen des Fensters
  End
EndIf

End
User avatar
bofh
Posts: 629
Joined: Tue 1. Jun 2010, 19:01
Location: Saarland
Contact:

Re: KWP1281 Measuring Blocks implementation

Post by bofh »

I'm working on a hardware interface to connect a k-line to the multidisplay. :)
KWP1281 or OBD is not my primary target because the ecu which I connect (digifant I) does not have a KWP1281 protocol implementation. Instead i'm going to implement my own protocol to get just the data out of the digifant which I need (knock etc).

But it should be really easy to use the WBH-Diag Pro Controller to query data by KWP1281 protocol over the k-line interface (the Seeeduino Mega has enough serial interfaces so we could simply connect the WBH-Diag Pro AVR to one of them).
The WBH Diag Conroller Pro http://www.obd2-shop.eu/wbhdiag-controller-p-130.html handles the complete KWP1281 protocol and has a really fair price (21 €).
passuff
Posts: 97
Joined: Wed 2. Feb 2011, 11:11

Re: KWP1281 Measuring Blocks implementation

Post by passuff »

your K line interface sounds very interesting for another project. I want to setup a g60 turbo so this would be very very helpful!!
keep in touch..
User avatar
bofh
Posts: 629
Joined: Tue 1. Jun 2010, 19:01
Location: Saarland
Contact:

Re: KWP1281 Measuring Blocks implementation

Post by bofh »

I ordered some K-Line / TTL translation ICs ( ST L9636 http://www.st.com/internet/automotive/product/75181.jsp ) and SOIC / DIP adapter sockets at RS Components. Next few weeks will be exciting. :D
User avatar
designer2k2
Administrator
Posts: 721
Joined: Mon 31. May 2010, 20:13
Location: Innsbruck
Contact:

Re: KWP1281 Measuring Blocks implementation

Post by designer2k2 »

oh i will build this also in my car´s, moooore data 8-)
itsmyfault...
passuff
Posts: 97
Joined: Wed 2. Feb 2011, 11:11

Re: KWP1281 Measuring Blocks implementation

Post by passuff »

I ordered some K-Line / TTL translation ICs ( ST L9636 http://www.st.com/internet/automotive/product/75181.jsp ) and SOIC / DIP adapter sockets at RS Components. Next few weeks will be exciting. :D
Some news?
Post Reply