Toyota GR86, 86, FR-S and Subaru BRZ Forum & Owners Community - FT86CLUB

Toyota GR86, 86, FR-S and Subaru BRZ Forum & Owners Community - FT86CLUB (https://www.ft86club.com/forums/index.php)
-   Software Tuning (https://www.ft86club.com/forums/forumdisplay.php?f=88)
-   -   Feasibility of figuring out current gear, clutch pos over CAN/OBD2? (https://www.ft86club.com/forums/showthread.php?t=141330)

Stu L Tissimus 07-07-2020 09:10 PM

Feasibility of figuring out current gear, clutch pos over CAN/OBD2?
 
(EDIT: RESOLVED)
Hi there! First off, a disclaimer - this is not exactly about tuning, but there's enough overlap that I think this is the best forum to ask about it in.


Okay - so as a little hobbyist project, I want to build a cheap, stupid device that will show me "if you downshift from CURRENT_GEAR to CURRENT_GEAR-1, what should your target RPM be?" Basically, a little helper for rev-matching.


Current plan is:
- ELM327 OBD2 reader communicating over BT to...
- an ESP32 (or some such hobbyist chip) displaying on a cheap display



The logic would be pretty simple on the ESP32. A quick and dirty pseudocode representation:


Code:

def main():
    while True:
        if(was previously in gear, and we just clutched out):
            desired_downshift_rpm = calculate_downshift_rpm(last_observed_gear, last_observed_rpm)
            update_display(desired_downshift_rpm)
            # probably some timeout
        last_observed_gear = OBD2.read_gear()
        last_observed_rpm = OBD2.read_rpm()

def calculate_downshift_rpm(
    last_observed_gear: int,
    last_observed_rpm: int,
    gear_ratios: Dict[int, float],
):
    last_ratio = gear_ratios[last_observed_gear]
    next_ratio = gear_ratios[last_observed_gear - 1 /* excluding first gear */]
    return last_observed_rpm / last_ratio * next_ratio
   
   
def test():
    # Going from 1000rpm @ 2nd -> 1600 rpm @ 1st

    assert calculate_downshift_rpm(
        last_observed_gear=2,
        last_observed_rpm=1000,
        gear_ratios=hardcoded_gear_ratios
    ) roughly_equals 1657

hardcoded_gear_ratios = {
    1: 3.626,
    2: 2.188,
    # etc etc
    5: 1.000,
    6: 0.767,
}

So, finally, here's my question.
I've messed around with OBD2 readers on my phone, and it can definitely read RPM (and the latency is surprisingly not bad), but I haven't seen if there are PIDs for:
- what's my current gear? (manual transmission if it counts)
- what's the clutch pedal position?

Compelica 07-08-2020 12:13 AM

Techstream has a number of information that is shown, however I'm not sure whether those are communicated via OBD2 PIDs or via some other means. I've did some tinkering in the past by sniffing the communication between the ECU and Techstream to identify the PID and replaying the transmits and responses in hex values to understand how they are derived.

I'm sure it's possible on our cars (it was a long time ago, I've lost all the software) but if those values you're looking for are available in Techstream, chances that you would be able to pull it from your OBD2 reader.

churchx 07-08-2020 02:04 AM

As there is no sensor (except maybe reverse, as rear camera & backup lights switch on immediately when putting in reverse gear) for gear position and even for car dash gear indication itself position gets calculated only after gear switch and letting out clutch pedal (and it gets calculated wrong for guys with different FD, if they don't also adjust calculation ratios in ecu tune), with lag, from engine rpm readings & wheel speed sensors, and even for clutch IIRC there was just sensor if clutch pedal is on or off (for keyless start sake i guess), i don't think you'll be able to get needed readings from twins stock sensors.
Maybe some custom aftermarket sensors can be added to clutch and gearbox, but have no info on those.

steve99 07-08-2020 08:18 AM

As above the ECU calcualtes the gear from rpm and speed data. There is no gear sensor.


Note you can get auto blip rev matching on these cars with ecutek tunes, ie it blips throttle for you on downshift, and full throttle upshift, all in software

Yoshoobaroo 07-08-2020 10:04 AM

You have speed, RPM, and clutch position in OBD. That should be all you need to figure out the current gear.

Oh and this :bonk::


Quote:

First Gear 3.626
Second Gear 2.188
Third Gear 1.541
Fourth Gear 1.213
Fifth Gear 1.000
Sixth Gear 0.767

Reverse 3.437

Final Drive 4.100
ref: https://www.caranddriver.com/subaru/...rz_2013/350874

Stu L Tissimus 07-08-2020 11:56 AM

Thanks guys!


I recognize the Ecutek can auto-blip for me, but I'm doing this more for the fun of building it :)

Yoshoobaroo 07-08-2020 01:01 PM

Quote:

Originally Posted by Stu L Tissimus (Post 3347493)
Thanks guys!


I recognize the Ecutek can auto-blip for me, but I'm doing this more for the fun of building it :)

I really like the idea!

7c8 07-08-2020 06:50 PM

You won't be able to request the calculated gear over OBD2, but you can access it under the regular CAN bus:

ID: 0x140
Offset: 6 bytes
Length: 4 bits
Mask: 0x0F (i.e. you only care about the 4 least significant bits on that byte)

These 4 bits match the gear display, and reads 7 (0b0111) when nothing is displayed, between shifts, neutral, etc..

Obviously you could compare vehicle speed vs. engine speed, which would be faster I think. You can also get those off the CAN bus, which is quicker and less intrusive than over OBD2.

Vehicle speed:
ID: 0x0D1
Offset: 0 bytes
Length: 2 bytes (little endian)
Multiplier: 0.05747 for kph, 0.3571019137 for mph

Engine speed:
ID: 0x140
Offset: 2 bytes
Length: 2 bytes (little endian)
Mask: 0x3FFF

EDIT: You can see how well comparing vehicle speed vs. engine speed works here: https://streamable.com/sqk9h8
It's much faster than using the gear data on the CAN bus because you don't necessarily have to wait for clutch out like the ECU does in the car.

Stu L Tissimus 07-17-2020 08:11 PM

(I finished a super hacky quick-and-dirty version here!)

Yoshoobaroo 07-17-2020 08:21 PM

Sweet!

pallen 07-22-2020 12:15 PM

Somewhat related, I've noticed the gear indicator on the gauge cluster sometimes isn't there and occasionally is even wrong - it may say 4 when I'm in 5th. Is this normal? Its not like I actually need this, but I found it odd.

Dzmitry 07-23-2020 09:18 AM

Quote:

Originally Posted by pallen (Post 3351198)
Somewhat related, I've noticed the gear indicator on the gauge cluster sometimes isn't there and occasionally is even wrong - it may say 4 when I'm in 5th. Is this normal? Its not like I actually need this, but I found it odd.

If you've changed wheel diameter from stock or changed the FD then this would be your issue.

pallen 07-23-2020 09:22 AM

Quote:

Originally Posted by Dzmitry (Post 3351417)
If you've changed wheel diameter from stock or changed the FD then this would be your issue.

I have the stock 17" wheels.
What is FD? I feel like I know that abbreviation, but its escaping me at the moment...

Dzmitry 07-23-2020 09:28 AM

Quote:

Originally Posted by pallen (Post 3351418)
I have the stock 17" wheels.
What is FD? I feel like I know that abbreviation, but its escaping me at the moment...

Final drive. You did buy the vehicle used, do you happen to know if the seller ever replaced the FD?


All times are GMT -4. The time now is 10:37 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
User Alert System provided by Advanced User Tagging v3.3.0 (Lite) - vBulletin Mods & Addons Copyright © 2026 DragonByte Technologies Ltd.


Garage vBulletin Plugins by Drive Thru Online, Inc.