• There has been a recent cluster of spammers accessing BARFer accounts and posting spam. To safeguard your account, please consider changing your password. It would be even better to take the additional step of enabling 2 Factor Authentication (2FA) on your BARF account. Read more here.

Z3n's Project Barn

Into the weeds of tuning - because of our steadfast commitment to ignoring the emotional part of the vehicle / operator relationship, it’s very easy to end up making something that tricks our brain into feeling fast but isn’t actually fast. A giant hit of power feels fast, but requires the rider to think about and manage the bike effectively changing the amount of power going to the ground even though they might be maintaining the same throttle position.

As an example - I’ve been lucky enough to ride some of the old turbocharged bikes from the 80s and they were the best demonstration of this (see also: the widowmaker generations of Porsche 911s). The CX650 Turbo was as fast as the ZZR1200 I was riding at the time in a straight line to about 110mph, but the amount of work, focus, and concentration to make it hustle at the same pace up a twisty road was orders of magnitudes more. You’d approach the apex, and need to add throttle extremely early to get the bike to start building boost to get out of the corner, far, far earlier than you would with a traditional motor. But once boost started building, you’d have to back off the throttle as the boost increased power output at the same throttle position. Those bikes ran skinny tires, so keeping the bike adding power progressively as you reduced lean angle up might require you to go from 75% throttle to 45% throttle as it comes on boost, and then back to 75% to keep it accelerating progressively on corner exit. You had to predict the boost you were going to gain on the gas, and manage the increase in engine output proactively. Because boost was changed by throttle application over time creating exhaust velocity to spool the turbo, not directly controlled by the throttle, but influenced the output of the throttle, you were managing a complex, multi-variable system via only one input to get a progressive application of power to the ground. This will be important later, as we talk about how modern ECUs solve this problem for you. Boosted motors benefit even more from modern ECU designs, but NA motors still benefit and are influenced by the technology developed to handle the complexity of boosted applications.

The core principle here is this: Power that you can not put to the ground is power that is wasted. It can be wasted because you can’t easily put the power to the ground due to inconsistent throttle response, as in the CX650 Turbo demonstrates, or it can be wasted because you do not have the precision to balance holding the bike at the very limit of available rear tire grip, as the old 500cc 2 stroke GP bikes would demonstrate, by flicking their riders off the highside when they went on the pipe.

So: The goal of tuning, in my opinion, is to make power outputs predictable, then maximize available power output. You need the bike to respond consistently so you can maximize drive off the corner while you are in the danger zone of high levels of lean and high levels of throttle application. This has been a lot of words, so here’s a more tangible example:

[youtube]qI_YoWViAP4[/youtube]

You can hear the shift at :02 that takes place effectively at the apex of the last corner, which is comfortable due to two factors: The quality of the KTM quickshifter, and the confidence that being one gear up won’t create an uncontrolled burst of power. It’s a relatively gentle turn, but you are putting a lot of inputs into the bike to get it to change direction, and an unanticipated burst of power could cause a slide or unbalance the suspension, causing you to lose drive or induce instability.

So how do we make that happen?

In the old days, we had carburetors, and tuning for those systems was somewhat different - the fuel metering available from a carb was dependent on a large number of factors that couldn’t be controlled by the carb itself. I’ll assume a carb with a throttle cable directly to the slide here for simplicity, which were treasured because they offer very direct throttle feel. Lectron / Smartcarb are examples of modern carbs like this. The rider can change the settings on the carb, but once it is set, you cannot change it live, and the only control the rider has is the throttle. Given a specific vacuum through the intake and slide position, the carb will always respond with the same amount of fuel.

On the flip side, using the KTM ECU as an example, it has a plethora of sensors:

Air temperature sensors
Manifold Air Pressure sensors
Throttle plate angle sensors
Knock sensors
RPM sensors
Throttle sensors
Lambda sensors
(and more!)
The KTM ECU also has complete control over the following:
Throttle plate position
Injection timing
Ignition timing
(and more!)

