Possible uses of our timer resources : ideas soon please!

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

Possible uses of our timer resources : ideas soon please!

Post by Fred »

Hi,

Because of our budget minded approach, we are using a chip that is NOT designed for engine control. It's designed for ABS systems etc, and consequently is somewhat light on timers for doing large cylinder count, or multiple injectors etc.

The question is, what can we use our timers for? (anything and everything please)

We have the following :
PIT - Periodic Interrupt Timer X 4 : 2 planned for ignition, 2 for staged injection
ECT - Enhanced Capture Timer X 8 : 6 planned for injection (main), 2 planned for engine position/RPM capture
MDC - Modulus Down Counter X 1 : Nothing yet, another PWM or ???
RTI - Real Time Interrupt : periodic interrupt based on bus clock, planned for doing things regularly, like keeping track of time

The use of the ECT module is pretty much pinned down, as are 2 and possibly 3 of the PIT timers, and the RTI (though this can do all sorts of things)

What can you think of (anything AT ALL) that we can do with the 1 or 2 spare PIT timers?

Following on from that...

I've been discussing staged injection with Flacid and his preference is to have individual control of staged injectors such that tapering in one fuel and out of another is possible, and controlling proportions of different fuels is possible.

My idea for staging was simply (and highly accurately) piggy back on the (otherwise unused) OC timer interrupts for the main injectors and set the pulsewidth correctly to take the dead times and flows into account. In this way you always get 2/3 secondary fuel if your secondarys are 1000cc and primaries 500cc.

This has the downside of possible non smooth turn on characteristics, and of course no control over the proportional nature of the flows. My gut feeling is that for most installations the fuel will be the same, and with sequential operation, the "coming in" of the second bank will be almost transparent anyway. No serious race car runs dual fuel systems and different fuels, they all just use one good fuel for all purposes.

Flacid wants to do this so he can put "expensive" race gas in a second tank and system and run pump gas out of and in low boost. This seems a nice idea, but the extra expense and complexity of the dual fuel systems and the chance of the secondary tank running out of the high octane juice and sending the engine to a quick destruction on the lean side seems quite high to me. You are certainly better off with no fuel than half of it.

Discussing this with Flacid just now, I realised that we could use one PIT timer to start the staged injectors sequentially at a different time and close them at the same time as the main injectors (or vice versa) with the ECT timer ISRs.

One thing is true with sequential ign/inj and that is that all end times will be evenly spaced, and all start times will be evenly spaced (minus the variation from changing conditions which is extremely unlikely to make them line up). For that reason, as far as I can tell, you only need two timers to bit bang any number of sequential channels fairly accurately.

Another thing I was thinking about is that rather than having semi sequential on 8, 10, 12 cyl engines, we could have fully sequential with a timer based interrupt bit banged system like that. However, it would (again) require special code of this type :

if cyl count > 6 {
bit bang
} else {
output compare
}

which i really dont like. I think for 8, 10, 12, the firing twice per cylinder per engine cycle is a non issue because using say 550cc injectors you could have massive power and decent control.

Having spent quite a while putting bits of this post together while doing other things, the idea of the PIT start (or stop) staged injection seems increasingly good to me, however, I am keen to hear what other timer uses you lot have that I haven't thought of, maybe one of them is more attractive than highly accurate staged injection?

Of course, the PIT ISR could start off with code like this :

If (staged) {
do staged stuff
} else if (your stuff here){
do your stuff here here
} else if (kjdkjfkd)

etc

such that something has a priority, and if it is enabled, it gets to run, and other stuff does not.

a single 'if' in that context is not going to cost much time, and more importantly, it will be a consistent amount of time that it costs ;-)

Thoughts? (please?!!?)

Admin.
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!
gearhead
LQFP112 - Up with the play
Posts: 120
Joined: Sun Feb 03, 2008 9:30 pm
Location: Chicago, USA

Re: Possible uses of our timer resources : ideas soon please!

Post by gearhead »

How does this relate to PWM outputs? On the one side we will need true PWM for idle control. This is a must, for me. Other PWM output could be used for boost control solenoid, VVT control...

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

Re: Possible uses of our timer resources : ideas soon please!

Post by Fred »

There are 8 hardware 8 bit PWM lines available that can be used for anything, and they can be combined in pairs to produce upto 4 16bit PWM lines. However, yes, a PIT channel could be used for generating more PWM goodness, as can the RTI code.

