Members Login
Username 
 
Password 
    Remember Me  
Post Info TOPIC: Timer function


Guru

Status: Offline
Posts: 2338
Date:
Timer function


One of the mysteries of the ecu has always been the ability for ecu to adjust fuel and ignition signals. And its still a mystery to me how that actually happens. To explain the timer functionality of sh7052 in ECU context is something I would appreciate help and feedback from the members of this board.

Particularly I am looking for help in finding the ATU instructions (writes to 0xFFFF7???) that are used for setting the ATU timer outputs that control the PortK pins ???

In busa ecu the PortK pins 1,2,3,4 and 9,10,11,12 are defined as outputs and other Port K pins as inputs. Based on the initial tracing the TIOB seems to be one of the signal inputs and possibly TI10 the other.

To check that the injector and ignition coil outputs the reverse voltage pulse after the driver is disengaged there seems to be a feedback to the other PK pins,  but those I have not really traced from the board properly.

IG4Timer Out TO8LPK11
IG3Timer Out TO8KPK10
IG2Timer Out TO8JPK9
IG1Timer Out TO8IPK8
Inj4Timer Out TO8DPK3
Inj3Timer Out TO8CPK2
Inj2Timer Out TO8BPK1
Inj1Timer Out TO8APK0

n-109PB14/TI10
n+109PB14/TI10
g-75PA1/TIOB
g+75PA1/TIOB


__________________

When asking a question, you can also consider posting it to facebook:

http://www.facebook.com/ecueditorcom



Guru

Status: Offline
Posts: 2338
Date:

Let me be more precise, this is starting point of what I know.., .idc updated accordingly.

ROM:0000028C                 .data.l loc_2120
ROM:00000290                 .data.l Interrupt_OSIM_loc_2152
ROM:00000294                 .data.l Interrupt_OSIN_loc_2186
ROM:00000298                 .data.l loc_21E0

.............

