apalrd wrote:
Does the code run as fast on a real ECU as it does on the simulator?
As far as I can tell it does...but I haven't done back to back runs ECU vs sim. At the moment I have everything set to a 128 priority on a 0-255 scale and everything is 1 big thread.....once I have a fairly complete model I'll look at thread run and sleep times and start moving stuff around to get reasonable times on it all. Get it working first them optimize where possible.
apalrd wrote:
As for by the cycles, to me it makes it easier to calculate everything at the right angle (just before it is 'due'), since I know that a single iteration of the code equals one cylinder's cycle, so things like air models can take a running mass estimate and subtract the current air charge from the manifold mass estimate every time they run (cyclically) without having to convert it to a flow and slowly pull the flow out. In that example, the model then handles things like uneven firing correctly. For transients, the delay between the sensing, calculation, and actuation is fixed so the calibration of prediction things is easier. Little things like that.
It's also important to calculate things as infrequently as possible if the processor is loaded. I worked on a MPC5674F (260mhz dual issue single core) and we had the processor pretty hammered with an advanced I4 engine (which is currently in production), due to the calculations required, and we were only doing them once per cycle per cylinder.
I'm at about 1% loaded right now I think.
On a 1 cylinder you have the full cycle time to do you work....on a 12 its another story.
What I do is run a simple cycle clock in the code and try anything that is truly cycle dependent to that. So the x-tau calculates stored fuel by cycle, but the code may come up any number of times within a cylce and skip through because it's not due.
Other stuff I think it best to update when the info is available....like throttle or traction control, you just do it.
There is no right for most of this stuff, at least not that I've found, you just adapt to get the most from the system you're working with. The enginelab system is one of the most powerful I've worked with, but it's not without its quirks and limits. Jim is concerned about trying to load to much into the low-level time critical world when it's really not time critical, I think he's probably over concerned but so far I can live happily within the rules I think, its a lot of bang for the buck compared to other options.