This is all we have for possible uses for PWM so far :
Idle valve (16 bit)
VVT (precision required?)
fuel pump (8 bit)
water pump (8 bit)
fans upto 2 (8 bit each)
boost control upto 2 (hard to know if 16 bit precision is required or not, but probably not if the right valve is chosen!)

The chances of that not being enough on a particular install are fairly slim I would say.

Thats a good point, but can you think of anything else that could require a Timer channel?

Admin.
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
AbeFM
Post Whore!
Posts: 629
Joined: Sat Feb 16, 2008 12:11 am
Location: Sunny San Diego
Contact:

Re: Possible uses of our timer resources : ideas soon please!

Post by AbeFM »

Nice write up on what we were talking about, btw - I agree that a timer for an offset is a good way to go, though with more cyl you'd need two times for overlapping staged differences? Maybe.

Also, why switch modes for >6 cyl?
Why not write one piece of code, that "bit bangs" things in a harmless, one-channel effected, sort of way? You'd save the IF, I dunno if you'd lose more that way or not, but doing things the same saves a statement.

Why do you have water pump and such as 8 bits? Aren't these digital? I'm really confused by that!

Lastly, the best job for another timer to me seems to be watching an additional rotating bit - driveshaft comes to mind. I want something to tell me the delta between two points to high accuracy, so that several times per revolution I get an update about it's speed - then it could deal with it if it changes rapidly and ignore if it it doesn't.
-Abe.
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: Possible uses of our timer resources : ideas soon please!

Post by Fred »

8InchesFlacid wrote:Also, why switch modes for >6 cyl?
Why not write one piece of code, that "bit bangs" things in a harmless, one-channel effected, sort of way? You'd save the IF, I dunno if you'd lose more that way or not, but doing things the same saves a statement.
Seems a damn shame to not use stuff thats there to best effect IMO...
Why do you have water pump and such as 8 bits? Aren't these digital? I'm really confused by that!
You answered your own question :-p but i'll detail it : 8 bits = 255 max value period = 255 clock cylces (clock is adjustable) = slightly better than 0.5% resolution. take that out to 16bit and things are MUCH better...
Lastly, the best job for another timer to me seems to be watching an additional rotating bit - driveshaft comes to mind.
That would be a hell of a waste of a timer. All you need for that is a count, timer inputs dont save you storing a value, they just let you know exactly when it is. i.e. you don't give a s%^& when driveshaft teeth and per wheel teeth are, just that they happened.
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
ababkin
LQFP112 - Up with the play
Posts: 215
Joined: Tue Jan 15, 2008 5:14 pm

Re: Possible uses of our timer resources : ideas soon please!

Post by ababkin »

i was just thinking if 2x periodic timers is really sufficient for ignition.

