Spark/dwell timing when rpm varies

This is a forum for discussing the development and testing of alpha MS2/Extra code. Documentation
(Runs on MS2 and Microsquirt)

Moderators: jsmcortina, muythaibxr

Post Reply
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Spark/dwell timing when rpm varies

Post by jartzi »

I changed my project code so that it give spark when 2nd trigger got pulse which came at every TDC. This is for cranking only and give solid spark timing.
Now i am testing that i get smooth move to 6-1 wheel triggered spark when moved to cranking to running. Lowered cranking speed limit value so that engine goes running state quickly.

When i rotated engine without sparkplug i got constantly timed spark.But if i put plug on and try kickstart spark timing varies too much. Only reason which came to my mind is that because i have 1cyl high compression light flywheel engine it slows down so much at compression cycle that spark event timer values are not valid anymore.

In SW when spark event tooth is detected at wheel decoder, spark timer values are updated latest ones, if latest values are still using same tooth for calculations.
I am wondering how often main loop updates new values aprox?

Does it worth to try calculate new spark and dwell times with last tooth tics/deg values for timers every time when spark event tooth is detected? Maybe in worst case tooth need to been skipped and calculate times for next tooth? Is there time for this kind of calculations? Maybe low rpm only?
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

Timing is set to fixed no spark tables are used yet.
When i rotate engine without plug. At 1500 rpm timing is quite good but at 800 rpm it gives spark in two different places, if i keep drill very hard in my hands diff is smaller. Wastes spark is in use so maybe cam and valves slow down rpm in every 2nd rev.
Matt Cramer
Super MS/Extra'er
Posts: 17499
Joined: Thu Apr 16, 2009 8:08 pm

Re: Spark/dwell timing when rpm varies

Post by Matt Cramer »

Missing tooth wheels are a bear to kick start - the rapid RPM changes can hide the missing tooth or make other teeth appear to be missing. The best solution is to use a different arrangement like dual wheel.
Matt Cramer -1966 Dodge Dart slant six running on MS3X
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

Actually i already tried dual wheel but it not made things better. I dont get any sync losts now.
Came just to my mind that if i got 6 waves/rev from battery charging coil i can use it. Or maybe full wave rectificate it to get 12 pulses/rev.
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

i am pretty sure that timing varies because when mainloop calculates tooth events and time after that tooth it uses latest available measured tooth time. Which tooth time it supposed to be varies. Easiest way is use average time of whole revolution (or two) and div it by tooth/rev count or use always same tooth time which is not always available.

I will try hard way.
- Only toothed wheel support to get more memory.
- Only even deg tooth wheel to get rid of time consuming for and while loops.
- Modify events so that mainloop store only tooth and angle after tooth to event.
- Events can be array of events which are sorted to queue using pointers so that next needed event is keeped in pointer to get quick access and when used it can be updated quickly to next one. Used ones is used for filling from main loop so does not need separate temporary events. Separate queues for spark, dwell, map and fuel events or one common for all would be nice but maybe difficult to implement.
- Always when tooth decoder (tooth interrupt) get new tooth time it try predict next tooth time based on latest and previous tooth times.
Maybe it is better to use only latest time because at low rpm when compression cycle changes to power cycle predict will fail.
- When tooth decoder detect that there is any event for current tooth it calculates angle after tooth to time after tooth with predicted time.
- Fuel squirts every rev half of amout if 4-stroker phase is not detected. Full amount if phase detected If i move to MAP phase detection in future. When cranking currently it squirts every rev, but for better idle squirt per rev is maybe better than per cycle if phase not known.
- Not give spark or fuel if time/deg is too big. Engine is stalled or almost stalled (risk for kick back).

I dont have no idea how bysy main loop is. Does it have enough time to update events. Because tooth decoder not use "old" events and if events run out engine will start missfiring.
Most propably i spend many hous for these changes without getting things any better, but least i tried. :D
jsmcortina
Site Admin
Posts: 39587
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Spark/dwell timing when rpm varies

Post by jsmcortina »

