> > X / 370 = 4000 > > X = 4000 * 370 = 1,480,000 = 169540h > > > > >From the hex value of X you can see that a minimum of 21 bits are required > > for X. That means you can use a 24 or 32 bit integer divide routine. > > > Thanks again Olin, that all makes perfect sense. Now > I have the rouble of getting enough resolution at the > other end of the range. My big period is 10kph=200,000 > so I would be doing: > (10kph) 1,480,000 / 200,000 = 7.4 > (11kph) 1,480,000 / 182,000 = 8.1 > (12kph) 1,480,000 / 167,000 = 8.9 > > Obviously with rounding this shoots my resolution > out the window. I need better than 0.25kph and > prefer 0.1kph throughout the whole range. Something seems inconsistant here. If a period of 370 implies 400Km/H, then 10Km/H would be 14,800, not 200,000. Your 200,000 figure must be for a different bike configuration, in which case you would be using a different X (20,000,000 in that case). Once X has been chosen for the particular bike configuration so that you get 4000 for 400Km/H, you end up with a value that can resolve .1Km/H. By the way, given your potentially large X values, you need to be doing a 32, not 24 bit, divide. As you mentioned in your other post, you have 16,000 cycles available, which is way more than enough. ***************************************************************** Olin Lathrop, embedded systems consultant in Devens Massachusetts (978) 772-3129, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu