Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PID json file for MiniCooperSE electric #4

Merged
merged 11 commits into from
Jan 9, 2022

Conversation

remmie1972
Copy link
Contributor

The protocol "B" is unsure, could be 6 or 7 instead. "B" is entered because of the AT command "ATSPB" in the initialisation commands

The equations Letters are also unsure : example : received data for 22DDBC (soc) to module 607 is : 607F1100962DDBC01A6607F12103E50091FFFF
that is interpreted by me as :
607 F1 10 09 62 DD BC 01 A6 607 F1 21 03 E5 00 91 FF FF
? A B C D E F G H ? I J K L M N O P
the actual SOC is found in the 01 A6 pair. In my interpretation that is G + H : 01A6 in hex equals 422 in decimal. Divide by 10 to get the SOC : 42.2%
therefore the equation is (G*256+h)0.1
if the 01 A6 pair is actually byte A and B the equation must be altered to (A
256+B)*0.1

The protocol "B" is unsure, could be 6 or 7 instead. "B" is entered because of the AT command "ATSPB" in the initialisation commands

The equations Letters are also unsure : example : received data for 22DDBC (soc) to module 607 is : 607F1100962DDBC01A6607F12103E50091FFFF 
that is interpreted by me as :
607 F1 10 09 62 DD BC 01 A6 607 F1 21 03 E5 00 91 FF FF
?      A  B  C    D   E    F    G   H    ?     I    J   K   L   M   N  O  P
the actual SOC is found in the 01 A6 pair. In my interpretation that is G + H : 01A6 in hex equals 422 in decimal. Divide by 10 to get the SOC : 42.2%
therefore the equation is (G*256+h)*0.1
if the 01 A6 pair is actually byte A and B the equation must be altered to (A*256+B)*0.1
Added PID json file for MiniCooperSE electric
@SamuelBrucksch
Copy link
Collaborator

Can you provide sample data for all the commands? Maybe also with the actual value. Then i can add some tests for these pids. We already have tests for the other vehicles to make sure we do not break anything in the commands. If we have real world data it makes it easier to verify the pid list before publishing it.

@SamuelBrucksch
Copy link
Collaborator

SamuelBrucksch commented Jan 8, 2022

As for the position chars...
607 F1 10 09 62DDBC 01 A6 60 7F 12 10 3E 50 09 1F FFF
01 -> A, A6->B, 60->C, ...

The data after the command is the data which is required.

Will already write some tests to see if our current parser can deal with that format, maybe you can do some adjustments to the other commands meanwhile and provide some data so i can enhance the tests later on.

@SamuelBrucksch
Copy link
Collaborator

SamuelBrucksch commented Jan 8, 2022

Ok i can read 42.2% SoC from the supplied data above with adjusted chars to A and B. So it seems once the chars are corrected, we can add this fairly fast. Requires a new app version though as i needed to do some adjustments to the OBD response parser.

@remmie1972
Copy link
Contributor Author

here some more commands and responses
sendATCommand("22DD68"); // Battery Voltage
Example Response is : 607F10562DD688AF8

  1. relevant data = 8AF8 (from position 13, length 4 bytes) = Battery Voltage * 100 => 0x8AF8 HEX = 35576 dec = 355,76 Volt = battery Voltage

so the voltage equation should be INT16(A:B)*0.01

@remmie1972
Copy link
Contributor Author

This one is a little more complicated i think because the reponse containss multiple 607 (ecu number). I think I remember that those responses were actually on a separate line

sendATCommand("226335"); // SOH State Of Health
Example response is : 607F110076263350000607F1210064FFFFFFFF

so actually :
607F110076263350000
607F1210064FFFFFFFF

  1. relevant data = 0064 (from position 26, length 4 bytes) = State of Health (SOH) in percent => 0x0064 HEX = 100 dec = 100% SOH

I don't have a clue what equation letter to give to the "00" and "64" bytes as they are on the second line. Perhaps C & D ??

Co-authored-by: Samuel Brucksch <SamuelBrucksch@users.noreply.github.com>
@SamuelBrucksch
Copy link
Collaborator

That one is a multi frame response i think. Multi frame messages normally have len 10

607 F1 10 07 626335 00 00
                    A  B
607 F1 21 00 64 FF FF FF FF
          C  D

@remmie1972
Copy link
Contributor Author

remmie1972 commented Jan 8, 2022

Ah thought so,
I have another for the battery tempratures there are 3 temperatures in there

sendATCommand("22DDC0"); // Battery temperatures (min, max, avg)

