follow ft86club on our blog, twitter or facebook.
FT86CLUB
Ft86Club
Delicious Tuning
Register Garage Members List Calendar Search Today's Posts Mark Forums Read

Go Back   Toyota GR86, 86, FR-S and Subaru BRZ Forum & Owners Community - FT86CLUB > Technical Topics > Software Tuning

Software Tuning Discuss all software tuning topics.


User Tag List

Reply
 
Thread Tools Search this Thread
Old 07-07-2020, 09:10 PM   #1
Stu L Tissimus
Member
 
Stu L Tissimus's Avatar
 
Join Date: Jun 2012
Drives: MT GB BRZ Limited
Location: Seattle, WA
Posts: 76
Thanks: 0
Thanked 28 Times in 17 Posts
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
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?
__________________
すばらしい。いや、スバルしい。

Last edited by Stu L Tissimus; 07-08-2020 at 11:56 AM.
Stu L Tissimus is offline   Reply With Quote
The Following User Says Thank You to Stu L Tissimus For This Useful Post:
RedReplicant (01-25-2024)
Old 07-08-2020, 12:13 AM   #2
Compelica
Senior Member
 
Compelica's Avatar
 
Join Date: Apr 2019
Drives: 86 GT
Location: Malaysia
Posts: 358
Thanks: 218
Thanked 205 Times in 105 Posts
Mentioned: 2 Post(s)
Tagged: 0 Thread(s)
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.
Compelica is offline   Reply With Quote
Old 07-08-2020, 02:04 AM   #3
churchx
Senior Member
 
churchx's Avatar
 
Join Date: Mar 2015
Drives: 2014 GT86
Location: Latvia, Riga
Posts: 4,333
Thanks: 696
Thanked 2,085 Times in 1,436 Posts
Mentioned: 53 Post(s)
Tagged: 1 Thread(s)
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.
churchx is offline   Reply With Quote
Old 07-08-2020, 08:18 AM   #4
steve99
Banned
 
Join Date: Dec 2013
Drives: FT86
Location: Australia
Posts: 7,998
Thanks: 1,035
Thanked 4,987 Times in 2,981 Posts
Mentioned: 598 Post(s)
Tagged: 2 Thread(s)
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
steve99 is offline   Reply With Quote
The Following User Says Thank You to steve99 For This Useful Post:
DarkPira7e (07-08-2020)
Old 07-08-2020, 10:04 AM   #5
Yoshoobaroo
TRACKBREAD
 
Yoshoobaroo's Avatar
 
Join Date: Mar 2016
Drives: 2013 BRZ
Location: Florida
Posts: 3,929
Thanks: 2,660
Thanked 4,024 Times in 1,895 Posts
Mentioned: 30 Post(s)
Tagged: 0 Thread(s)
Garage
You have speed, RPM, and clutch position in OBD. That should be all you need to figure out the current gear.

Oh and this :


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

Last edited by Yoshoobaroo; 07-08-2020 at 10:16 AM.
Yoshoobaroo is offline   Reply With Quote
Old 07-08-2020, 11:56 AM   #6
Stu L Tissimus
Member
 
Stu L Tissimus's Avatar
 
Join Date: Jun 2012
Drives: MT GB BRZ Limited
Location: Seattle, WA
Posts: 76
Thanks: 0
Thanked 28 Times in 17 Posts
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
Thanks guys!


I recognize the Ecutek can auto-blip for me, but I'm doing this more for the fun of building it
__________________
すばらしい。いや、スバルしい。
Stu L Tissimus is offline   Reply With Quote
The Following User Says Thank You to Stu L Tissimus For This Useful Post:
steve99 (07-08-2020)
Old 07-08-2020, 01:01 PM   #7
Yoshoobaroo
TRACKBREAD
 
Yoshoobaroo's Avatar
 
Join Date: Mar 2016
Drives: 2013 BRZ
Location: Florida
Posts: 3,929
Thanks: 2,660
Thanked 4,024 Times in 1,895 Posts
Mentioned: 30 Post(s)
Tagged: 0 Thread(s)
Garage
Quote:
Originally Posted by Stu L Tissimus View Post
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!
Yoshoobaroo is offline   Reply With Quote
Old 07-08-2020, 06:50 PM   #8
7c8
Member
 