This enables a much more complex but powerful control over the power output characteristics of the motor. If we reduce an ICE motor to an air pump, then you can determine the ideal operating characteristics of the motor by understanding how much air it can take in at a given RPM (Volumetric Efficiency map) and intake pressure(Manifold Air Pressure sensor), and that tells you how much fuel should be injected to burn at a specified air fuel ratio, which when combined with a spark table and other environmental factors (air temperature, altitude, etc), means the ECU can model how much torque the motor puts out. This has multiple major benefits - you can manage places where the motor doesn’t run particularly efficiently by adding a bit more throttle to compensate at anything below 100% power output, you can back the torque output of the motor off at an appropriate rate if a rider suddenly loses traction, you can precisely output enough torque to unload the transmission with an autoblip downshift but not cause the bike to lurch, and you can make sure that if the rider asks for 20% throttle they get a consistent torque output, regardless of the conditions. You can also compensate in an extremely specific, accurate way for boundary conditions like going from closed throttle to pinned that a more basic system like a carburetor would struggle with, or wear on the engine over time (via monitoring charge burn via lambda) to validate the engine is operating as intended. You can also take action to save the motor if it begins to knock, reduce harm to the motor if it is pinned while unloaded or in neutral, and a variety of other things that aren’t possible in a system where fuel is metered strictly by the throttle slide and vacuum characteristics.


But I thought this was about tuning?

If we’re not just gonna throw shit at a wall and see what sticks, we have to actually understand what we are tuning. This ain’t just throwing jets in a hole, my dude, this is precision binary engineering.

So if you’ve built this complex ECU, with all these variables to manage, you have to have a way to interact with them. After all, as my initial post said, the ECUs themselves are generic until they’re programmed, so understanding how the ECU processes each of the available sensors and then reacts is critical to actually having some control over the motor. This is done in the ECU by a combination of flags (ie, should the O2 sensors be on or not), and lookup maps. Those maps look like this in raw memory:

la9WnvI.png


Which - to be honest, isn’t very useful. But it’s useful to understand that the maps get flattened into memory. If you do some normalization on them, mapping the memory values into something more human parseable, you get something closer to this:

I2VrifY.png



This specific map describes the relationship between RPM and throttle, and the expected amount of air in kg/h that the motor will ingest as a result. It can be sometimes useful to represent these in 3 dimensions to better understand the nature of how the system interact:

FPG7z95.png


The small dot you see represents that at 6500 RPM and 39.99% throttle, with the lookup value being 74.62 kg/h of air. From reading the throttle sensor, the RPM sensor, the motor can now know how much air is processed, and it can infer how much fuel should be injected to start. That brings in a starting point, and then from there the ECU determine if it needs to apply additional fuel trim based on the Lambda sensors reporting how much oxygen remains in the exhaust:

1jz5ROg.png


Those trim maps over the top of that to compensate for changes atmospheric conditions, wear, ethanol in fuel, etc.

You’ll discover as you dig into these maps that there’s a lot of inferences that may or may not be correct - after all, you’re basically looking at the shape of the map in 3 dimensions and trying to match it to what makes sense in terms of shape for what the map itself does. This map is called “normal lambda for component protection”, but I believe it’s a lambda target map, so the ECU uses this in combination to validate feedback from the O2 sensors on each header and then dials in fuel trim accordingly. Too much trim will usually cause an error, as it indicates something is operating out of expected values - so it’s important to baseline appropriately, so you don’t over-rely on the trim tables to fix your fueling.

Okay, NOW can we start tuning?

I thought you’d never ask! Once we’ve determined what type of maps we have, we’ve got a few goals. While many people think that air/fuel ratios make power, A/F ratios actually mostly make safety, not power. HPTuners does a lot of excellent work, and they have a great YT video where they show how a motor with only AF changes has different outputs on the dyno:

tasnNWI.png


You can see here that as long as Lambda is somewhere between .87 and 1.0 or so, it makes basically the same power. The difference is the additional fuel will help with cooling, and avoiding detonation, especially on boosted motors. If you’re looking for “Rich Best Torque”, you’ll probably find it about .87, if you’re looking for Lean Best Torque, you’ll probably find it around .97.