Example response is : 607 F1 10 09 62 DD C0 09 C4 607 F1 21 0C 1C 0A F4 FF FF
			  		     A  B           C  D  E  F  G  H
  1. relevant data 1 = 09C4 (from position 15, length 4 bytes) = Battery lowest temperature in Celsius => 0x09C4 HEX = 2500 dec = 25,00 degrees Celcius. The equation would be : signed(A)*256+B
  2. relevant data 2 = 0C1C (from position 26, length 4 bytes) = Battery highest temperature in Celsius => 0x0C1C HEX = 3100 dec = 31,00 degrees Celcius The equation would be : signed(C)*256+D
  3. relevant data 3 = 0AF4 (from position 30, length 4 bytes) = Battery middle or average temperature in Celsius => 0x0AF4 HEX = 2804 dec = 28,04 degrees Celcius. The equation would be : signed(E)*256+F

@SamuelBrucksch
Copy link
Collaborator

Looking good, i now added a custom protocolB as it seems to be more close to 7 but is a bit different. So we can leave it at protocol B.

@SamuelBrucksch
Copy link
Collaborator

SamuelBrucksch commented Jan 8, 2022

Do you also have a value for current? Maybe connect a charger, then you should get a stable negative value, that should be easy to confirm if it is correct (for example on 11kW and 355V you should see roughly -30A.

@remmie1972
Copy link
Contributor Author

remmie1972 commented Jan 8, 2022

For battery current :

sendATCommand("22DD69"); // Battery Current

Example Response is : 607 F1 10 07 62 DD 69 00 00 607 F1 21 01 1A FF FF FF FF
			                    A  B            C  D  E  F  G  H

Relevant data = 011A (from position 26, length 4 bytes) = Battery Current * 100 => 0x011A HEX = 282 dec = 2,82 Amps

I will look for negative values but i think that the MSB of A is the plus or minus sign. Then the equation should be something like :
(signed(C)*256 + D)*0.01

@SamuelBrucksch
Copy link
Collaborator

SamuelBrucksch commented Jan 8, 2022

Do you by change also have car speed? We use that to estimate if the car is charging, when speed is 0 and current is negative. Alternatively a boolean flag for is_charging would also work.

@remmie1972
Copy link
Contributor Author

Do you by change also have car speed? We use that to estimate if the car is charging, when speed is 0 and current is negative. Alternatively a boolean flag for is_charging would also work.

Yes, but that is on a different ecu : 660 which is the KOMBI or instrument cluster

the command to send is : 22D107

The response is 660F10562D1070000 and the speed is in 0.1 kph resolution
So I think the equation is : INT16(A:B)*0.1

value min is 0 value max is 154, the mini doesn't go faster ;)

Getting the is_charging parameter by speed = 0 and current is negative is also how i do it :) But be carefull : when coming to a stop for a trafic light with regen (= charging) and eventually speed = 0 as well. So you need at least 2 consecutive samples of speed = 0 and current < 0 to get a more reliable is_charging = true

@SamuelBrucksch
Copy link
Collaborator

Ok let's leave speed for now, we also have an estimation based on GPS speed. We can always enhance the commands later on if everything works. So now i have everything tested which is available here. Thanks for the data. I'll add this to the backend soon and then you can test it.

Copy link
Contributor Author

@remmie1972 remmie1972 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you prefer division by 100 or multiplication by 0.01 ? I guess it doesn't really matter for the parser :) but now there are some values *0.1 and some with /100
That messes with my OCD ;)

@remmie1972
Copy link
Contributor Author

Ok let's leave speed for now, we also have an estimation based on GPS speed. We can always enhance the commands later on if everything works. So now i have everything tested which is available here. Thanks for the data. I'll add this to the backend soon and then you can test it.

awesome, thanks so much. Looking forward to testing. And if you need more values, PID etc just let me know. I'll setup an Arduino sketch where I can type in commands and see the responses in the serial monitor so I can record them, That makes it easier to test different commands

@SamuelBrucksch
Copy link
Collaborator

do you prefer division by 100 or multiplication by 0.01

I don't care, choose whatever you want

@SamuelBrucksch
Copy link
Collaborator

Please send a mail to samuel@iternio.com with your apple ID so i can invite you to our test version. Also include the mail associated to your ABRP account so i can add the tester role to your account so you can test it, when it tis available.

@remmie1972
Copy link
Contributor Author

I pulled some values of the current while idle (not charging) and while charging :

command = 22DD69

response while idle (discharging the battery)
607 F1 10 07 62 DD 69 FF FF
607 F1 21 FF 98 FF FF FF F

I think the current data is now FF 98 (*0.1 Amps) = -103 = -1.03 Amps

while charging @ 1.8 kW (and still idling)
607 F1 03 7F 22 78
607 F1 10 07 62 DD 69 00 00
607 F1 21 01 38 FF FF FF

now the current data is 00 00 01 38 = 312 = 3.12 Amps @ 400 Volt = 1.2 kW which seems correct

So the current is positive while charging and negative while discharging the battery. So maybe the equation needs a minus sign in front. I don't exactly know how ABRP sees positive and negative current.

Also the values are separated by spaces between the bytes. I don't know if that affects anything.

I'll do a test where I issue all commands multiple times and log the responses. Maybe that helps in bench testing the parsing.

@remmie1972
Copy link
Contributor Author

Here is a complete dataset of the data that is now available in the json, I follow every step in the init section and now the output is a little different, no spaces and no ecu number any more. I guess some ATcommands you changed have done that :)

I entered the 4 datacommands 5 times each and the responses are below :

Attempting to connect to VGATE
Connected to VGATE
ATZ
ELM327 v2.2>
ATD
ATDOK>
ATE0
ATE0OK>
ATS0
OK>
ATAL
OK>
ATPBE101
OK>
ATSPB
OK>
ATBI
OK>
ATSH6F1
OK>
ATAT0
OK>
ATSTFF
OK>
ATCRA607
OK>
ATCEA07
OK>
ATFCSH6F1
OK>
ATFCSD07300800
OK>
ATFCSM1
OK>

22DDBC
0090:62DDBC03E81:03D4007DFFFF>
22DDBC
7F22780090:62DDBC03E81:03D4007DFFFF>
22DDBC
7F22780090:62DDBC03E81:03D4007DFFFF>
22DDBC
7F22780090:62DDBC03E81:03D4007DFFFF>
22DDBC
7F22780090:62DDBC03E81:03D4007DFFFF>

22DD68
7F2278
62DD689B9D>
22DD68
62DD689B9D>
22DD68
7F227862DD689B9C>
22DD68
7F227862DD689B9B>
22DD68
7F227862DD689B9B>

22DD69
7F22780070:62DD69FFFF1:FFA1FFFFFFFF>
22DD69
0070:62DD69FFFF1:FFA0FFFFFFFF>
22DD69
7F22780070:62DD69FFFF1:FFA0FFFFFFFF>
22DD69
7F22780070:62DD69FFFF1:FFA1FFFFFFFF>
22DD69
7F22780070:62DD69FFFF1:FFA1FFFFFFFF>

226335
0070:62633500001:0063FFFFFFFF>
226335
7F22780070:62633500001:0063FFFFFFFF>
226335
7F22780070:62633500001:0063FFFFFFFF>
226335
0070:62633500001:0063FFFFFFFF>
226335
7F22780070:62633500001:0063FFFFFFFF>

@SamuelBrucksch
Copy link
Collaborator

Yes charging needs to be negative and driving positive.

charging needs to be negative and driving positive
Setting ATSTFF to ATST0F. ST is the timeout command. FF is a timeout period of 1024 msec which is far too long, the message comes almost instantly. setting the value to 0F instead of FF brings the timeout down to 64 msec which works fine (tested in my own iOs app). ATST00 also works but is slower. ATST01 (4 msec timeout is too short, no data is received)
@SamuelBrucksch
Copy link
Collaborator

SamuelBrucksch commented Jan 9, 2022

Hi @remmie1972
just looked at your last data command set... The responses with a colon indicate, that you enabled auto formatting of can messages:
7F22780070:62DD69FFFF1:FFA1FFFFFFFF>

Did you set ATCAF1 somewhere before when requesting the data? Could you please try the same command list with ATCAF0 as additional init command?

@SamuelBrucksch
Copy link
Collaborator

Ok nevermind, i just implemented that notation as well...

@SamuelBrucksch
Copy link
Collaborator

Still i'm wondering, sometimes you get different results for the same query:

22DD68
62DD689B9D>
22DD68
7F227862DD689B9C>

Do you know why it sometimes comes with 7F2278 and sometimes not?

@SamuelBrucksch
Copy link
Collaborator

And also that format is again different from what you initially showed:

607 F1 10 09 62DDBC 01A6 607 F1 21 03E50091FFFF

So this is a bit confusing now. Why are there so many different representations of the same data? Normally if the init sequence is always the same, the incoming data should also look the same.