first off, (i am not sure if this was discussed already in another thread but..) what precision is more important: dwell precision or ign advance angle precision? As i understand, you cannot really have both, as you kinda need to predict when you want dwell to start while having current RPM as the only deciding factor. So if the RPM changes during the dwell period, one either has to:
1. maintain dwell period constant and have ign advanced or retarded (depending on whether RPM was speeding up or slowing down during dwell) or do the opposite:
2. keep the ign advance as it should be and increasing or decreasing the dwell period (again depending on acceleration of the engine during dwell).
Or we can even make this decision unidirectionally:
3. during acceleration: let the dwell decrease and keep ign advance constant (but i'd think one would need more dwell during accel, as there is more mixture, which is harder to ignite), during deccel: keep dwell constant but have ign advanced
4. during accel: keep dwell constant but retard the ign, during deccel: increase dwell and keep ignition advance constant

...Or some kind of weighed combination of #1,2,3 and 4

out of the 4, #1 makes the most sense to me right now: retard a bit during accel and advance during deccel, while keeping dwell constant
Legal disclaimer for all my posts: I'm not responsible for anything, you are responsible for everything. This is an open and free world with no strings attached.
User avatar
jbelanger
LQFP144 - On Top Of The Game
Posts: 387
Joined: Sat Feb 23, 2008 8:58 pm
Contact:

Re: Possible uses of our timer resources : ideas soon please!

Post by jbelanger »

Two timers should be enough for ignition and the most important thing is advance angle precision. If the dwell changes a bit it's not a big deal but you don't to have jitter on the spark angle. Also, you can use prediction to minimize the effect of acceleration (positive and negative). You'll still have some variation in both dwell and spark angle but the priority will always be spark angle precision.

Also for rotary (and maybe other multi-sparkplug) engines, there is a need to add 2 more timers for the different timing for leading and trailing. I'm not familiar enough with these engines to elaborate but I know they require different timing for optimal operation. So that would take the 2 free PITs.

As for injection, if we want to extend support to up to 16 injectors channels and staged injectors (which will cover 8 cylinders sequential plus staged injectors or up to 16 single injectors sequential) then there would be a need to use 4 timers: one for the start-of-pulse for the main injectors, one for the end-of-pulse for the main injectors, one for the start-of-pulse for the staged injectors, one for the end-of-pulse for the staged injectors.

In this case, what is important is the injection duration. So, as opposed to the spark channels, once you have started injecting, the end angle is of less importance than the duration which makes it a bit easier.

I think that such a setup would make the system flexible, usable and optimized for most engine configurations. So if there are up to 6 injectors (6 cylinder sequential or 3 cylinders with staged injectors) then the hardware timers can be used otherwise, bit bang the injector channels for up to 16 injectors. Does anyone think there would be a need for 12 cylinders staged? There is definitely enough output pins for it but the interrupt overhead would start to be a bit high, I assume. Also, even with 16 bit-banged channels, it becomes essential to be very careful with ISR coding to keep them as lean as possible otherwise timing precision goes out the window.

Jean
User avatar
jbelanger
LQFP144 - On Top Of The Game
Posts: 387
Joined: Sat Feb 23, 2008 8:58 pm
Contact:

Re: Possible uses of our timer resources : ideas soon please!

Post by jbelanger »

Admin wrote:
8InchesFlacid wrote:
Lastly, the best job for another timer to me seems to be watching an additional rotating bit - driveshaft comes to mind.
That would be a hell of a waste of a timer. All you need for that is a count, timer inputs dont save you storing a value, they just let you know exactly when it is. i.e. you don't give a s%^& when driveshaft teeth and per wheel teeth are, just that they happened.
Actually, if you need the speed then you want the timer. And you may actually want to have 2 timers for speed measurement if you want to do traction control: one on the driveshaft or a driven wheel and one on an undriven wheel. You can use rpm only for traction control but direct speed measurement can give other information such as gear, clutch slip, wheel spin, ... And those can be used for modulating boost control and some other power control as well as help in power measurement using the logged data.

An other point about knowing actual speed is for idle control. If you're moving slowly, you don't necessarily want to do the same thing with the IAC as if you're just idling.

Jean
User avatar
AbeFM
Post Whore!
Posts: 629
Joined: Sat Feb 16, 2008 12:11 am
Location: Sunny San Diego
Contact:

Re: Possible uses of our timer resources : ideas soon please!

Post by AbeFM »

I don't think tooth count does you any good for crank shaft/wheel speed - basically you can have a 1000 tooth wheel, and read it every quarter revolution, you'll get some idea of how fast it's going, but a sudden change you won't catch till it's slipped a lot. I'm saying highly accurate timing of a few teeth is better than accurate counts you get too rarely to do you any good. Definately an XGATE thing, I would hazzard to guess - all you do is check the time, see if the rate is within reasonable limits, then ignore it.

Definately spark dwell time is silly to get concerned about. You can have it be 20% over and then if sometimes it comes out "too short" you'll still have plenty of margin. In practice, you could do better, but I'm illustrating a point. I would say you want to be as accurate as possible (calc in mid-dwell even) on the advance angle, it's probably the single most critical opperating parameter of a gas engine, dwell times and even fuel delivered be damned!

About V8's - I don't think stagged injection is as imortant there? At least, not a two-fuel, variable mixture. My reasoning is they are generally big budget engines by people who wouldn't bother with two tanks. But it fits the high performance 4 cyl quite well. 6's are debatable. But my gut feeling is if you could somehow have 8 channels, you could cover fully sequential V-8's and fully staged 4s, though it sounds unrealistic given the chip. Anyway, same with 8's, 12 cyl aren't the sort of motor I can see someone wanting two fuels for. They will just put $50/gallon ultra-gas in the tank and run it all the time. If they can't afford it, why are they driving a Jag or a GT-90?

Re: Rotaries, I believe they have three injector channels? They certainly have three spark channels. Anyway, they may bank-fire the secondaries, meaning one more timer, not two. Also they won't be using nearly so many of those ign. channels, can they recycle?

I am a little confused by Jean's comments:
As for injection, if we want to extend support to up to 16 injectors channels and staged injectors (which will cover 8 cylinders sequential plus staged injectors or up to 16 single injectors sequential) then there would be a need to use 4 timers: one for the start-of-pulse for the main injectors, one for the end-of-pulse for the main injectors, one for the start-of-pulse for the staged injectors, one for the end-of-pulse for the staged injectors.
You can't recycle a timer? I.E. On injector start timer: START INJECT, SET TIMER FOR PULSE LENGTH - then that timer becomes the close timer as well.
If you have staged, you're even better.
SET START_PRIMARY TIMER
SET START_SECONDARY TIMER
On SP timer:
START PRIMARY INJECTION
SET CLOSE_ALL TIMER
On SS timer:
START SECONDARY INJECTION
On CA timer:
STOP PRIMARY INJECTION
STOP SECONDARY INJECTION

You might set end time when you start where I started secondary, etc, but I think this only takes two timers for two well timed injectors? It's what fred suggested anyway.
User avatar
jbelanger
LQFP144 - On Top Of The Game
Posts: 387
Joined: Sat Feb 23, 2008 8:58 pm
Contact:

Re: Possible uses of our timer resources : ideas soon please!

Post by jbelanger »

8InchesFlacid wrote:About V8's - I don't think stagged injection is as imortant there? At least, not a two-fuel, variable mixture. My reasoning is they are generally big budget engines by people who wouldn't bother with two tanks. But it fits the high performance 4 cyl quite well. 6's are debatable. But my gut feeling is if you could somehow have 8 channels, you could cover fully sequential V-8's and fully staged 4s, though it sounds unrealistic given the chip. Anyway, same with 8's, 12 cyl aren't the sort of motor I can see someone wanting two fuels for. They will just put $50/gallon ultra-gas in the tank and run it all the time. If they can't afford it, why are they driving a Jag or a GT-90?
I don't think most will use staged injection for different fuel but for dynamic range reasons. If you have a monster engine be it 4, 6, or 8-cylinder, if you want to engine to idle you're better with 2 injectors per cylinder and you want to bring in the staged injector progressively for better response. Also some people might want to investigate staging with primary injectors close to the intake valve and the secondary injectors high up above the throttle bodies (F1 style). Both of those require individual control of primary and secondary injectors.
8InchesFlacid wrote:Re: Rotaries, I believe they have three injector channels? They certainly have three spark channels. Anyway, they may bank-fire the secondaries, meaning one more timer, not two. Also they won't be using nearly so many of those ign. channels, can they recycle?
They actually have 2 ignition channels per rotor: leading and trailing. One of them is set in wasted spark and the other not (it can't) in early engines but later engines have them all individually controlled.
8InchesFlacid wrote:I am a little confused by Jean's comments:
As for injection, if we want to extend support to up to 16 injectors channels and staged injectors (which will cover 8 cylinders sequential plus staged injectors or up to 16 single injectors sequential) then there would be a need to use 4 timers: one for the start-of-pulse for the main injectors, one for the end-of-pulse for the main injectors, one for the start-of-pulse for the staged injectors, one for the end-of-pulse for the staged injectors.
You can't recycle a timer? I.E. On injector start timer: START INJECT, SET TIMER FOR PULSE LENGTH - then that timer becomes the close timer as well.
If you have staged, you're even better.
SET START_PRIMARY TIMER
SET START_SECONDARY TIMER
On SP timer:
START PRIMARY INJECTION
SET CLOSE_ALL TIMER
On SS timer:
START SECONDARY INJECTION
On CA timer:
STOP PRIMARY INJECTION
STOP SECONDARY INJECTION

You might set end time when you start where I started secondary, etc, but I think this only takes two timers for two well timed injectors? It's what fred suggested anyway.
I think you're confusing using timers for OC and bit banging outputs. What I suggest is bit-banging the injector outputs which would use 4 timers for ALL channels.

Bit banging the injectors is the same as bit banging the ignition in terms of timer requirements. You need one timer to start dwell. Because there is no overlap between starting dwell events for the different cylinder, you can reuse the same timer. Then you need one timer to spark and again there is no overlap for spark between cylinders. However, there might be overlap between dwell and spark so these are 2 different timers. The same applies for injection but here you talk about start-of-pulse (instead of start of dwell) and end-of pulse (instead of spark).

With the rotary ignition (and possibly other multi-sparkplug engines) since you have 2 independent events per cylinder you need 2 timers to start dwell and 2 timers to spark. Similarly, for bit-banged staged injectors, you need 2 timers to start injecting and 2 timers to end the injection for complete individual injector control.

So you can recycle timers if you bit bang the outputs but that reduces the precision. If you use OC, you need one timer per injector (or spark for that matter) and you can't recycle them for other uses.

Jean
Post Reply