So there’s a few things here. Although I haven’t talked about the VE tables (oh yes, there is more here), you can kinda hack around the fact that motors will default to lean tuning by adjusting the values of Kg/h of air processed to tell the ECU that more air is coming in, and then adjusting the lambda targets to get the ECU to avoid tuning out the richer default to a leaner target. It also gives you the flexibility to have dramatically different setups for lean cruise, which is how bikes like my 1290 SuperDuke could get ~60mpg under light cruise, while still making 160hp when full throttle - the ECU can have dramatically different values for different load and usage conditions, unlike a carb. It can also correct within reason for changes away from the baseline, which is why you can get check engine lights - the engine is expecting a certain set of values within a certain range, and discovering that the readouts are not matching expected values.

First step is to make sure that the motor operates consistently and reliably, and safely. We’ll first make the basic injection a bit richer by adding a 5% change mostly across the board, as i’ve modified the exhaust and intake on this bike:

IDtgsrV.png


I also did some smoothing to help clean things up a bit.

Then we need to adjust the Lambda values, because we don’t want the ECU tuning out my changes, so we’ll modify the values listed above to this:

jXhDR1q.png


You can see that I’ve broadly moved the values towards .90. I could have run them a bit richer, but this is already quite a bit richer than before, and anything in the lower ranges is still pretty safe for my use case. I might adjust even farther into the rich range for many of those values, but I’m sure this is pretty safe, and avoiding large swings in values means the motor will run more consistently, and consistency is predictability.

So how do we know this was a good change?

a0MEQ2c.png


The blue run is the original run before these changes, and the red run is after the changes - more importantly, there’s no piggyback unit - the ECU will always attempt to tune back to these values. Back to back runs showed this:

Ao9yG1S.png


Predictability - although I’d still like to clean it up just a bit more.

Now that you’ve got a predictable, safe AF ratio, that you can trust the bike will maintain independently, you can start tuning for power, via adjusting ignition. It’s pretty much the same routine with ignition - identify which maps control ignition timing in the areas you want to adjust, adjust ignition within safe boundaries for reasonable power, and test and validate your changes are actually leading to more power and are applied consistently.

There’s also some other details around things like throttle -> torque maps that will interact with this - you can make the bike run better, but if the ecu is programmed to never give you more than a specific amount of torque, it will actually back the throttle off as the motor has already hit the effective target. Piggybacks fix this by just messing with the signals at the injector, but you’re always gonna be fighting with the closed loop systems. Adjusting the closed loop values means the closed loop corrects automatically to where you want it to be, but does require you to do a bit more work. On the flip side, the ECU will never undo your changes, as it will always try to shoot for your values. Okay, that’s enough for today! Here’s a few useful resources for folks who want to go down this rabbit hole themselves:

How to use/ identify maps in WinOLS:
[youtube]TWsv3VkOFeo[/youtube]
HP Tuners A/F HP
[youtube]JzbLrn-2jyw[/youtube]

A final note here - I have seen some godawful maps from tuners - massive swings in spark values, maps that barely ran but the ECU valiantly compensated for, creating “power” by just making the throttle response completely abrupt. When you’re modifying an ECU like this, take some time to understand what the tuner is actually changing, and if it can’t be validated meaningfully, I’d encourage you to take it to another dyno tuner and get a quick a/f sample run. There’s also the question of if the tuner actually correctly managed and compensated for closed loop corrections - nothing like the tune running great on the dyno and then the ECU happily tuning it all out over the first 20 miles away from the dyno shop. Not to mention piggyback units failing, and the plethora of other woes that can show up with tuning. If they can’t explain what they’re doing, how it might fail, and how they compensate for that…maybe find another tuner.
 
Last edited:
I just hope it inspires someone else to go mess with this stuff :) It's not magic, it's complicated but it can be learned. I've got a personal fixation on the 790 / 890 platform, so I'll focus on that, plus maybe a bit of work on a friend's RC390, but if it inspires someone to go try it themselves, that's the goal.
 
It's inspiring me to send you my ECU. ��

Or pickup a spare ECU to toy with and keep mine as a backup.
I'd guess that would mess with the immobilizer system tho....
 
Yeah, can't do that because afaik, the gauges and the ECU are linked. I might try plugging in a different ECU and see if I can figure out what it sends but it's pretty risky if it goes wrong.