@remmie1972
Copy link
Contributor Author

Hi Samuel, the colons appear when I do not use ATH1 (headers on) in the init commands.
ATCAF0 just leads to "NO DATA". with ATCAF1 the data appears again.

here's same examples switching between ATCAF0 / ATCAF1 (auto formatting ?) and ATH0 / ATH1 (headers on/off) and ATS0 / ATS1 (spaces on/off)

`ATZ

ELM327 v2.2

ATD
ATD

OK

ATE0
ATE0
OK

ATS0
OK

ATCAF0
OK

ATAL
OK

ATPBE101
OK

ATSPB
OK

ATBI
OK

ATSH6F1
OK

ATAT0
OK

ATST0F
OK

ATCRA607
OK

ATCEA07
OK

ATFCSH6F1
OK

ATFCSD07300800
OK

ATFCSM1
OK

22DDBC
NO DATA

ATCAF1
OK

22DDBC
009
0:62DDBC01E8
1:03D40087FFFF

ATH1
OK

22DDBC
607F1037F2278
607F1100962DDBC01E8
607F12103D40087FFFF

ATH0
OK

22DDBC
7F2278
009
0:62DDBC01E8
1:03D40087FFFF

ATCAF0
OK

22DDBC
NO DATA

ATCAF1
OK

22DDBC
7F2278
009
0:62DDBC01E8
1:03D40087FFFF

ATH1
OK

22DDBC
607F1100962DDBC01E8
607F12103D40087FFFF

ATs1
OK

22DDBC
607 F1 10 09 62 DD BC 01 E8
607 F1 21 03 D4 00 87 FF FF `

@remmie1972
Copy link
Contributor Author

And also that format is again different from what you initially showed:

607 F1 10 09 62DDBC 01A6 607 F1 21 03E50091FFFF

So this is a bit confusing now. Why are there so many different representations of the same data? Normally if the init sequence is always the same, the incoming data should also look the same.

sorry for the confusion, that was me playing around with some of the settings. This one is with headers on (ATH1) and spaces on (ATS1).

@SamuelBrucksch
Copy link
Collaborator

Can we somehow get rid of these additional messages:

22DDBC
7F2278
009
0:62DDBC01E8
1:03D40087FFFF

so that only the actual data bytes show up? (line 3 and 4 of the response)

@remmie1972
Copy link
Contributor Author

Do you prefer the output with colons (as the init sequence is now) or with the headers so the 607 ecu number is in the data?
That way we can settle on a fixed init command structure and just go from there. Otherwise we are confusing one another.

@SamuelBrucksch
Copy link
Collaborator

I don't care if the ECU is there or not, we don't use it. But it has to be consistent. We only use the ECU on multi frame messages that are not auto formatted, but with auto formatting we do not need it.

What is confusing for me is, that even on single frames we get some data before, that is unexpected for me (at least i did not see it on a different car)

22DD68
62DD689B9D>
22DD68
7F227862DD689B9C>

The same command should always return the same structure.

@remmie1972
Copy link
Contributor Author

Can we somehow get rid of these additional messages:

22DDBC
7F2278
009
0:62DDBC01E8
1:03D40087FFFF

so that only the actual data bytes show up? (line 3 and 4 of the response)

The 22DDBC is the command I typed and the response is the 7F2278 009 0:62DDBC01EB 1:03D40087FFFF

I have no idea why the 7F2278 and the 009 are there.

I don't care if the ECU is there or not, we don't use it. But it has to be consistent. We only use the ECU on multi frame messages that are not auto formatted, but with auto formatting we do not need it.

What is confusing for me is, that even on single frames we get some data before, that is unexpected for me (at least i did not see it on a different car)

22DD68
62DD689B9D>
22DD68
7F227862DD689B9C>

The same command should always return the same structure.

I agree but it appears that BMW does something strange there. I will use the init structure as it is now and then issue the same command for lets say 20 times and maybe we can see a pattern. The data itself is the same but in the second response 7F2278 is added in front.

@SamuelBrucksch
Copy link
Collaborator

Ok lets try this:

  1. response should be in one line and auto formated
  2. don't show headers
  3. spaces off

I think i can deal with the additional data in front, if i know the rest of the data is always the same format

@remmie1972
Copy link
Contributor Author

remmie1972 commented Jan 9, 2022

Ok lets try this:

  1. response should be in one line and auto formated
  2. don't show headers
  3. spaces off

I think i can deal with the additional data in front, if i know the rest of the data is always the same format

