Moderators: daxtojeiro, muythaibxr, jsmcortina
JasonC SBB wrote:Sorry I missed following this thread in the middle part. Would you be so kind as to save me reading 7 pages by typing a brief explanation of "same example as robs mystery MAP issue"?
2 of the "lag" filters in cascade (each having the same lag factor) also implement a 2-pole Bessel.
lag(lag(a, b, p1), b, p2)
lag(a, b, p3)
JasonC SBB wrote:Just to be sure, could you post a snippet of the lag filter code?
__asm__ __volatile__ (
"ldd %1\n"
"subd %3\n"
"tfr d,y\n"
"clra\n"
"ldab %2\n" // it is a uchar
"emuls\n"
"ldx #100\n"
"edivs\n"
"tfr y,d\n"
"addd %3\n"
: "=d"(outpc.tps)
: "m"(tmp1),
"m"(flash4.tpsLF),
"m"(outpc.tps)
: "x", "y" );
JasonC SBB wrote:Thanks but can you post C or pseudocode? That looks like assembly I'm not familiar with.
...The tuner gets to specify a lag percentage. The output of the lag calculation is the value that percentage of the way between the last output value and the most recent raw value. So a lag value of 0 locks the input forever where it started. A lag of 100 simply gives the most recent sample. A lag value of (say) .75 gives you T(n) = T(n-1) + .75[T(n)-T(n-1)]. Since T(n-1) depends similarly on T(n-2), there is actually a little feedback from everything that has ever happened, except that truncation of fractions soon wipes that out.
The MS lag filter can be expressed as:
(1) T(n) = pT(n-1) + qSn
where p is in [0:1]; q is 1-p, and Sn is the nth sample (i.e. the most recent). A MS lag value of 40% would be p=0.6, q=0.4. If you cascade this filter twice you get:
(2) T(n) = p[pT(n-1) + qSn] + qSn
= (p^2)T(n-1) + pqSn + Sn
= (p^2)T(n-1) + [p(1-p)+1]Sn
= (p^2)T(n-1) + (1-p^2)Sn
Which can clearly be expressed in one iteration of equation (1).
JasonC SBB wrote:If you read my posts a couple of pages back, I explained how the characteristics of the signal, the information therein, and the noise all need to be understood before a proper filter can be spec'd, designed, and tested. And this includes the rate of change information. Because the signals (MAP, TPS) are going to be used with a dot operation, then the filtering has to be designed accordingly. I also explained why a 2-pole filter (run through a lag filter twice) is superior when the filter output needs to pass through a dot operation. I explained that the rise time to step input and delay time from a ramp input are important figures of merit for measuring filter performance. WRT an engine's operation, one needs to think about how much delay and rise time a throttle enrichment operation can tolerate and not result in a misfire or hesitation.
JasonC SBB wrote:Last time I looked at it it looked to me like a single-tap "IIR" filter. Specifically the 2 examples on the first page, with coefficients between 0 and 1
muythaibxr wrote:I think you misunderstood. I wasn't talking about what you were doing specifically, but instead talking about filtering both the main signals themselves and additionally filtering the "dots" (all of them). More filters of more signals means more work. Considerably more depending on the type of filter used.
muythaibxr wrote:I wouldn't say they have to be perfect though you are correct that any noise in the original signal is magnified. However, my statement is one of what is *necessary*. With limited CPU resources, I want to make sure we do the least amount of work possible in the code while maintaining good results.
muythaibxr wrote:muythaibxr wrote:However, the piece you're missing is "is the delay a problem?"
Heh.
? That comment was aimed at gslender not you.
muythaibxr wrote:I think maybe you misunderstood my point there. I wasn't saying that anything was happening too soon. I was just saying that there are requirements for how quickly the "dot" data is updated after the actual events themselves happen, and in many cases, getting the data faster doesn't help. For example, we can only inject fuel so often. Getting the data more often than that is not necessarily important as long as we have good data just before the injection event is scheduled. Does that make more sense?
muythaibxr wrote:To be honest I would just like to arrive at a filtering method that avoids requiring the user to tune anything. The lag filters have in the past been a source of confusion and of tuning problems, so I'd like to avoid that in the future. I'm not saying your method lacks technical merit or that it doesn't work. I'm just saying that I think we can come up with something that doesn't require the tuning parameters.
"don't touch the throttle for 3 seconds after starting"
robs wrote:Which doesn't really say anything one way or the other. "Necessary" is a woolly word -- anything from the heroic, "we'll do whatever it takes", to the stingy "we'll cover the bare essentials".
I don't think it's possible in the world that MS currently inhabits. You've got bikes with feeble electrical systems, people who don't solder well, people who can't follow a circuit diagram, people (like me) who just reused existing harness wires. While some of these should be fixed at the source of the problem, some problems are intrinsic in the application.
piledriver wrote:"don't touch the throttle for 3 seconds after starting"
Note that will be a PITA until you have your cranking fuel/ASE etc perfect at all temperatures and can always just bump the key.
I realize that's just an example, but still...
Code that could adaptively check and set a noise threshold within a reasonable band would be nice, but would also probably be larger than the available space with my luck.
piledriver wrote:"don't touch the throttle for 3 seconds after starting"
Note that will be a PITA until you have your cranking fuel/ASE etc perfect at all temperatures and can always just bump the key.
I realize that's just an example, but still...
muythaibxr wrote:I don't think that solution is really a viable solution either. I just don't think we should give up on something that doesn't require tuning.
Robs may be right, making it work like the current MAP sampling works may help. James had some ideas on ways to make it better as well that we've discussed off the forums.
muythaibxr wrote:As far as making TPS sampling the same as MAP, it's worth a shot.
It seems plausible that, going with the "sample when it's about to be used" approach for TPS, you could take (say) four samples just when the squirt is about to happen. The mean of four can be efficiently calculated and this would probably get the noise reasonably under control without needing a parameter. Of course you wouldn't want it to average over the whole stroke as per MAP. With MAP you're interested in the area under the curve, with TPS it's the latest sample we're after.
robs wrote:...The tuner gets to specify a lag percentage. The output of the lag calculation is the value that percentage of the way between the last output value and the most recent raw value. So a lag value of 0 locks the input forever where it started. A lag of 100 simply gives the most recent sample. A lag value of (say) .75 gives you T(n) = T(n-1) + .75[T(n)-T(n-1)].
However I don't believe you have ever explained why running values through a lag filter twice is superior for the dot operation, you merely asserted it. But I'm not that fussed about the theory.
If you have specific software filter suggestions, stated in terms that a mathematically literate electronic incompetent might understand, this mathematically literate electronic incompetent will be happy to code them up in R and test them against Gaussian noise, or other suggested test scenarios.
JasonC SBB wrote:robs wrote:...The tuner gets to specify a lag percentage. The output of the lag calculation is the value that percentage of the way between the last output value and the most recent raw value. So a lag value of 0 locks the input forever where it started. A lag of 100 simply gives the most recent sample. A lag value of (say) .75 gives you T(n) = T(n-1) + .75[T(n)-T(n-1)].
OK it indeed is a single tap IIR lopass filter. It creates a single pole lopass filter. Just like the first 2 examples in the linked PDF with the positive values.
2 identical "lag" (or 1st order lopass) filters in cascade is NOT the same as a single 1st order lopass filter with some equivalent "lag factor" (aka time constant aka pole frequency)
muythaibxr wrote:It seems plausible that, going with the "sample when it's about to be used" approach for TPS, you could take (say) four samples just when the squirt is about to happen. The mean of four can be efficiently calculated and this would probably get the noise reasonably under control without needing a parameter. Of course you wouldn't want it to average over the whole stroke as per MAP. With MAP you're interested in the area under the curve, with TPS it's the latest sample we're after.
This is a fair suggestion.
Your "cascade" operation is wrong. See attached Excel file for what I mean by "cascade". You were thinking of cascading the math of one line of code, rather than having the output data stream of the first "lag" operation, be the input data stream of the 2nd "lag" operation.robs wrote:Jason, I have provided an algebraic proof that when a MS lag averaging operation is applied a second time to its own output the combined result can be expressed as another MS lag average. Your reasoning appears to hinge on the fact that this is not the case.
That's because I defined a "lag" function not as a line of code but defined as taking 2 inputs - the input data stream, and the "lag factor". This is what cascading transfer functions means in signal and filter theory.As a suggestion, I find it suspicious that you earlier referred to a lag function as lag(a,p3).
robs wrote:muythaibxr wrote:It seems plausible that, going with the "sample when it's about to be used" approach for TPS, you could take (say) four samples just when the squirt is about to happen. The mean of four can be efficiently calculated and this would probably get the noise reasonably under control without needing a parameter. Of course you wouldn't want it to average over the whole stroke as per MAP. With MAP you're interested in the area under the curve, with TPS it's the latest sample we're after.
This is a fair suggestion.
An interesting potential benefit is that timing it synchronously with injection, we might see much less interference from flyback current, much as they eventually realised it'd be a good idea to synchronise the machine gun to the propeller in WWI fighters.
Have fun,
Rob.
piledriver wrote: the one possibility left is a bit of logic to throw out samples that are out of range, perhaps simply based on tossing out the high/low samples of a small set...
Return to MS2/Extra Development
Users browsing this forum: No registered users and 5 guests