Hi Andrew.
I got some time and tried to rewrite your filter code to optimize it a little bit.
The formula can be rewritten as: Ave' = Ave + ( New - Ave )/16 ;
Used the same names for variables. TEMP cell isn't used.
I having more and more believing that 12 is some magical number for small completed code fragments. ;)
; Initially written by Andrew Warren (fastfwd at ix.netcom.com).
; Optimized by Dmitry A. Kiryashov (zews at aha.ru) 06/18/2000
; 12 clocks/words
Filter:
movfw AVE
subwf NEW,F ;NEW - AVE
swapf NEW,W
andlw 0x0F ;get /16 int part
skpc ;result is neg?
iorlw 0xF0 ;yes
addwf AVE,F
swapf NEW,W
andlw 0xF0 ;get /16 frac part
addwf AVFRAC,F
skpnc
incf AVE,F
;
; low nibble of AVFRAC isn't used
; so we can utilize it for other purposes ;)
See also:
Comments:
| file: /techref/microchip/dsp/av-16w-dk.htm, 2KB, , updated: 2010/3/14 11:11, local time: 2010/3/15 02:15,
38.107.191.114:LOG IN
|
| ©2010 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? Please DO link to this page! Digg it! <A HREF="http://piclist.com/techref/microchip/dsp/av-16w-dk.htm"> PIC Microcontoller DSP Math Method 8bit 16 step Averageing filter by Dmitry</A> |
| Did you find what you needed? |
|
Ubicom SX18 thru SX52, PIC 16c5X compatibile, 50 to 75 MIPS microcontrollers! |
Robotics nuts!Check out http://www.verinet.com/~dlc/ email: dlc@verinet.com... This guy ROCKS! He has made (and sells but also releases code, docs, etc...) for a number of cool little robotic modules including whiskers, IR proximity detect and remote control, Sonar proximity detect, PWM, Servo, compass. Most of these use the little PIC 12C508 controller which costs basically nothing and is soooo tiny.The 4 servos, 2400 baud serial servo controller is a wonder of magic and he sells the programmed chip for $8. Wow! |
.