We've already spent many years working on the issues you describe and coding for a workable solution. If you are experiencing spark timing weirdness having just implemented a new wheel decoder, then may I suggest you look at that decoder first rather than the rest of the code.

For very low tooth-count wheels, you may want to look at the distributor code that does a time calculation right in the ign_in interrupt. (Search for muldiv)

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

Thanks for tip. I blindly removed all Dizzy code so did not see that.
But maybe i am so deeb in my own sollution that i will try it. I have removed much code so i have room to made big changes.
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

Planning to use timer precaler when wheel tooth count is low. Using prescaler i get rid of slow 32bit SW timers.
Is there any debug or trace possibilities?
Maybe i ended rewrite whole SW.
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

Is there bug in isr_rtc.c when dwell or spark queue timer ellapses timer is started. But there are not added current TCNT register value to compare register.
Second thing if 1st queue timer fires second one is not counted.

dq1:
ldx dwellq
beq dq2
ldy dwellq+4
dey
sty dwellq+4
bne dq2
clr dwellq
clr dwellq+1
ldd dwellq+2
bsr dq_fire

dq2:
ldx dwellq+6
beq dq_done
ldy dwellq+10
dey
sty dwellq+10
bne dq_done
clr dwellq+6
clr dwellq+7
ldd dwellq+8
bsr dq_fire

bra dq_done

dq_fire:
xgdx
stab dwellsel
stx TC_dwl
movb #TFLG_dwl, TFLG1
bset TIE, #TFLG_dwl
rts

should this be like this:

dq1:
ldx dwellq
beq dq2
ldy dwellq+4
dey
sty dwellq+4
bne dq2
clr dwellq
clr dwellq+1
ldd dwellq+2
addd TCNT
bsr dq_fire

dq2:
ldx dwellq+6
beq dq_done
ldy dwellq+10
dey
sty dwellq+10
bne dq_done
clr dwellq+6
clr dwellq+7
ldd dwellq+8
addd TCNT
bsr dq_fire

bra dq_done

dq_fire:
xgdx
stab dwellsel
stx TC_dwl
movb #TFLG_dwl, TFLG1
bset TIE, #TFLG_dwl
rts
jsmcortina
Site Admin
Posts: 39587
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Re: Spark/dwell timing when rpm varies

Post by jsmcortina »

No, that's not correct on either count.

The dwell queue timer relates to the crank tooth it is scheduled from not the current timer. TC0 was already added on when the queue was filled.

Both queue counters downcount.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

Ok now i get it.

There is
time_us = TC0this + next_spark.time16_low;
when timer is started and rtc clock is excactly 192 times slower.

How about in fire_coil routine:

tas_set:
addd TC_ign
std TC_dwl ; set up dwell timer for prescribed time later
bset TIE,#TFLG_dwl
movb #TFLG_dwl,TFLG1

Should here been added current count not TC_ign because fire_coil is not always called from ISR_Ign_TimerOut?
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

Maybe i dont fully understand this dwell and spark queques but.
When timer started there is check not to use timer directly if time is same or greater than 250. This timer can as i know count to 35536. This is so maybe because it is better to use queue and 250 is greater than 192 which would be rtc minimum.
Then when queue timer is started first rtc dec of this timer can be happened any time after 0-0.128ms or how rtc in synced?
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

You did answer this already. So this is the reason why TCNT is not used. to get rtc synced to tooth event.
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

When time after spark is in use should ign lines put inverted state in FIRE_ALL and FIRE_ALL_US macros?
jartzi
Helpful MS/Extra'er
Posts: 90
Joined: Fri Mar 27, 2015 7:57 am
Location: Finland

Re: Spark/dwell timing when rpm varies

Post by jartzi »

:yeah!:
Done big changes and my biggest fear did not happend. All these changes for nothing.
Got spark today. it is very stable. At 500 cranking rpm only few degs, and 1000 rpm not noticebly.
Did not tried to start yet. I managed to get tooth decoder light but does not know how much rpm it can handle.
Post Reply