I'll happily reflash yours if you want, although it might take me a little to figure out where the maps are in the ECU and such - the facelift probably had a software revision as well. What I'm hoping to do at some point is back to back a stock flash with my changes and see what the difference is on the dyno, after I add some ignition. The bike definitely feels smoother with the richer fueling - I noticed that on my friend's SuperDuke, and I've noticed it throughout the years on different bikes, including carbureted ones as well - richer running usually means a smoother motor. Goes from feeling like it's trying to shake itself apart at low RPM in top gear to smooth across the whole rev range.
 
After a busy week, I finally had a few minutes to sit down and do some work on maps. Not going to do a more detailed overview today, but I wanted to correct the fueling on my friend's 790, primarily around the flat spot in the midrange. If you look at the OEM MAF maps, you can actually see that dip visibly in how the motor is expected to put out horsepower:
9X1DM1C.png


The blue circle area is where it determines how much air is coming in, and thusly how much fuel should be injected. If the bike feels like it's going lean and then surging forward at that RPM, it's because the ECU is injecting less fuel because it is being told the motor can't process as much air at that RPM/Throttle! The fueling maps (or any maps) should always be smooth - motors don't suddenly change power characteristics as long as they're reasonably well built, with balances in the tradeoffs between intake and exhaust design, ignition, cam profiles, etc.

After adjustment, the MAF tables look like this:
zPnOQVp.png


Nice smooth progression, even power, no massive spikes.

I also adjusted ignition with similar smoothing, although in very conservative ranges (ie, nothing more than a degree or two, mostly pulling out big spikes in the map vs trying to maximize power), put the lambda to about rich peak torque, and mildly tweaked the torque adjustment in the midrange to try and feed back in a bit more power. If this doesn't sufficently smooth out the flat spot, I'll probably tweak the driver wish map a bit to add a bit more requested torque at those RPM ranges, and just smooth things out. I doubt that'll be needed, though.

Oh, and I've decided I want to do some rally raid events, so I'm going to build the 350 into a rally bike with some KTM RFR tanks and a custom rally tower.
 
Last edited:
After some test riding, I'm happy to report the changes filled in the 3.5-5k midrange nicely. I'll drop it by the dyno and do a run and check all the A/F ratios at some point, but it pulled cleanly through the rev range and built power how you'd expect it to, no lag and no delay. Rottweiler power plate + decat, otherwise stock.
 
A friend of mine got into car rally stuff, and is having a blast - but a car seems like a lot of infrastructure, and I'm not really into having someone yell instructions at me while I operate a vehicle, so after some digging around to see what my options are, and because I did want to go back to Utah after I did part of the Utah BDR, setting myself up to do the Cotah Rally seemed like a good idea. I've spent the last 6 months or so really enjoying my 2023 350 XC-F, suspension is dialed, bike runs great, so that means it's time to....completely disassemble it and use it as the chassis for a rally bike.

We all know KTM has a lego-like design ethos, so I'll just take these RFR tanks I have sitting around and snag a windshield and build a rally tower for it. Will need to build an exhaust, make a skidplate, a bunch of brackets, relocate the radiators a bit so the tank clears, build a rally tower bracket and the tower itself...

But I did mock up the tanks and it doesn't look like it'll be too much of a monster task to rig everything up. Let's build a rally bike!
n53FzOb.jpg
 
Well, finally decided it was time to experiment with the titanium weld kit from TiCon Industries - I was struggling with color and contamination, before realizing that my torch was leaking argon and the only functional torch I had couldn't fit my gas lens.
cF79I6I.jpg

0LKA4x5.jpg


Will have to go pick up some supplies tomorrow. Also, somehow there was no aluminum foil in the house, so backpurge was done with a separate line directed at the back of the weld. Messed a bit with speeds, amperage, tungsten sharpening angle, different types of tungsten - no strong conclusions yet, but got enough good welds with proper penetration and no contamination that I'm confident with a proper gas lens and backpurge it'll be just fine.
 
A friend of mine got into car rally stuff, and is having a blast - but a car seems like a lot of infrastructure, and I'm not really into having someone yell instructions at me while I operate a vehicle, so after some digging around to see what my options are, and because I did want to go back to Utah after I did part of the Utah BDR, setting myself up to do the Cotah Rally seemed like a good idea. I've spent the last 6 months or so really enjoying my 2023 350 XC-F, suspension is dialed, bike runs great, so that means it's time to....completely disassemble it and use it as the chassis for a rally bike.

