'MOMA-filter field observation & speed up idea'
|I just configured my app to generate high level on a pin during execution
of MOMA. Then set up an Oscope to trig on rising edge so I could watch
ececution time in real application.
Execution time varies much because of the filters first part which searches
for the first array value < seed, as it starts searching from the top max
of the array.
Studying the pulse time then give a good idea of where in the array the new
value is injected = what the new value is in relative to the current
@ 20MHz, execution time varies between approx 100µs (rising feed values) to
180 µs (falling feed values).
Code used: as posted but she sum routine corrected and speeded-up using the
known zero register trick (also giving the add constant execution time),
and the div8 speeded to 9 cycles (9 rrf).
What i learned from watching the Oscope is that when the sensor signal is
stable, and only noise actually controls where new values are injected; is
that the most values are injected in the top and bottom ends of the filter.
In my app approx only 1/20 of them (looked like; very approximately) were
injected in the 8 median values (which are used for calculating output)
The filter can therefor be speeded up if the scan-for-adjacent-values
routine first checks if input is higher or lower than the filter median,
and then start the search from the relevant end, towards center.
The execution time would then most often be close to 100µs (injected close
to array ends), or maximum slightly above 140µs.
I don't need this speedup, but if anybody constructs such a routine, i
would be happy to recieve it.
Morgan Olsson ph +46(0)414 70741
MORGANS REGLERTEKNIK fax +46(0)414 70331
H€LLEKS (in A-Z letters: "HALLEKAS")
SE-277 35 KIVIK, SWEDEN iname.commrt
> The filter can therefor be speeded up if the scan-for-adjacent-values
> routine first checks if input is higher or lower than the filter median,
> and then start the search from the relevant end, towards center.
My Idea how to speed up the search is:
new_input := tyngd_in
size := size_of(viktfilter_array)
rrf size; ; half array
movf size, w
loop movef INDF, W
rrf size ; quarter array
IS W > new_input
add size to fsr
sub size from fsr
if W = new_input or size = 0
fsr contains address where to inject new input
or to try this in a more textual way:
if you test for higher or lower the value in the middle, then you know
in which half the value has to be. now test higher or lower in the
middle of the appropriate half.
gives you the quarter where the value will be, now devide the quarter in
again checking for higher or lower until you4re just have two values
left where the
new value can be between. gives you the address where to inject.
sorry for the pseudeo code but the Idea came very recently into my mind.
I also think there is a quite better way to describe this algorithm.
It4s like descending a binary tree.
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- New search...