Join Date: May 2015
Drives: BRZ
Location: Vancouver, BC
Posts: 33
Thanks: 5
Thanked 13 Times in 10 Posts
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
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.

Last edited by 7c8; 07-09-2020 at 11:36 AM.
7c8 is offline   Reply With Quote
The Following 2 Users Say Thank You to 7c8 For This Useful Post:
anticubus (07-18-2020), churchx (07-09-2020)
Old 07-17-2020, 08:11 PM   #9
Stu L Tissimus
Member
 
Stu L Tissimus's Avatar
 
Join Date: Jun 2012
Drives: MT GB BRZ Limited
Location: Seattle, WA
Posts: 76
Thanks: 0
Thanked 28 Times in 17 Posts
Mentioned: 1 Post(s)
Tagged: 0 Thread(s)
(I finished a super hacky quick-and-dirty version here!)
__________________
すばらしい。いや、スバルしい。
Stu L Tissimus is offline   Reply With Quote
The Following 2 Users Say Thank You to Stu L Tissimus For This Useful Post:
Compelica (07-18-2020), Yoshoobaroo (07-17-2020)
Old 07-17-2020, 08:21 PM   #10
Yoshoobaroo
TRACKBREAD
 
Yoshoobaroo's Avatar
 
Join Date: Mar 2016
Drives: 2013 BRZ
Location: Florida
Posts: 3,929
Thanks: 2,660
Thanked 4,024 Times in 1,895 Posts
Mentioned: 30 Post(s)
Tagged: 0 Thread(s)
Garage
Sweet!
Yoshoobaroo is offline   Reply With Quote
Old 07-22-2020, 12:15 PM   #11
pallen
Senior Member
 
pallen's Avatar
 
Join Date: Jun 2020
Drives: 2017 Toyota 86
Location: Fort Worth, TX
Posts: 261
Thanks: 200
Thanked 184 Times in 110 Posts
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
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.
pallen is offline   Reply With Quote
Old 07-23-2020, 09:18 AM   #12
Dzmitry
Senior Member
 
Dzmitry's Avatar
 
Join Date: Jul 2019
Drives: 2018 Subaru BRZ Limited with PP
Location: Phildalphia, Pennsylvania
Posts: 975
Thanks: 2,123
Thanked 609 Times in 391 Posts
Mentioned: 4 Post(s)
Tagged: 0 Thread(s)
Garage
Quote:
Originally Posted by pallen View Post
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.
Dzmitry is offline   Reply With Quote
Old 07-23-2020, 09:22 AM   #13
pallen
Senior Member
 
pallen's Avatar
 
Join Date: Jun 2020
Drives: 2017 Toyota 86
Location: Fort Worth, TX
Posts: 261
Thanks: 200
Thanked 184 Times in 110 Posts
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quote:
Originally Posted by Dzmitry View Post
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...
pallen is offline   Reply With Quote
Old 07-23-2020, 09:28 AM   #14
Dzmitry
Senior Member
 
Dzmitry's Avatar
 
Join Date: Jul 2019
Drives: 2018 Subaru BRZ Limited with PP
Location: Phildalphia, Pennsylvania
Posts: 975
Thanks: 2,123
Thanked 609 Times in 391 Posts
Mentioned: 4 Post(s)
Tagged: 0 Thread(s)
Garage
Quote:
Originally Posted by pallen View Post
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?
Dzmitry is offline   Reply With Quote
 
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cruise control and current gear suddenly not working, but suddenly worked again btan219 Issues | Warranty | Recalls / TSB 2 06-30-2018 01:09 AM
Car will not go into gear after new clutch install?! Amartinez99 Engine, Exhaust, Transmission 15 01-15-2018 01:25 PM
is it ok to slip my clutch often in 2nd gear when my rpm is below 2k? awhatzable Scion FR-S / Toyota 86 GT86 General Forum 88 06-17-2015 06:12 PM
clutch/gear box getting softer zERoTu Issues | Warranty | Recalls / TSB 3 06-05-2014 08:18 AM
Display current gear without clutch engaged? cfusionpm Scion FR-S / Toyota 86 GT86 General Forum 45 03-26-2013 04:08 PM


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


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

Garage vBulletin Plugins by Drive Thru Online, Inc.