We all know KTM has a lego-like design ethos, so I'll just take these RFR tanks I have sitting around and snag a windshield and build a rally tower for it. Will need to build an exhaust, make a skidplate, a bunch of brackets, relocate the radiators a bit so the tank clears, build a rally tower bracket and the tower itself...

But I did mock up the tanks and it doesn't look like it'll be too much of a monster task to rig everything up. Let's build a rally bike!
n53FzOb.jpg


Hell to the yes...! :thumbup
 
Welding shop didn't have any smaller torches in stock, nor the appropriate gas lens set up for the bigger ones, so gotta wait until the mailman drops some off. The muffler shipped from Italy, so hopefully that'll be here soon!

As an amusing note for how forgiving titanium can be: I've been running an eBay header for the last 2 years on the RC890, and I ordered a few more just because they're cheap and I figure a clean one will be a lot easier to weld to, plus they fit either config of 890, and ~$180 to scrub a bunch of weight off the bike doesn't hurt. Given that I've been experimenting with welding titanium, I figured I'd look at the brand new, disassembled one and see what I see...
Lwd4eHF.jpg

Guess if you don't have penetration you don't really need to backpurge! But also, I'm sure the one I have looks just as contaminated as this one and it's been fine without any exhaust supports whatsoever for 2 years of track use so I think whatever I weld will be just fine, even if it's not the nicest. My TIG even has a pulse setting on it that I've never played with, so we'll see how that goes together.

Also, some ubends showed up for the first pass at the rally bike exhaust. Gonna shamelessly rip off the Akrapovic routing, and once I've got it all set up, I'll do a version of it in titanium. Wanted to see how the 890 exhaust went before I committed to a second titanium exhaust, the materials aren't cheap! I'm thinking maybe one of these exhausts for it, although I'll order a straight muffler and run it in the low rally style:
0020810_hp-sp-1-carbon-short-titanium-ktm-890-adv-rally.jpeg
 
Okay, so it's been awhile since my last update - life got busy, everyone knows how it goes.

I found a configuration for the 350 that both makes sense from an ergonomic standpoint, lets everything clear, and generally will make the bike reasonably functional while using the new tanks.

Bonus that it's pretty balanced side to side, and that I won't need to make a new seat.
hIMSoYql.jpg

vY0IkjOl.jpg


Designed and printed up some pie cut spacers for protyping:
LkBdoBKl.jpg

Here they are in use:
3BxRZKwl.jpg

Tacked up, first full weld done:
rNKQFdPl.jpg


And couldn't resist firing it up for a quick test run - sounds a lot more civilized now, before it was just obnoxious.
https://imgur.com/I83c0ZG

Also got the rest of the supplies for making the exhaust. I didn't like having to constantly start and stop to not outrun my shielding, so I snagged a trailing shield from TiCon, as well as the supplies to make installing O2 sensor bungs much easier:
9vB09D5l.jpg

W7fbL5ml.jpg


I crashed my 890 on the OBDR awhile back and busted the coolant reservoir, the facelift side fairings finally showed up with all the other parts and I installed them - I just cut down the Aurora side panels, will need to still make a few additional brackets, a mount for the R/R, and a coolant overflow:
2DhXX6bl.jpg

mPVytLUl.jpg


Might knock out the remaining titanium welding this weekend, might not get to it. Also figured out how to reflash the 890 Duke to the 890 Duke R power output, which is neat, and what I learned might help me get more power out of the R models. I've also done some measurements, and will be trialing out some different header lengths and designs to see if I can move the powerband upwards on the RC890. Did some data analysis and basically discovered the bike lives between 7-9.5k while being run on track, so I can design the exhaust and intake to maximize power at those RPMs and let the rest of it go.

Never enough time, but thank you for yours, reading along with my projects :)
 
Last edited:
Bike sounds good. :thumbup

Sure it still makes some rippppping sounds when on the gas. :teeth

Good luck with the pipe experimentation.
 
Glad I found this thread. Lots of cool stuff going on in the Project Barn! :Popcorn
 
