NefMoto

Technical => Reverse Engineering => Topic started by: prj on March 14, 2021, 10:10:17 AM



Title: Custom C167 Boost PID
Post by: prj on March 14, 2021, 10:10:17 AM
Since I will never need this anymore, I will throw this out here.
The main routine needs to run in a 20ms-100ms loop.

The PID has pre-control, D-kick suppression, anti windup, steady state and dynamic modes as well as an on/off window. It also has an application mode to force DC based on RPM.
I wrote it in assembler from scratch more than 5 years ago.

The GitHub repo contains the assembly code, and a sample implementation on a VR5 file. Including re-configuring the inlet manifold flaps switch output into a N75 PWM output.
I used the Keil assembler to assemble the code.

The controller works off of pssol_w as the setpoint and ps_w as the measurement. Whether from MAF or from SD calculation, both work equally well.
It can be used to add real boost control to things like VR5 and VR6 engines.

Do not ask me to implement it in your file unless you are ready to pay 4 digits.
If you have any questions, post them here.
I would rate the difficulty of integrating this as "advanced". If you do not have a good grip on assembler and C167, just move along, nothing to see here.

GitHub repo:
https://github.com/prj/C167BoostControl (https://github.com/prj/C167BoostControl)


Title: Re: Custom C167 Boost PID
Post by: RBPE on March 14, 2021, 01:05:23 PM
Nice!


Title: Re: Custom C167 Boost PID
Post by: prj on March 14, 2021, 04:17:02 PM
Yes, now put it to use :)

I need to release a lot more stuff I've been sitting on, since it has no monetary value for me anymore...
If I only had the time.


Title: Re: Custom C167 Boost PID
Post by: sda2 on March 24, 2021, 03:29:50 AM
Thank you very much for this piece of code! We will see how good this works in a non Bosch ECU :)

Attached you'll find an XDF made from the CSV you provided.


Title: Re: Custom C167 Boost PID
Post by: prj on March 24, 2021, 04:46:36 AM
It does not care very much about ECU in particular.
But you of course must provide your own actual pressure and target (pressure) and do some modifications.

You will need to patch in a "ldrxn" style map somewhere into the ECU.
And you will need to find how to configure the end stage for the correct frequency.
The biggest change is probably the fact that the map lookup routines are going to be different...


Title: Re: Custom C167 Boost PID
Post by: dream on March 27, 2021, 03:03:22 PM
Thank you for your contribution again Prj :)


Title: Re: Custom C167 Boost PID
Post by: jibberjive on April 04, 2021, 02:05:18 AM
Very cool.


Title: Re: Custom C167 Boost PID
Post by: jochen_145 on April 04, 2021, 04:41:18 AM
Great stuff, thanks for sharing  8)

btw.:
does someone got a A2L, Damos o.i. for 066906032A of prj´s example ?


Title: Re: Custom C167 Boost PID
Post by: prj on April 06, 2021, 12:24:02 PM
I certainly did not when I made it... NA->Turbo, no damos, no problem :D

I looked and I don't think I do even now.
But really, it should not be so hard to adapt the code. If you have a question about what is what in the binary, I can answer.


Title: Re: Custom C167 Boost PID
Post by: jochen_145 on April 06, 2021, 12:42:37 PM
Thanks,
I do not plan to start sutch a project, but someone in a german TT-forum got the idee to build an 5-cylinder-turbo TT "RS" 8N based on the VR5..

So I´d like to search a little in the dump and playing around to extend the dump run with a proper and linear torque-model. Even chancing MDNORM to a proper value have effect to a lot maps, as you know..

I am too mutch OEM infected to run bended maps and start without the A2L meanwhile  :-X


Title: Re: Custom C167 Boost PID
Post by: prj on April 07, 2021, 02:01:12 AM
Well that's what I did this for 5 or 6 years ago, a Golf mk2 IIRC with a VR5 engine and they managed to make a flange to fit a RS3 turbo on it with the manifold.


