RomRaider Logo

RomRaider

Open Source ECU Tools
 FAQ •  Register •  Login 

RomRaider

Documentation

Community

Developers

It is currently Sat Feb 21, 2026 9:58 pm

All times are UTC




Post new topic Reply to topic  [ 87 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Rev matching on downshift
PostPosted: Sat Feb 18, 2017 9:22 pm 
Offline
Moderator

Joined: Thu Nov 23, 2006 2:23 am
Posts: 2565
For the last couple months my office has been in a building that overlooks a busy street, and every once in a while somebody drives past in a Lamborghini, Ferrari, or even just a newer M3, and the rev-matched downshift noises are glorious. It probably helps that there's a crazy expensive restaurant a few blocks away. But anyway, this got me thinking it would be fun to make Subarus do the same thing.

I'm picturing a hook for the ECU code that looks up the throttle plate angle...

Code:
// RAM variables
int state; // 0 = normal, 1 = no rev match, 2 = yes rev match
int targetRpm;
int timer;

// ROM constants
int maxMatchRpm = 7000;
int minimumRpm = 1000;
int timerLimit = 1000; // I'm just guessing at this one

// find these values by logging RPM and speed (km/h) in each gear
int gear1Ratio, gear2Ratio, gear3Ratio, gear4Ratio, gear5Ratio;

// In most cases, just reset state and call the factory code
if ((clutch up) or
    (throttle pedal above 0%) or
    (coolant < 160F) or
    (RPM < minimumRpm) or
    (defogger switch off)) // just in case testing goes poorly - remove afterward
{
    state = 0;
    timer = 0;
    return CallFactoryCodeToGetThrottlePlateAngle();
}

// If the clutch went down with more than 0% throttle, DO NOT rev match
if (state == 1)
{
    return CallFactoryCodeToGetThrottlePlateAngle();
}

if ((throttle pedal above 0%) or (brake off) or (timer > timerLimit))
{
    // If we get here, the drive is accelerating
    // or doing their own rev match
    // or the rev-match timer has expired.
    state = 1;
    return CallFactoryCodeToGetThrottlePlateAngle();
}

// If we get here, the clutch went down with brake and 0% throttle
// So this is where the rev-match code really begins.
if (state == 0)
{
    targetGear = currentGear - 1;
    state = 2;
    timer = 0;
}

if (state != 2)
{
    // This should never happen, but just in case...
    // Set state to 3 so that the logger will clearly indicate that there's been a bug.
    state = 3;
    return CallFactoryCodeToGetThrottlePlateAngle();
}

timer++;

defaultTargetRpm = GetIdleRpm();

// This 'switch' block could be an array lookup instead, but that
// would end badly if targetGear gets set to an unreasonable
// value somehow. Using switch seems a little safer.
switch(targetGear)
{
    case 1:
        targetRpm = currentSpeed * gear1Ratio;
        break;
    case 2:
        targetRpm = currentSpeed * gear2Ratio;
        break;
    case 3:
        targetRpm = currentSpeed * gear3Ratio;
        break;
    case 4:
        targetRpm = currentSpeed * gear4Ratio;
        break;
    case 5:
        targetRpm = currentSpeed * Gear5Ratio;
        break;
    default:
        targetRpm = defaultTargetRpm;
        break;
}

// Sanity check
if (targetRpm > maxMatchRpm)
{
    targetRpm = defaultTargetRpm;
}

if (targetRpm < defaultTargetRpm)
{
    targetRpm = defaultTargetRpm;
}

// This would just do a simple lookup in a new table that
// converts an RPM value to a throttle plate angle.
return LookUpThrottleFromTargetRpm(targetRpm);


_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Sat Feb 18, 2017 9:27 pm 
Offline
Moderator

Joined: Thu Nov 23, 2006 2:23 am
Posts: 2565
It just hit me that at startup, this will think you're trying to do a rev match, so the default RPM should actually come from the idle table after all. [fixed]

Also, the first first 'if' should probably check whether the coolant temperature is up to a reasonable level (160F?) so that this feature doesn't kick in until the engine is warmed up. [fixed]

Also, for testing purposes, that first 'if' should also check something like the SI-drive mode (if the car has it) or the defrost switch (on cars that don't have SI-drive), so that if there are any surprises you can disable the feature. [fixed]

And if the basic idea works out, but the rev control isn't good enough, then the simple table lookup could be augmented with a feedback loop to hit the target RPM more accurately. First I'd try just proportional feedback, then PI if it still isn't good enough. Maybe PID but I think PI would probably be sufficient.

What else am I missing?

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Mon Feb 20, 2017 3:50 pm 
Offline
RomRaider Donator

Joined: Thu Apr 23, 2015 8:20 pm
Posts: 5
Sounds like a very good idea. I wouldn't mind trying it out. I'm no programming expert so I might be of little help in that department :oops:


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Tue Feb 21, 2017 7:14 pm 
Offline
Experienced

Joined: Sun Oct 16, 2011 7:57 am
Posts: 150
good stuff NSFW...

I'm looking through the code - how do you work out if the user is actually downshifting though (vs upshifting)? I've thought about doing this for my "aijmod" version of merpmod for sometime.

It's almost as though one would need to wait for the clutch to start coming out, and watch vehicle speed to see if it slows down or speeds up before you rev-match.


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Tue Feb 21, 2017 7:38 pm 
Offline
Moderator
User avatar

Joined: Sat Jul 06, 2013 12:55 pm
Posts: 3297
Location: NI
or you could check if the brakes are on, you'd generally be downshifting and on the brakes together so the ECU would know it's time to match for the next gear?

_________________

Good luck and may the logs be ever in your favour!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Wed Feb 22, 2017 9:00 am 
Offline
Experienced

Joined: Sun Oct 16, 2011 7:57 am
Posts: 150
I don't always downshift and use the brakes... especially when i'm engine braking :D


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Wed Feb 22, 2017 2:02 pm 
Offline
RomRaider Developer

Joined: Thu May 21, 2009 1:49 am
Posts: 7323
Location: Canada eh!
If you are engine braking you could monitor for a high vacuum to detect downshift.


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Thu Feb 23, 2017 4:58 am 
Offline
Moderator

Joined: Thu Nov 23, 2006 2:23 am
Posts: 2565
I was thinking that 0% throttle would be enough to indicate that the next shift is doing down rather than up, but I've almost mostly been driving my Outback for the last couple months, and it's got an auto, so I've already forgotten how to drive a real car. :)

The brake switch sounds like a more reliable indicator. And I like the idea of the brake pedal being an explicit command to the ECU that it's time to match revs.

Using 0% throttle might cause it to sometimes blip the throttle at times when that's not what the driver wanted, whereas using the brake switch would fail the other way, causing it to NOT blip when the driver was hoping it would. The latter sounds safer, and if rev matching works well then it'll be easy to get into the habit of riding the brakes every time you want it to kick in.

Thanks for the input. (see what I did there?)

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Thu Feb 23, 2017 7:50 am 
Offline
Experienced

Joined: Sun Jul 13, 2014 10:12 pm
Posts: 111
If it's of any use, the ECUtek implemented Auto-Blip on the BRZ works based on the clutch being pressed while the brake is depressed. Even that catches you out sometimes (probably by bad driving practices) but I've yet to have an occasion where I'd want it to work and it hasn't. If you're driving hard, where you want the rev matching, then you'll be braking when changing down.


Last edited by Kodename47 on Thu Sep 07, 2017 10:40 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Sun Aug 27, 2017 6:42 pm 
Offline
Moderator

Joined: Thu Nov 23, 2006 2:23 am
Posts: 2565
It's interesting that they incorporated a time axis into their table. I'm hoping that a simple countdown timer can be used instead, and judging by the shape of that table, that should be sufficient.

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Mon Aug 28, 2017 3:11 am 
Offline
Moderator

Joined: Thu Nov 23, 2006 2:23 am
Posts: 2565
I started working on an open-source implementation of rev-matching last week, and it's about half done. It's not ready for flashing yet but it's getting there. Most of the work so far has been focused on enabling/disabling rev matching (and a calibration mode) via the cruise-cancel switch, so that unsuspecting spouses / valets / etc won't be startled by an engine that revs up spontaneously.

It's the same HEW project as the LC/FFS/SD stuff I was working on a while back, but now it's on GitHub:

https://github.com/LegacyNsfw/EcuHacks

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Mon Aug 28, 2017 3:55 am 
Offline
Moderator

Joined: Thu Nov 23, 2006 2:23 am
Posts: 2565
I have a theory about why they used a table with a time axis... the clutch switch is triggered with a tiny amount of movement, which means it is triggered before the clutch actually disengages, which probably means that without a delay the car will lurch forward for a split-second before the engine can rev freely.

If I'm right about that, then I'll try to address that with a fixed delay rather than a two-axis table. Either way, drivers will need to be decisive when pressing the clutch pedal. :)

P.S. Please do not share any further info from EcuTek. What I'm doing here is, and will remain, 100% my intellectual propery (licensed freely of course). We need to be super sensitive to this kind of thing, because in the early days of RomRaider (before it was even called RomRaider, if I remember right) there were people using stolen EcuTek intellectual property to create ECU definitions. Merchgod's definitions were done from scratch, so tainted IP hasn't been used for years, but still. Let's not do anything that even remotely resembles using anyone else's IP.

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Mon Aug 28, 2017 2:08 pm 
Offline
Senior Member

Joined: Thu Aug 03, 2006 2:40 pm
Posts: 1934
enginuity
xmlwrite

;)


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Thu Sep 07, 2017 8:22 am 
Offline
Moderator

Joined: Thu Nov 23, 2006 2:23 am
Posts: 2565
Attachment:
RevMatchTables.1.PNG


Progress is slow but steady. I hope to start testing in my car in the next few days.


You do not have the required permissions to view the files attached to this post.

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: Rev matching on downshift
PostPosted: Thu Sep 07, 2017 8:28 am 
Offline
RomRaider Donator

Joined: Tue Apr 29, 2014 4:48 am
Posts: 946
Thats great. I like how u structured it.

Sent from my SM-G900FD using Tapatalk

_________________
RomRaid!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 87 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subsilver by phpBBservice.nl