Interrupt Priority Settings

Official FreeEMS vanilla firmware development, the heart and soul of the system!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Interrupt Priority Settings

Post by Fred »

I had a thought last night about how to get the best accuracy on our bit banged fuel and/or ignition pins. Clearly we want the RPM input ISRs to run first and foremost in every case. The primary RPM and position measurement one should have absolute top priority with the cam phase detection stuff falling in as a lower priority ISR, possibly after some others of high importance.

Then what?

Well, for any given set of related sequential pins (ign and fuel) you require 2 interrupt pins - this is because as dwell or duration changes over due to whatever, the on and off points will cross over each other and the math and logic to do it would be tricky if not impossible to do quickly enough to keep ISR runtime low. Now, the trouble is, the on and off pins can't ever run at the same time, so when the on and off timing of two pins comes in at the same time, one will lag the other.

The thought:

Run the ON on the S12 CPU and the OFF on the XGate CPU!

That way the ON and OFF of some related pins can run at EXACTLY the same time! Sure other things can screw this up a bit, but with appropriately short code run times and appropriate interrrupt priorities setup, it should work very well.

For IGN the dwell end timings are critical, so those should be on the fastest interrupts with the highest priorities. The dwell start timings are NOT critical and should be lower priority - provided that they are early enough and not, on average, too early, we're golden.

For fuel, the period matters, so both ends should be accurate if possible. We could potentially stick with the 6 cyl sequential or at least 6 cyl hardware timed limitation. Or we could suffer a minor accuracy hit and just bit bang those too. In the latter case we'll be left with 4 spare timers and up to 4 spare input capture timers. These would be super handy for doing stuff like wheel speed and other high input rate stuff. I'll ONLY accept this compromise if the fuel accuracy is sufficiently good bit banging. If it's not, then we stick with the wasted spark style semi sequential fueling for the 8, 10 and 12 cylinder engines and run with sequential on 1,2,3,4,5,6 cylinder engines.

This thread is primarily for information purposes, but I'm open to comments and input from anyone on anything.

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
jbelanger
LQFP144 - On Top Of The Game
Posts: 387
Joined: Sat Feb 23, 2008 8:58 pm
Contact:

Re: Interrupt Priority Settings

Post by jbelanger »

Dual spark plug engines and rotary engines will require the use of 2 additional timers if you want to allow split timing of the sparks. I don't know if that is useful for regular twin plug engines but rotary engines definitely use split timing. Similarly, if you have staged injectors with different capacity or even just progressive staging, you'll need to use the last 2 timers for these.

Jean
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Interrupt Priority Settings

Post by Fred »

Thanks Jean! I'd forgotten about chicken cookers, though staged is on my mind for sure. I guess the priority is to make it work exceptionally well for the most common cases, and let accuracy fall off a little bit as the setup becomes more obscure or extreme.

Thinking about it again, though, why does rotary need another timer? One fires, then some delay occurs and another fires, right?

Twin plug engines probably don't need any special attention.

Fred.

Disclaimer, its after 4am....
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
jbelanger
LQFP144 - On Top Of The Game
Posts: 387
Joined: Sat Feb 23, 2008 8:58 pm
Contact:

Re: Interrupt Priority Settings

Post by jbelanger »

Fred wrote:Thinking about it again, though, why does rotary need another timer? One fires, then some delay occurs and another fires, right?
Because they don't always fire in the same order. Split can be positive, negative or null. You can do that with a single timer but if you do that then you can also do the injectors with the same timer.

Jean
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Interrupt Priority Settings

Post by Fred »

Urrrrrr, positive negative or null? They are trailing plugs, fired after the main ones, exclusively, or so I thought. Feel free to educate me, esp with links.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
sry_not4sale
LQFP144 - On Top Of The Game
Posts: 568
Joined: Mon Mar 31, 2008 12:47 am
Location: New Zealand, land of the long white burnout
Contact:

Re: Interrupt Priority Settings

Post by sry_not4sale »

Trailing are sometimes fired before the primaries, e.g. at idle, or for fuel economy. Also, positive split varies and sometimes there is no split at all (e.g. some n/a applications).
Owner / Builder: 1983 Mazda Cosmo 12at (1200cc 2-rotor turbo) coupe [SPASTK]
165hp @ 6psi standard - fastest production car in japan Oct 82
MotoFab
1N4001 - Signed up
Posts: 307
Joined: Thu May 29, 2008 1:23 am
Location: Long Beach CA

Re: Interrupt Priority Settings

Post by MotoFab »

Fred wrote:Twin plug engines probably don't need any special attention.
A way to think of twin plugs on a piston motor is as 'flame front speed enhancement'.

The plugs fire at different times based on load (charge volume) and RPM. In the example of a four-valve twin-plug, the plug names are 'center' and 'side'. The side plug is the speed enhancer say.

The intention is to reduce power-robbing spark advance, while moving the power-adding peak cylinder pressure closer to the optimum crank angle.

Take the situation of low RPM and high load; At a stop, feeding in a lot of throttle and clutch for a low RPM torque-away start. In that condition, low RPM gives the flame front plenty of time to propagate, and also it propagates faster because of a high charge fill. But even so, the side plug is used to make the front even faster. That results in less spark advance, and better peak pressure angle.

At other RPMs, depending on charge fill, the side plug is fired positive, negative, or null, of the center plug. (don't you just love that!) All with the intention of reducing spark advance, and moving peak pressure to the best possible crank angle.

Anyway, you can think of rotary dual plug set up in the same way, as 'flame front speed control'. Sure, there's another variable of 'moving combustion chamber', but the intention is the same.
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Interrupt Priority Settings

Post by Fred »

We really need to have some weighting, that is what it comes down to.

negative impact on chicken cookers and dual sparkers vs positive impact on wheel speed sensor users

and +/- effect on simplicity of code and config in each direction

weighted by quantity of users for each relative to total user base size.

It seems to me that the negative impact of 0 split timing or just firing one plug on rotor and twin units is negligible in most cases. The extra complexity required and performance hit to other parts of the code base probably isn't negligible IMO.

One thing is for sure, it should be considered thoroughly and left open to possibile change in future where it makes sense and is possible to do so.

It'd be nice to get some techy chicken cooker experts in on this to sell the benefits of proper split control with detailed but understandable reasoning. It might be worth solicting input from such people.

Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
sry_not4sale
LQFP144 - On Top Of The Game
Posts: 568
Joined: Mon Mar 31, 2008 12:47 am
Location: New Zealand, land of the long white burnout
Contact:

Re: Interrupt Priority Settings

Post by sry_not4sale »

Well, chicken cooker performance is a deal breaker for me - so I'll get a good friend to write something up
Owner / Builder: 1983 Mazda Cosmo 12at (1200cc 2-rotor turbo) coupe [SPASTK]
165hp @ 6psi standard - fastest production car in japan Oct 82
User avatar
sry_not4sale
LQFP144 - On Top Of The Game
Posts: 568
Joined: Mon Mar 31, 2008 12:47 am
Location: New Zealand, land of the long white burnout
Contact:

Re: Interrupt Priority Settings

Post by sry_not4sale »

Well looks like lack of split is going to be no good for rotaries :(

We could skip the negative split, but we need some sort of positive split that varies with load.
Owner / Builder: 1983 Mazda Cosmo 12at (1200cc 2-rotor turbo) coupe [SPASTK]
165hp @ 6psi standard - fastest production car in japan Oct 82
Post Reply