OK I think that is the following log. I noticed that when copying the data from the Arduino serial monitor to the GitHub comment windows the data gets additional line feeds. I'll attach a screenshot of the data seen on the serial monitor. I can see no distinct patter as to when the additional data in front appears and when not.
Perhaps you can reference the "0:" and the "1:" pairs and parse the data from there. That part seems to be very consistent

the 22DDBC command is the command typed by me :

Schermafbeelding 2022-01-09 om 15 53 10

@SamuelBrucksch
Copy link
Collaborator

SamuelBrucksch commented Jan 9, 2022

Yes i think that looks doable. Can you send me the whole command chain including init commands and everything again please? So i use the correct init sequence for our obd command list as well and can adjust the tests.

You can also send the responses as mail if the formatting is off on github.

@remmie1972
Copy link
Contributor Author

I also noticed this morning that in the ABRP app the OBDBLE option for the Mini Cooper SE was active so I tried it. I could select the iOS-vlink module. and it gave me 3 green ok signs. the last one took a few seconds. However the data was not yet being imported. Now I guess I know why :) LOL.

@remmie1972
Copy link
Contributor Author

remmie1972 commented Jan 9, 2022

Yes i think that looks doable. Can you send me the whole command chain including init commands and everything again please? So i use the correct init sequence for our obd command list as well and can adjust the tests.

You can also send the responses as mail if the formatting is off on github.

For reference on GitHub, these are 3 screenshots with :

  1. init sequence
  2. multiple 22DDBC commands
  3. multiple 22DD68 commands

Schermafbeelding 2022-01-09 om 16 03 17

Schermafbeelding 2022-01-09 om 15 53 10

Schermafbeelding 2022-01-09 om 16 03 32

@SamuelBrucksch SamuelBrucksch merged commit e36119e into iternio:main Jan 9, 2022
@SamuelBrucksch
Copy link
Collaborator

Oh i forgot, we need to add attributions. Check https://github.com/iternio/ev-obd-pids/blob/main/jaguar/README.md for reference. You can add a README.md in the mini directory.

@remmie1972
Copy link
Contributor Author

@SamuelBrucksch

Thanks for implementing this for the Mini Cooper SE !
These PID's would also work for the BMW i3 and i3s. I don't know about other BMW's but the i3(s) has to work.
I don't have an i3 to test but maybe an announcement in the forum for i3 testers can help.

Would that need a separate pull request from me or can you just copy the page to a BMW section. Or do you rather want to wait until the test with the Mini is done ? There are still some values that can be discovered :

  • is_charging, is_dcfc, is_parked
  • capacity (I have a PID for amp hours which is now reported as 95.1 amp hours, so multiply that by average cell voltage of 3.65 Volt and 96 cells in series gives 33.3 kWh which is gross capacity. usable capacity is roughly 15% less.
  • external temp. I have that PID (but is on a different module, should be easy to test)
  • vehicle indicated range. I have that PID as well although it is wildly conservative
  • odometer, don't know about that one.

@SamuelBrucksch
Copy link
Collaborator

We have the most important values, so we can work on the others later on if it is confirmed to be working. Internally we can map one file to multiple cars, so no need to copy over to other directories.

@SamuelBrucksch
Copy link
Collaborator

SamuelBrucksch commented Jan 10, 2022

@remmie1972

I think i know where those additional bytes come from. Please check the ELM327 spec:
https://www.elmelectronics.com/wp-content/uploads/2016/07/ELM327DS.pdf
And search for AT FC SM 1, it enables a custom message that is returned on pid commands, based on what is set on AT FC SH and AT FC SD, which are both used in the init commands here.

So i think if we skip the AT FC SM 1 we should not see those additional bytes. Can you please remove that command and see, what data is returned?

You also have a command in there ATFCCSM1, which seems to be a duplicate of the above one with a typo, the return is ? so it is not used, so you can remove that one as well.

@remmie1972
Copy link
Contributor Author

Hi Samuel,

Unfortunately that does not work, it actually makes things worse.
I see no change in the behavior in receiving messages (sometimes with no information before the frames and most of the times with) but without the FC SM 1 command the multiframe messages only display the first frame with the “0:” the second frame with the “1:” does not show at all.

I mistyped the ATFCCSM1. It is not an automated sequence. I just type one after the other and see what happens.

@SamuelBrucksch
Copy link
Collaborator

Ok...well it works now anyways, just wanted to avoid additional data to prevent possible bugs, but let's test this first... Will send you a mail when the test version is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants