Grant, To divide efficiently by 13.18 use a constant division/multiplication code generator at www.piclist.com/codegen/constdivmul This is as easy as copy and paste :) ; ACC = ACC * 0.075900 ; ; ALGORITHM: ; Clear accumulator ; Add input / 16 to accumulator ; Add input / 64 to accumulator ; Substract input / 512 from accumulator ; Move accumulator to result ; ; Error in constant approximation : 0.358202, % ; Input: ACC0 .. ACC1 (11 bits) ; Output: ACC0 (8 bits) cblock ACC0 ACC1 TEMP0 TEMP1 endc movf ACC0, w movwf TEMP0 movf ACC1, w movwf TEMP1 clrc rrf ACC1, f rrf ACC0, f clrc rrf ACC1, f rrf ACC0, f clrc rrf ACC1, f rrf ACC0, f clrf ACC1 comf ACC0, f comf ACC1, f incf ACC0, f skpnz incf ACC1, f movf TEMP0, w addwf ACC0, f movf TEMP1, w skpnc incfsz TEMP1, w addwf ACC1, f clrc rrf ACC1, f rrf ACC0, f clrc rrf ACC1, f rrf ACC0, f movf TEMP0, w addwf ACC0, f movf TEMP1, w skpnc incfsz TEMP1, w addwf ACC1, f rrf ACC1, f rrf ACC0, f clrc rrf ACC1, f rrf ACC0, f clrc rrf ACC1, f rrf ACC0, f clrc rrf ACC1, f rrf ACC0, f ; Generated by www.piclist.com/cgi-bin/constdivmul.exe (version March 21, 2000) ; Sat Apr 22 03:50:56 2000 GMT Hope it helps, Nikolai http://techref.massmind.org/member/NG--944 On Friday, April 21, 2000 Caisson wrote: >> Van: Grant Forest >> Aan: PICLIST@MITVMA.MIT.EDU >> Onderwerp: Frequency Conversion >> Datum: vrijdag 21 april 2000 11:35 >> >> Goodday, >> >> Spent the last 8 hrs trying to convert a frequency with a range of > 7351Hz >> to 6033Hz so that I can display 0 to 100. >> Can someone point me to a URL that has routines to convert >> frequency to decimal. Or do I just do it with a very large lookup table. > Looks like you could : Subtract the base frequency (6033) from the one > you've got, and divide the result by the difference between the highest & > lowest frequency's (7351 - 6033 => 1318) divided by 100 (1318 / 100 => > 13.18). > You could replace the division by 13.18 by multiplication by 4972 (100 * > 65536 / 1318), giving a 3-byte result with the percentage in the third byte > from the right. This will be easier (multiplying versus division), and > will deliver a quite accurate result. > Regards, > Rudy Wieser