I haven't posted in like forever... my OpenAero2 and the new OpenAeroVTOL have now 99% unique code - unrelated to MultiWii - with the exception of the IMU code, which is based on older MW code.
However I have been looking at improving this code and sorted through changes up to V2.3. I then came across the rather puzzling change to the ACC LPF code. So as not to waste your time I duly researched the ACC LPF mod and found this thread --> http://www.multiwii.com/forum/viewtopic.php?f=7&t=1573.
Now the claim is that this code:
Code: Select all
accTemp[axis] = (accTemp[axis] - (accTemp[axis] >> ACC_LPF_FACTOR)) + accADC[axis];
accSmooth[axis] = accTemp[axis] >> ACC_LPF_FACTOR;
...is essentially the same as this code:
Code: Select all
accSmooth[axis] = (accSmooth[axis] * (ACC_LPF_FACTOR - 1) + accADC[axis]) / ACC_LPF_FACTOR;
..or its better-rounded cousin:
Code: Select all
accSmooth[axis] = (accSmooth[axis] * (ACC_LPF_FACTOR - 1) + accADC[axis] + (ACC_LPF_FACTOR/2)) / ACC_LPF_FACTOR;
If you read the above thread you can see the conversation drift obliquely away from the actual issue and compare >> to /...
The code in the current MultiWii implementation might kinda sorta work when not examined closely but it is in NO WAY similar to the original code.
The old code MULTIPLIED the ongoing sum by a large amount, then added the new accADC, and then divided the total by an amount fractionally larger than the multiply, leaving the result exactly the same size as before the operation.
The new code subtracts a small fraction of the current sum, adds the new accADC and then strangely, divides the ENTIRE result by again the same amount. The result in accSmooth[axis] will be a small fraction of the original. It is true that an amount of the original signal is retained, but the point of a LPF is to retain a very specific LARGE amount of the original. With the old code the percentage of the old signal vs the new one is guaranteed.
I do understand that the move to rotates was probably driven by a need to increase code execution speed, but I really don't think the code works the same way.
I'm not saying that you don't get a kind of filtering effect from this code if you process the decimated result properly but either I've missed something obvious or there is something wrong with this code.
So can someone look at the above with fresh eyes and tell me I'm wrong? Frankly I want to be wrong but no matter how many times I look at it I can't see it any other way...