At 03:08 PM 11/25/02 +0200, you wrote: >I have written a algorith on the pic to mathematically convert the 10-bit >number to a number between Ymin and Ymax but the algorithm takes far too >long. Is there a way (hopefully easy) that you more or less can convert >the 10-bit number to say between 100 and 200 almost directly (bit >manipulation) without long and cumbersome arithmetic. Nic, One idea amounts to multiplying by (about) 25 and then dividing by 256 (throw away the LS byte). Assuming you want 100-200 *inclusive*, you could do something like this (I'll use pseudo-C code) Let's assume x (one byte) contains the MS byte of the left-aligned A/D value (0x00 to 0xFF as the A/D output goes 0x000 to 0x3FF) z = ((x + (x >> 1) >> 1) + (x >> 5) + (x >> 6); ^^^^^^ shift any carry from the addition in here z= (z >> 1) + 100; You'll recognize the shifts and adds as hard-coded multiplication. This will reduce down to just a handful of PIC assembly instructions, with no loops. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.