Title: Re: Custom C167 Boost PID
Post by: Blazius on April 14, 2021, 01:41:08 PM
Right well to bump this , I would be interested in giving this a go on a non turbo ecu before switching over to 1.8t ( yes still haven't done that, no time + thanks 'rona), however I dont think i possess enough asm skills to pull this off specially without a2l.. eh regardless I got some questions.

there are some CC 00's - the native writes ( I guess) which you mentioned to pw1 that are changed at 702B6-702496  how did you find these exactly, how would one find these in a completely different bin for example, dont seem to find much on this topic.
Just ref from PW1 (FE32) ? but still who knows how many hits that produces

6432E+ - 2 things changed (cmp r8/ mov r4) these are the hard caps I assume.

Also, there are 2 calls after eachother at 2030A (unless I misunderstand), one goes to 8c57e which "just" seems like a normal part of the bin - what is the reason behind this, the second one goes to the boostcontrol function.


Do you by any chance have the idb for the example file even without damos I guess you defined it quite extensively , would that be something that you would share?


Title: Re: Custom C167 Boost PID
Post by: Blazius on April 18, 2021, 06:44:15 PM

Well figured it out.. I was actually dumb and completely forgot about the hookin, the first calls actually calls the normal function that was replaced  by the call to run the custom PID routine...

The writes to Port 7 bit 1(PW1) have to be disabled for this to work , there are bmov's from B_su (intake changeover on these cars) , like mentioned N75 output is used for the changover valve, nop these.
Rlsol hardcap was adjusted on the example file, also dont forget about the calls to the load by gear (last part of the custom code) where rlssol gets assigned.

That said I will probably attempt this on my own car if I ever get the downtime for it, then get back with feedback hopefully.

Thanks.


Title: Re: Custom C167 Boost PID
Post by: Pr3muToS on April 01, 2023, 06:07:35 PM
@pjr did you ever did some like this on st10 ?!


Title: Re: Custom C167 Boost PID
Post by: prj on April 02, 2023, 03:57:17 AM
@pjr did you ever did some like this on st10 ?!
What do you mean? This can be used on ST10 as well, it makes no difference.


Title: Re: Custom C167 Boost PID
Post by: IamwhoIam on April 02, 2023, 04:49:25 AM
pjr=PyJamaRama


Title: Re: Custom C167 Boost PID
Post by: fknbrkn on July 08, 2024, 05:57:58 AM
Quick question
Im in my way into R32T w 022906032DR
And pw1 used here for exhaust cam / pw0 for intake one
So maybe someone wants to save me a day of digging into code / logs  ;)


Title: Re: Custom C167 Boost PID
Post by: prj on July 08, 2024, 06:51:01 AM
There is usually PWM output for intake flap changeover. Or is it solved with an on/off on it?


Title: Re: Custom C167 Boost PID
Post by: Blazius on July 08, 2024, 11:46:05 AM
Quick question
Im in my way into R32T w 022906032DR
And pw1 used here for exhaust cam / pw0 for intake one
So maybe someone wants to save me a day of digging into code / logs  ;)


Yes. Use pw3 its free.

Thats what i did both on st10 and c167

Be aware you need configure the period register aswell.


Title: Re: Custom C167 Boost PID
Post by: fknbrkn on July 08, 2024, 01:55:16 PM
There is usually PWM output for intake flap changeover. Or is it solved with an on/off on it?

Seems that its only binary condition in this ECU

Quote
Yes. Use pw3 its free.

Thats what i did both on st10 and c167

Be aware you need configure the period register aswell.

Yep its free
At the 1.8t it seems that PW3 used for TEV with output to pin 64, can you confirm its the same pin?


Title: Re: Custom C167 Boost PID
Post by: Blazius on July 09, 2024, 05:29:46 PM
Seems that its only binary condition in this ECU

Yep its free
At the 1.8t it seems that PW3 used for TEV with output to pin 64, can you confirm its the same pin?

No its on pin 116 if I remember correctly. Positive is on 121 usually.


Title: Re: Custom C167 Boost PID
Post by: fknbrkn on July 19, 2024, 05:00:47 AM
No its on pin 116 if I remember correctly. Positive is on 121 usually.

Finally had a chance to test it and seems that pw3 on pin116 works like a charm
Thank you and also prj for this project  :)


Title: Re: Custom C167 Boost PID
Post by: fknbrkn on September 10, 2024, 10:49:08 AM
Just my 2c:

022906032DR file equipped with DSG

we had misfires at cyl1 and constant pwm even after shutoff after transfering routine from example file, all variables was fine, mono lambda patch also here, there is no load limit in this file

- all ram variables redefined to 387* instead of 384* this eliminate misfires, even if IDA shows empty space here, probably some ram-mirroring was there, ive faced this before so just swap it with 387xxx*

- changed turbo routine instead of feeding pwm it manages new ldtvm_w to be able to log wgdc and move pwm to its raster
- new code (below) with port writing hooks up with other pwm operations, i believe its 1ms raster, correctly operating pwm even with !b_kl

Code:
exts	#38h, #1
mov r4, ldtvm_w
movbz   r5, rl4
shl     r5, #8
mov     r4, PP3
mulu    r5, r4
mov     PW3, MDH
mov     r2, MDH

DPUPVDK calculates pvdkds_w based on ml_w in stock its subtracted map values from pu_w and i replaced it with addition due to map is not signed, this gives positive pvdkds_w and msdk_w now looking nice but i still thinking to replace it with native map sensor

RLVMXN/RLVSMXN maxed out to eliminate IOP limit and gives adequate misol_w, now its misol > miist, no torque intervention and car runs smoothly, ps_w, msdk_w, pvdks_w finally sorted out

asm patch for b_mdee (redsol) when shifting, basically some kind of 'jb b_zwget, loc_enable' so it gets selective fuel cut at shifts but unfortunately without noticeable sound

this knowledge costs me 2 days so enjoy it for free  :)


probably i want to emulate KFVPDKDS / KFPLGU stuff but im not sure for now // any hints?


Title: Re: Custom C167 Boost PID
Post by: Yur1i123rus on November 14, 2024, 01:47:30 PM
Hello friends. I am a newbie and I need help, in 1 month I have learned a lot by reading this forum, thanks guys. I'm trying to master this patch from Pjr. Now I can’t figure out how to track in ida which functions pw0, pw1, pw2 use. Even in the ori file from the example, I assume that I correctly found the function for controlling the damper for changing the length of the collector. But I don't see any reference to pw1 there. Nudge in the right direction


Title: Re: Custom C167 Boost PID
Post by: fknbrkn on November 14, 2024, 10:40:59 PM
Hello friends. I am a newbie and I need help, in 1 month I have learned a lot by reading this forum, thanks guys. I'm trying to master this patch from Pjr. Now I can’t figure out how to track in ida which functions pw0, pw1, pw2 use. Even in the ori file from the example, I assume that I correctly found the function for controlling the damper for changing the length of the collector. But I don't see any reference to pw1 there. Nudge in the right direction


just check cross-reference of PWs
thats simple code like

mov r5, pp1
mov r4, tev_w (didnt remember param names)
shl r4, #8
mulu r4, r5
mov pw1, MDH

there also part with port initializations where pws gets zero value


Title: Re: Custom C167 Boost PID
Post by: Yur1i123rus on January 09, 2025, 05:51:34 AM
Sorry for the long pause in my answer, but I needed a pause to digest all the information and take a break from these matters. Thank you very much.


Title: Re: Custom C167 Boost PID
Post by: Yur1i123rus on January 09, 2025, 06:30:06 AM
Tell me, is it a bad idea to use the brake booster pressure sensor input like fknbrkn did, just put it in the intake manifold and transfer the data to ps_w?


Title: Re: Custom C167 Boost PID
Post by: Yur1i123rus on January 09, 2025, 02:23:26 PM
or maybe it's better to create another variable ps and use it instead of ps_w in this boost control code.
And send data from the intake manifold pressure sensor to it. The main idea is to make the boostcontroller work with the pressure from the sensor. I think it shouldn't be that difficult for a beginner. Maybe I'm wrong and I'd like to hear your opinion.