ROM:00003AAA                 mov.w   @(h'98,pc), r1 ; [00003B46] = h'D0 ;  [00003B46] = h'D0 (11010000)
ROM:00003AAA                                         ;               Bit 4, Counting on external input cycle x 32
ROM:00003AAA                                         ;               Bit 6, Halted when = x multiplication factor
ROM:00003AAA                                         ;               Bit 7, Transfer to RLD10C when input capture halted
ROM:00003AAC                 mov.b   r1, @r0
ROM:00003AAE                 mov     #h'16, r2       ; Enable counter clearing for channel 2 (Timer function)
ROM:00003AB0                 mov.w   @(h'96,pc), r1 ; [00003B4A] = h'F6E4
ROM:00003AB2                 mov.b   r2, @r1         ; TIER10 Timer interrupt enable 10
ROM:00003AB4                 mov.w   @(h'94,pc), r3 ; [00003B4C] = h'F6EA
ROM:00003AB6                 mov     #b'10, r7       ; ICI 10 Enabled
ROM:00003AB8                 mov.w   r7, @r3
ROM:00003ABA                 mov.w   @(h'90,pc), r2 ; [00003B4E] = h'F42C
ROM:00003ABC                 mov.w   @r2, r2
ROM:00003ABE                 mov.w   @(h'8E,pc), r0 ; [00003B50] = h'FE ;  [00003B50] = h'FE (11111110)
ROM:00003AC0                 mov.w   @(h'8A,pc), r2 ; [00003B4E] = h'F42C
ROM:00003AC2                 mov.w   r0, @r2         ; 11111110 -> TSR0
ROM:00003AC4                 mov.w   @(h'8A,pc), r1 ; [00003B52] = h'F42E
ROM:00003AC6                 mov.w   r7, @r1
ROM:00003AC8                 add     #-h'2A, r3
ROM:00003ACA                 mov.l   r4, @r3
ROM:00003ACC                 mov.w   @(h'84,pc), r0 ; [00003B54] = h'F6D4 ; Output compare register
ROM:00003ACE                 mov     #-1, r2
ROM:00003AD0                 mov.l   r2, @r0
ROM:00003AD2                 mov.w   @(h'80,pc), r1 ; [00003B56] = h'F6C4 ; event counter 10B
ROM:00003AD4                 mov.b   r4, @r1
ROM:00003AD6                 add     #h'18, r3
ROM:00003AD8                 mov.b   r6, @r3
ROM:00003ADA                 mov     #1, r6
ROM:00003ADC                 mov.w   @(h'78,pc), r2 ; [00003B58] = h'F6C6 ; reload counter
ROM:00003ADE                 mov.w   r6, @r2



-- Edited by PetriK at 19:19, 2007-12-18

__________________

When asking a question, you can also consider posting it to facebook:

http://www.facebook.com/ecueditorcom



Guru

Status: Offline
Posts: 2338
Date:

Small progress.... but still very far away... so hints would be appreciated as my skills on understanding the timers is very limited.

The timer registers are defined as an array:
ROM:000068E8 Down_Counter_and_Compare_Registers_dword_68E8:.data.l h'FFFFF650      ; 0
ROM:000068E8                                         ; DATA XREF: Set_Timers_sub_4734:off_47B4o
ROM:000068E8                                         ; ROM:off_4988o ...
ROM:000068E8                 .data.l h'FFFFF614      ; 1
ROM:000068E8                 .data.l h'FFFFF604      ; 2
ROM:000068E8                 .data.l h'1000100       ; 3
ROM:000068E8                 .data.l h'FFFFF652      ; 4
ROM:000068E8                 .data.l h'FFFFF616      ; 5
ROM:000068E8                 .data.l h'FFFFF606      ; 6
ROM:000068E8                 .data.l h'2000200       ; 7
ROM:000068E8                 .data.l h'FFFFF656      ; 8
ROM:000068E8                 .data.l h'FFFFF61A      ; 9
ROM:000068E8                 .data.l h'FFFFF60A      ; 10
ROM:000068E8                 .data.l h'8000800       ; 11
ROM:000068E8                 .data.l h'FFFFF654      ; 12
ROM:000068E8                 .data.l h'FFFFF618      ; 13
ROM:000068E8                 .data.l h'FFFFF608      ; 14
ROM:000068E8                 .data.l h'4000400       ; 15


Then the timer output is inverted (zeroed ?) in sub_4734, but still very far away from understanding the way the timers are used to control the ignition and fuel injection timing.

ROM:00004734 Set_Timers_sub_4734:                    ; CODE XREF: sub_447C+26Ep
ROM:00004734                 mov.l   r14, @-r15
ROM:00004736                 mov     r5, r0
ROM:00004738                 mov.w   @(h'64,pc), r3 ; [000047A0] = h'F600 ; TCNT2A free running counter 2
ROM:0000473A                 mov     r4, r14
ROM:0000473C                 mov.l   r13, @-r15
ROM:0000473E                 mov.l   r12, @-r15
ROM:00004740                 sts.l   pr, @-r15
ROM:00004742                 add     #-h'10, r15
ROM:00004744                 mov.w   r0, @(8,r15)
ROM:00004746                 mov.w   @r3, r4
ROM:00004748                 mov.l   @(h'64,pc), r5 ; [000047B0] = unk_FFFF
ROM:0000474A                 extu.b  r14, r13
ROM:0000474C                 mov.l   @(h'64,pc), r12 ; [000047B4] = Down_Counter_and_Compare_Registers_dword_68E8
ROM:0000474E                 add     r5, r4
ROM:00004750                 shll2   r13
ROM:00004752                 shll2   r13
ROM:00004754                 add     r12, r13
ROM:00004756                 mov.l   @(4,r13), r2
ROM:00004758                 mov.w   r4, @r2
ROM:0000475A                 mov.w   @(h'44,pc), r4 ; [000047A2] = h'F664 ; One shot pulse terminate register


-- Edited by PetriK at 18:22, 2007-12-21

__________________

When asking a question, you can also consider posting it to facebook:

http://www.facebook.com/ecueditorcom



Guru

Status: Offline
Posts: 964
Date:

Sorry I don't have more time to look at this stuff and others you have posted but my free time is pretty much spoken for between now and after Christmas.

__________________


Member

Status: Offline
Posts: 21
Date:


Just keep in mind when you are thinking about that the ignition coils and the injectors are always powered.

The ECU earths them for the designated time.

They are both coils , so dwel is important.

I know it's not what you are asking but I though it might be important to keep in mind.

__________________


Guru

Status: Offline
Posts: 964
Date:

Another thing that I guess I take for granted that everyone knows is how these work on a free run counter.

There is timer called the free run counter it just counts continuously


0, 1, 2, 3 ...... FFFFFFFD, FFFFFFFE, FFFFFFFF, 0 1, 2, 3 ....FFFFFFFE, FFFFFFFF, 0, 1 ,2 , etc.

Now the ignition and injector registers are compare registers, they don't really count. You put a value into them and when that value equals the free run timer it changes the pin state or generates an interrupt. For example you decide that the injector needs to fire for 500 units.

You read the free run timer and its some value, say 11220000. You add 500 to it and save 11220500 to the injector compare register. The free run counter keeps counting, as it always is, 11220001, 11220002, 11220003.... When it reaches 11220500 it changes the state of the injector pin or interrupts because the compare register now equals the free run counter.

Its like wanting to time something for 30 seconds on a watch. Not a stop watch that resets to zero then counts up 30 seconds. Its like your watch. You look at the time and see that it is 12:24:10 and calculate that the 30 seconds will have elapsed at 12:24:40.

So you will see the software read the free run, add a value to it then stick it in the compare register then stop. The compare will most likely trigger an interrupt and the pin changes will actually be done in the interrupt service routine.

Of course it doesn't always time the on dwell. It could be timing a delay until on. The ignition for example actually sparks when you turn off the coil. So you delay to turn it on. Leave it on a specific time to energize it, then turn it off to spark it.

On the ignition the software calculates in terms of degrees, not time, even though it is measured in time. The time, or clock pulses, it takes to spin the crank 360 deg changes with RPM but the software doesn't really care what the actual value is. Whatever the value half of it is 180 degrees, a fourth of it is 90 degrees. So for calculating timing advance if it decides on 15 degrees it will calc it as (15/360) * last_revolution_time.

Hope that helps.

__________________


Guru

Status: Offline
Posts: 2338
Date:

Thanks RR about clarifying the timers, and dont worry about answering - I really hope that there is wider competence base on this board that sparks the discussions. Even though this topic may be the hardest to cover. And xmas, yes its making the life so busy, on the other hand this project gives an opportunity to relax a bit ...

For Stocky - yes, the positive voltage is important from two perspective. First of all depending on the voltage level the ECU calculates a fuel injector compensation as the opening time is dependant on running voltage. Secondly after releasing the grounding through the ECU the coils send a voltage peak from which the ECU recognizes that the coil is in good condition.

How dwell is controlled by ECU, that is still a puzzle for me - as the code around that part gets very tricky. It was not even disassembled properly which I needed to hand fix during past couple of days.

I hope to find the variables that control the opening time and dwell which then will lead me into how the contents of these variables is calculated leading to understand the relations of each map into the fuel and ingition delivery.





__________________

When asking a question, you can also consider posting it to facebook:

http://www.facebook.com/ecueditorcom



Guru

Status: Offline
Posts: 964
Date:

PetriK wrote:
...How dwell is controlled by ECU, that is still a puzzle for me - as the code around that part gets very tricky. ...

Tricky is an understatement. I understand that as engineers we want to be able to quantify everything and think that we should be able to break it down to some kind of formula like

[MapA + (x * MapB)/y] -z  /  38

And given enough time and determination I'm sure we could but after spending many many hours traveling down this road I stopped and asked myself why am I doing this?

I wanted an Excel spreadsheet that would take into account all the variables used and had all the functions defined so that I could plug map values into it, get a result, changed them and determine the magnitude of effect each map value had.  I started it with three basic values loaded into the injector timers:1,2, and 3. 1 was a 2d map output. 2 was the sum of 5 other variables I called 2a, 2b, 2c, etc.  3 was the product of some complex formula that had 8 dependent variables 3a, 3b, 3c, etc. Some of these like 3b were map outputs but others were the product of still more variables so I had 2a1, 2a2, 2a3. Soon I was over 50+ variables. Ok I thought just look at how they are used in the formula and concentrate on the those that have the greatest effect on the final product. I got bogged down there too.

As I said I stood back and asked myself what am I doing? Even if I were successful what would I have. So I know that changing this map value changes the injector time by changing this variable of this equation, what practical use is that to a guy who just put an aftermarket pipe on his bike?  How are you going to figure out the NUMBERS on his pipe? How are you going to come up with a formula to describe the effect his new pipe has on the bike and factor it in to your existing formula? 

Your not. Your going to put the bike on a dyno or road test it and thru a process of trial and error tune the bike for max performance. Even if you figure the map values out so you can say change this map by X and you'll increase the fuel mass by 1 gram per second what good does it do you? You don't know how many grams then new pipe needs at each RPM / Throttle setting.

If you walk into a dyno shop and say just tell me how many more grams you need at what Cubic Meters per minute airflow and I'll punch it into the program and get the map values they are just going to stare at you. What they want is to be able to adjust the values while the bike is running on the dyno and then save those changes into the maps. 

No one cares what 56 in this particular cell of this map means in real world terms. They just know that 57 was too rich and 55 was too lean.

YES we need to know which maps are fuel and which are ignition
YES we need to know which maps are Alpha-n or speed density or temperature etc.
YES we need to know which maps are used under which loads conditions.

Do we need to know exactly how each map value effects the final injector pulse? I don't think so. It would be nice but I think the time spent on figuring it out would be better spent working out a realtime tuning scheme.

I'm not sure how far you planned on tracking down these injector timer values but be careful you don't get sucked down a black hole for nothing  :)


 



__________________


Guru

Status: Offline
Posts: 2338
Date:

Thanks for an honest view on priorities. I agree with you that it is possible to get distracted from the main goal which is to generate tuning tools for sh7052 equipped bikes.

The information I need is to learn enough to be able to tune the bike for LSR and quarter mile events for next year. That requires me to understand which map is selected for what purpose and what limiter for what purpose. Currenlty the more I read the code the more there is new information that affects the behavirour of the bike. Like the fact that for each A/B map there is a counter map for clutch, i.e. when doing a clutched gear change the map is selected accordingly per gear. Also there is three different sets of rpm limiters, not two as I suspected earlier.

The objective is to be able to document the purpose of each key map and constant into enginuity .xml. That objective is becoming very near to be reached now.

For tuning I need to understand how many degrees of timing change is one unit - that information is needed for Nitrous to reduce appr 2degrees of timing. The alternative strategy is to measure the changes with an external device. For AFR tuning the units are much less critical, all I need to know is min and max values that can be entered.

The timer functions after what you read are becoming much more clearer now. I managed to resolve the crankpulse variable which is critical for understanding the timers and purposes of some key functions. Thank you for showing the way.

.idc updated accordingly.


__________________

When asking a question, you can also consider posting it to facebook:

http://www.facebook.com/ecueditorcom



Member

Status: Offline
Posts: 21
Date:


It would be interesting (from a nitrous point of view) to see how much difference there is in ignition timing for different gears.

You might be able to simply keep the ingnition table in a "lower gear" when you use the gas to keep the timing out of it.

If you are using any more the 20hp I'd be taking more than 2 degrees out too.

__________________


Guru

Status: Offline
Posts: 2338
Date:

Had finally some more time to look at the timer functions as part of the process of figuring out how the maps are interrelated.

As written earlier the starting point is tracing from Harness pins to CPU pins to figure out to which pins each coil is connected. That tracing revealed the following information:

PKCRH, one shot pulse mode
IG4Timer Out TO8LPK11
IG3Timer Out TO8KPK10
IG2Timer Out TO8JPK9
IG1Timer Out TO8IPK8
PKCRL
Inj4TO8D, one shot modePK3
Inj3TO8C, one shot modePK2
Inj2TO8B, one shot modePK1
Inj1TO8A, one shot modePK0



Then some hours with Busa code revealed that the actual registers are handled as an array that contains the registers and bits for setting the fuel and ignition pulses:

ROM:000068E8 Ignition_Down_Counter_and_Compare_Registers_dword_68E8:.data.l h'FFFFF650      ; 0
ROM:000068E8                                         ; DATA XREF: Ignition_Timers_sub_4734:off_47B4o
ROM:000068E8                                         ; ROM:off_4988o ...
ROM:000068E8                 .data.l h'FFFFF614      ; 1
ROM:000068E8                 .data.l h'FFFFF604      ; 2
ROM:000068E8                 .data.l h'1000100       ; 3
ROM:000068E8                 .data.l h'FFFFF652      ; 4
ROM:000068E8                 .data.l h'FFFFF616      ; 5
ROM:000068E8                 .data.l h'FFFFF606      ; 6
ROM:000068E8                 .data.l h'2000200       ; 7
ROM:000068E8                 .data.l h'FFFFF656      ; 8
ROM:000068E8                 .data.l h'FFFFF61A      ; 9
ROM:000068E8                 .data.l h'FFFFF60A      ; 10
ROM:000068E8                 .data.l h'8000800       ; 11
ROM:000068E8                 .data.l h'FFFFF654      ; 12
ROM:000068E8                 .data.l h'FFFFF618      ; 13
ROM:000068E8                 .data.l h'FFFFF608      ; 14
ROM:000068E8                 .data.l h'4000400       ; 15
ROM:00006928 Crankpulse_plus_360degrees_byte_6928:.data.b h'1E, h'2A, 6, h'12
ROM:00006928                                         ; DATA XREF: Ignition_Timers_for_cylinder_sub_447C:off_4598o
ROM:00006928                                         ; Ignition_Timers_for_cylinder_sub_447C:off_466Co ...
ROM:0000692C Crankpulse_byte_692C:.data.b 6, h'12, h'1E, h'2A
ROM:0000692C                                         ; DATA XREF: Ignition_Timers_for_cylinder_sub_447C:off_4594o
ROM:00006930 Crankpulse_plus_3_byte_6930:.data.b h'21, h'2D, 9, h'15
ROM:00006930                                         ; DATA XREF: ROM:off_49A4o
ROM:00006934 Crankpulse_plus_1_byte_6934:.data.b 7, h'13, h'1F, h'2B
ROM:00006934                                         ; DATA XREF: Ignition_Timers_for_cylinder_sub_447C:off_459Co
ROM:00006938 Fuel_GR_and_DownCounter_registers_word_6938:.data.l h'FFFFF444      ; 0
ROM:00006938                                         ; DATA XREF: ROM:off_5FF0o
ROM:00006938                                         ; Set_Timers_sub_60BE:GR1A_ptro ...
ROM:00006938                 .data.l h'FFFFF640      ; 1
ROM:00006938                 .data.l h'10001         ; 2
ROM:00006938                 .data.l h'10000         ; 3
ROM:00006938                 .data.l h'FFFFF446      ; 4
ROM:00006938                 .data.l h'FFFFF642      ; 5
ROM:00006938                 .data.l h'20002         ; 6
ROM:00006938                 .data.l h'20000         ; 7
ROM:00006938                 .data.l h'FFFFF44A      ; 8
ROM:00006938                 .data.l h'FFFFF646      ; 9
ROM:00006938                 .data.l h'80008         ; 10
ROM:00006938                 .data.l h'80000         ; 11
ROM:00006938                 .data.l h'FFFFF448      ; 12
ROM:00006938                 .data.l h'FFFFF644      ; 13
ROM:00006938                 .data.l h'40004         ; 14
ROM:00006938                 .data.l h'40000         ; 15


This information helped to link the fuel injectors with each of the ports hopefully helping me now to identify that what are the maps that are used in building the injector and ignition timing.



__________________

When asking a question, you can also consider posting it to facebook:

http://www.facebook.com/ecueditorcom

Page 1 of 1  sorted by
 
Quick Reply

Please log in to post quick replies.

Tweet this page Post to Digg Post to Del.icio.us


Create your own FREE Forum
Report Abuse
Powered by ActiveBoard