What's new
Honda Trail 125 Forum

Welcome to the Honda Trail 125 Forum! We are an enthusiast forum for the Trail 125, Hunter Cub, CT125 or whatever it's called in your country. Feel free to join up and help us build an information resources for this motorcycle. Register a free account today to become a member. Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

JA55 AI Fuel Tuning

JPMcGraw

Active member
Joined
Apr 13, 2022
Messages
131
Hey everyone! I've been messing with Antigravity and the nerd in me had an idea. Nothing super cool but its fun. This was a kind of spur of the moment thing because i realized i already had all the stuff so i just did it this weekend. Everything isn't fully fleshed out but its at least working and ive been able to tune idle.

The goal is to get an AI agent to log, analyze, and suggest changes to tune my fuel map. This will be a slow process because my garage is over 90* right now so don't expect anything quick. Also don't expect many pictures. Really you should try this on your own so you figure everything out for me.

So far i reinstalled the Takegawa Fi-con fuel controller (it doesn't do spark, just fuel). The AI Agent can't connect to the FI-con since im using linux and there is no native Linux app with terminal commands for the AI Agent to use. So it can't change anything or connect to the FI-con at this time using the agent. Im sure i can use Wine or a virtual machine and just passthrough bluetooth but ill explore that later. If you are running windows you might have better luck.

I have a honda 4 pin diagnostic plug to OBD2 connector and a cheap Panlong Bluetooth OBD2 reader (OBD2 through Bluetooth) - this gives a bunch of PIDs like TPS, temps, rpm
I have a 14point7 Spartan 3 wideband (serial data through USB) - this gives Wideband air fuel reading

The OBD2 connects Bluetooth to my computer, the Spartan 3 sends serial output through USB to my computer. The AI agent connects, logs, syncs, and analyzes the data and suggests what changes i should make. Then i connect to the takegawa software with my phone and manually enter the changes. So far its tuned idle. The takegawa was set to 0 across the map. I rode the CT around my neighborhood (under 25mph) for a good 10min then came home, did some idle logs, and modified the table based on AI suggestions. It went from around 12AFR (i have a 170 injector) and it got it up to 13.7 before i called it quits for the day. This took 3 idle runs and each run was around 30 second idle each time. Also through doing multiple logs and changes it was able to figure out the increments, or how much lambda/afr increase/decrease per fuel table unit (i think its microseconds of injector pulse). since its learning, it should get better and better, and making more accurate changes as it learns the flow of the system. It should also learn how much change is required based on outside temp so i could get a rich cooling summer map and a leaner winter map. I also have a 155 injector so im going to get it to learn that too at some point. i may even throw on the stock injector just to see if it can keep up with my mods. im just excited i have something fun to do that connects 2 of my loves!

Tuning the idle with my laptop is easy because im stationary and i can run a long USB to keep may laptop inside my house out of the garage heat. Riding around on my motorcycle with my laptop in a backpack, in the summer, sounds like a terrible idea. So this weekend Antigravity is going to slop me together an android app that will connect to the OBD2 by bluetooth and spartan 3 by usb. It will maintain that connection and try to reconnect and resume logging if it drops, it will only log raw data, and it will make sure to accurately timestamp everything that way if a connection drops and resumes syncing the data should be easy to sync up. then ill move those logs over to my laptop for post processing (syncing, converting, and analyzing). any post processing will happen on my laptop after the run so my phone hardware overhead is low reducing the chances of something messing up while logging is active.

For now im just putting this out there in case another nerd wants to tinker and figure out another setup. Once i get the app working (hopefully this weekend) ill post again because then i can actually ride around logging and tune the rest of the map. Once my setup is fully tuned ill post my MAP in case someone wants to use it.
 
Last edited:

JPMcGraw

Active member
Joined
Apr 13, 2022
Messages
131
The slop logging app is made and working. Super basic, 0 fancy, just logs, maintains a connection, reconnects, resumes, and timestamps. the fanciest part is the indicator dot that lets me know the devices are connected and data is flowing. Connects to OBD2 by Bluetooth and Spartan3 Wideband by USB, all to my phone in my pocket. If i disconnect the USB or Bluetooth (usb jiggles loose in my pocket then i notice during a run), then i reconnect, the app auto reconnects to the device and auto resumes logging. all logs are sync'd on my laptop post ride. File names have a start date and time and the log files contain elapsed time. i made sure timestamping and syncing was a major focus for that exact scenario.

Here's my current map after probably 6-7 runs and making changes after each run. 0 is unchanged, green is add fuel, red is take away fuel. (143BBK, takegawa n-15? cam, big valve head, full exhaust, NK racing intake pipe, larger stock air filter, stock airbox no snorkel)

1785848699705.png

the 170cc injector is obviously too big,

Still need to work on logic to prevent toggling +1 then -1 every run. A rolling minimum of 3 should fix that (+1 +1 +1 would give me +1 / +2 +2 +4 would give me +2). There are some other tuning concepts that i need to get it to implement to speed up tuning. it also needs to work on smoothing (10%TPS at 5500rpm is a little suspicious but i'm no expert). Im only doing 15min rides with lots of "twist and hold" throttle so it gets a good long reading at a stable TPS%. im also giving it A LOT of 4th gear full throttle pulls so it can get plenty of slow sweep WOT rpm data. the 170cc injector seems to be perfect for WOT in my setup. i have it ignoring all transitional/varying/moving throttle data so only stable TPS gets looked at. For now its working, stable, and the bike is running really nicely so i'm going to say its at v1.0. The FICon also has an accelerator pump feature that im going to eventually mess with but it has a lot of settings so thats for a later date.

Buying a device with autotune already (like the ARacer) is the best idea, but if you already have all the parts like i did and no way to autotune this seems to be working. I'm also learning a lot about tuning concepts so that's been a really big highlight of the whole process.

once i get done with the 170cc injector map ill post it and move over to the 155cc injector, repeat, then the stock injector. ill post everything here. At some point ill get AI to go over everything, describe the app and tuning process in a way that AI would understand and recreate. Then all you will have to do is download an agent, tell it to "read the file and recreate the project", and it will probably get you 75% of the way there. Then you just have to customize everything to your devices and liking.
 

squeaks

Active member
Joined
Jan 5, 2022
Messages
149
Wow. This is very impressive.
I kind of followed the example of Ozark garage for My 143 , but opened up the intake and exhaust, added the big valve head and ported it.
Added a oil cooler also.
I'm getting 12.5 to 13s on the AFRs
The only issue so far is at idle and just off idle...
It's running rich then.
I'm running the 140cc if that helps your research.
I'm also running the efie at 250 mv
I'm going to remove it to see if that helps with the rich idle.
 

JPMcGraw

Active member
Joined
Apr 13, 2022
Messages
131
Had some old lady cat issues so i haven't been able to work on this much but shes all good now so ill be back to doing more runs.

Massive improvement i tell ya what. Its starting to tune the Accelerator Pump function on the FICon and man did that help out a lot. Snappy response, low speed response is insane compared to stock or with the EFIE, and overall it just keeps pulling until above 55mph when it starts running out of breath. I might even be able to do a brake stand in a puddle now like a boss. Like i can twist the throttle and if my abs aren't tight i can feel my pelvis rotate from the acceleration in 3rd. Not rip you off the bike but a very obvious night and day change. Tuning logic has improved and overall tuning has sped up and gotten more accurate/better predictions. Overall its doing a really good job. the custom android app is polling as fast as possible and its to a point where it has enough fidelity to see quick snaps of the throttle. Our ECU and K-line don't poll as fast as a modern cars CAN. the more PID's you poll the slower it goes, so asynchronous and interleaved polling is a must for clarity. RPM polls as fast as possible while intake temp, MPH, and some other ones only poll every .5-1second. my phone loggs barometer, gps altitude, and something else i don't remember. the spartan 3 can poll wideband at 10ms. so wideband, RPM, and phone sensors rapid fire close to 10ms while the rest poll just enough. that part took some trial and error.

i was going to upload the CSV files for easier reading but i can't get files to upload so you get screenshots. Its the Accelerator Pump values, Fuel MAP values, and Lambda. AP and Fuel maps are self explanatory. 170cc injector is to big unless you are flat out full throttle all the time with my mods. Im interested to see how the 155 and stock look like in comparison. The Lambda screenshot show (Target Lambda / what Lambda im getting) and its only for cells ive hit enough times to for the logic to be confident. anything with a - is a cell ive never hit or rarely hit. every run these numbers get closer and closer to the target. Still not perfect but getting close to good enough for me. Ive noticed it isn't changing 100% throttle high RPM much and i think its because its not getting enough data to be "confident" so i need to loosen the constraints up there. I don't spend much time up there so that logic need to allow less confident hits to count. a big part of all this has been just that. "why did this happen?", "oh you are right! good catch human, ill fix that!", "neat that seems to work now this is broken", "You are so correct! let me fix that", "why is this broken now, that isn't even part of what wejustfixed?", "you are absolutely correct!"over and over and over then it just works and we save that state then do some runs. see another problem, repeat. Every time though tuning logic improves. So LPT, make the AI agent beat it agains a wall until it starts working. connect your laptop to the devices and let AI realtime troubleshoot.

Accel Pump
1786987819572.png

Fuel MAP (redline @9500 so 10000 is just a safety rich overrev zone that never changes and i never really go there. just in case)
1786987847745.png

Lambda Target/Current
1786987934891.png

Super fun project so far
 

JPMcGraw

Active member
Joined
Apr 13, 2022
Messages
131
the forum (probably my jobs network security) is being weird when i add files or screenshots. hopefully everyone can see the AC map, Fuel map, and Lambda values
 

JPMcGraw

Active member
Joined
Apr 13, 2022
Messages
131
I gave up on the 170cc because its way too big and moved to the 155cc. Still too big but i tried to get it to meet targets anyway. My garage broke which trapped the motorcycle for a few weeks and i had some lifter issues so i didn't get to ride as much as i would have liked. I probably need another 3-5 runs to get it perfect but its close enough and WOT is either on target (.850 Lambda) or slightly rich so its safe and good enough for an injector ill probably never use again unless i go up to a 160ish BBK. The next injector i'm going to try is the PCX125 since that's the next biggest one i have and it should be around 120CC. I did change to a TB cam and had to replace the valve lash adjustment screws. the OEM screws got elephants foot so i had to grind them down to get them out and in doing so i screwed up the threads on one lifter arm and had to cut new threads. The second lifter adjustment screw came out like butter. Unfortunately those new threads i cut aren't good enough so it backs out and i have to adjust lash every 2-3 hours of riding. a new lifter is on the to do list.

Mods for the below data: Yuminashi 143cc BBK, Finbro Super Head 3.0, TB Cam, Yohsi, NK Racing intake, bigger foam filter that fits stock airbox, 155cc injector, E10 93 gasoline (makes eye contact with E0 gang), and i set the redline back to stock because nothing really happens above that RPM with my setup. it just sort of dies quick up there and its probably the timing.

Fuel Map:
155FuelMap.png

Accel Pump:
155AccelPump.png

Lamba Target/Actual Lambda (lower value = more fuel -- 1.0 = stoich)

155LambdaTargets.png

As you can see its pulling fuel just about everywhere so that should help put fueling into perspective for everyone. The accel pump is still a mystery. you need a mostly converged fuel map before tuning the accel pump. the constant changes cause a bunch of noise and confusion so the best thing to do is tune the map until the cells you normally hit are 95% of the way to target then you can start tuning the accel pump. the 155 accel pump data above should be good enough because it didn't change anything in the last 2 runs. The accel pump is the magic sauce. when it gets turned on throttle snaps just become so crisp. low speed maneuverability and responsiveness come alive. its really neat to feel the difference.

in the spring ill switch to the PCX125 injector and take that one all the way. I should also have 14t/42t sprockets by then and that should put redline around 60mph so that should allow me to use more of my powerband in 4th and hopefully have some good acceleration numbers and estimated HP and Tq based on rear wheel rotation aceleration.
 

dampdog

Well-known member
Joined
Jul 24, 2026
Messages
366
Location
Mild & Cooling America
Sorry about your broken garage and lifter problem. Fix the lifters and maybe you'll have a few good riding days sprinkled throughout the winter.

Do you have any performance metrics you're using to measure gains? I'm just curious what you're seeing on the road.
 

JPMcGraw

Active member
Joined
Apr 13, 2022
Messages
131
Kind of but they are super inconsistent since I haven't done any dedicated "dyno" runs or put much time into that math. Once I get a fully converged map and accel pump I can go find a flat to do some consistent performance runs then slop together some better performance math.

Right now its using rear wheel rotation acceleration to calculate power. It's aware of what gear I'm in and only takes readings from 3rd and 4th gear on a flat or incline. It uses the phones barometer and gps to figure out slope and it's far from perfect right now.

When I ask it about HP its anywhere from 7-12hp (wheel). I'm thinking 8-9hp sounds right for the mods. When I ask about Torque I get 7-9ft-lb (wheel). That math was all put down a while ago by Gemini Flash 3.5 so that explains the wide range. I moved over to Anthropic so when I get to performance math slopping I'm sure it's going to be completely overhauled. Opus just does a better job of being aware of it's "surroundings" and thinking multiple steps ahead. That's needed for someone like me who sucks at math and can't code.

The one thing that is (suspiciously) consistent is where it puts peak power (I wouldn't be surprised if Gemini just hard coded these ranges and that's why they are so consistent ::shakes fist:: ).

Peak HP is always 6500-7000rpm
Peak torque is always 5000-5500rpm
So the fun range is 5000-7000rpm

Like I said though, that's Gemini slop code doing these calculations so grain of salt. Even when Opus or whatever crazy model is out next spring overhauls performance math it's still grain of salt slop math. I don't have a way to verify performance yet like I do tuning (O2 and Wideband).
 
Top