Okay, another update!

Did manage to complete most of the welding on the pipe today:
iF6FJwKl.jpg


Not quite as consistent as I want, but functional:
EFgoIZYl.jpg


Really was wishing for a rotary table by the end of this, but here it is on the bike, with the raw welds:
0nUBbgdl.jpg


Took a quick break to weld up the copper fitting on my air compressor, which had cracked. Should have soldered it, but didn't have any, so TIG it is:
B6JqvCAl.jpg


Tried out the brushed look, didn't like it that much:
AvDU9l8l.jpg


Went after it with a torch and got an effect that I kinda like:
iIwoUdBl.jpg


And a bit of a longer running clip:
https://imgur.com/a/v3otraq

While I'm waiting for my other set of headers to show up, I'll be throwing some ECU maps together - tweaking torque monitoring, drivers wish maps, smoothing out fueling/ignition maps, fixing lambdas, and a couple of different timing maps to play with, and then it's off to the dyno to do some testing.
 
Pipe looks good. I am a fan of the blue... :thumbup
 
Thanks budman!


I'm pretty pleased with how it came out, even if my heat treating is a little old school. I've decided (because I can't leave well enough alone) that I'm also going to do my own exhaust can design, so there's more design and fab work in my future. A little mix of old school for the part that joins to the midpipe:
https://www.youtube.com/watch?v=BGKOPYoM4Qo

Some basic sheet metal forming for the can, and then a forged carbon endcap, using 3d printed molds:
https://www.youtube.com/watch?v=KpJdwryFj6k
 
Thanks Al! Hope you're having a good holiday season - you should come up and ride Ridge with us at some point :)

My knockoff Akra headers showed up - as I sort of expected, the headers are much larger diameter, and much longer - basically 12 additional inches of header. There's also an H pipe crossover, which I'm not 100% sure makes a meaningful difference, but maybe is worth something. I'll probably drop a plug in it at some point and see if there's a difference with / without the H pipe.
AsPWJ7C.jpg


For a rough reference on the difference in lenghts / diameters:
ha4Zq5j.jpg


I was going to build my custom headers to be even larger than these, so we'll see what the 3 setups end up landing at.

Things of the 4 wheeled variety have distracted me as of late - my box truck showed up, it's a 93 Ford E-350 Cutaway with a lift and a 4x4 conversion. 43k miles, got it for a song from a buddy, it's a little rough around the edges but can't argue with the 460 and 4.11 rear gear combo for hauling around, as well as a box truck and a DRW setup. Should be great for going anywhere I need to go, with bikes and supplies in tow.
yZ8ELNH.jpg


And also have this guy floating around in my shop:
0ojgBGa.jpg


I'm the keeper of a friend's NSX for a little while, it's truly unbelievable to me how good these cars are. Here it is getting fresh tires:
0ojgBGa.jpg

and out in the wild:
o2qdH79.jpg


It's such a glorious car to drive, and it's also wonderful how happy people are when they see it out in the wild. 205k miles, my friend bought it from the original owner, and I hope that he'll have it to at least half a million miles. It's a funny car because on the spec sheet it's nothing special, but it evokes the feeling that you should have when you're driving a supercar better than any vehicle that I've ever driven, and I've had the luck to drive more than a few very nice cars in my time. The Ferris Bueller's Day Off quote was about a Ferrari, but only because the NSX hadn't been released yet. That car is 32 years old and it provides more feel to the driver than a modern 911 GT3. It was the baseline against which the McLaren F1 was measured. All of the things people say about them are true.

Also, same friend has a restomod CBX that I've built for him over the years, and it's been sitting for a bit waiting for me to rip it apart and fix the #2 cylinder, which I think has a failed oil control ring. It's a bit of a unique build - ZX-6R rear swingarm, ZRX1200 front end / front and rear wheels, big bore kit, Voyager gauges, and a number of other custom bits.

Here that bike is:
RfGDz56.jpg


Will tear it down, install the V&H aftermarket CCTs, get a custom set of rings made for it, reinstall it, fix some oil leaks, and then it's the rest of the restomod madness for it - especially looking forward to building the 6 into 6 exhaust.

Hope everyone's having a great holiday season :)
 
Back
Top