Just another idea.

The result of

> 60 x 1,000,000 (conversions for minutes and us)

>rpm = ------------------

> 16 bit timer value

can be in range of 60000000 to 915.5 rpm. If the maximum rpm

fits into 16 bits, you can use your 16 bit division routine

to do that!

Just initialize nominator (dividend) AND remainder with

60*1e6 (0x3938700), and branch to the division loop start:

FindRPM

clrf y0

movlw 0x87

movwf y1

movlw 0x93

movwf rem0

movlw 0x03

movwf rem1

jmp divide16by16_loopstart

8 instructions!

Happy Holidays everyone!!!

Nikolai

---- Original Message ----

From: Drew Vassallo <TakeThisOuTsnurple@spam@spamHOTMAIL.COM>

Sent: Thursday, December 21, 2000 22:06:19

To: TakeThisOuTPICLISTRemoveME.....MITVMA.MIT.EDU

Subj: [PIC]: Challenge! (Everyone loves a...)

{Quote hidden}>>maybe I'm missing something (AND I don't have a solution to offer),

>>but it looks to me like the rpm is inversely related to the timer value,

>>which means simply dividing by 15 won't work. The basic equation looks

>>to me like:

>>

>> 60 x 1,000,000 (conversions for minutes and us)

>>rpm = ------------------

>> 16 bit timer value

>>

>>Also looks like the slowest speed that can be measured with 1us ticks

>>and a 16 bit number is 915 rpm... (is this adequate?)

>>Again, *I* don't know how to do this is 50 words!

> No, you're not missing anything. It is not a 'divide by 15' or anything

> that simple. You're right on with the 915 rpm max. Too bad you don't have

> a solution, you seem to understand the problem :)

> I suppose it's a 26-bit (32) divide by 16-bit, but that's probably some

> serious code. Too bad Nikolai doesn't have an "inverse of a multiply by a

> constant" code generator :)

> And yes, 915 rpm as the lowest limit is more than adequate. A max of about

> 20,000 rpm is the absolute ceiling, but that's not a problem as a count of

> 0x0001 is over 230,000 rpm.

> Using an actual time value rather than a "number of counts per XX time"

> gives a MUCH improved resolutionn and lower error. However, if anyone

> offers a method that makes use of the "number of counts per XX time" that is

> within 200 rpm, I'd probably take that.

> --Andrew

--

http://www.piclist.com hint: To leave the PICList

RemoveMEpiclist-unsubscribe-requestEraseMEmitvma.mit.edu