Monday, May 20, 2002, 5:05:58 PM, Jinx wrote: >> Here is probably an easier way to do it: >> >> 1) multiply your 16 bit number by 100*360/65536 = 0.54931640625 > The gyro is claimed to have 0.05 degrees accuracy at 14 bits, > although noise does seem to be a problem, despite sending > regular zero/integration commands and ignoring the LSbs. There's > still work to do sorting that out, as it's the core of the project. > Even if it's a little slower to do I want to keep the maths as > precise as possible so that any calculation errors are insignificant > compared to the jitter from the gyro. I don't think 16-bit maths will > be good enough to get 3dp fractions from a 16-bit source will it ? Well, it seems you need to display only 2 decimal digits after the point, which is only a +-0.01 degree error. So, I'm not really sure why you want 3 decimal digits. It is not really necessary for rounding, because you need only 1 extra bit for that, to tell if fractional part is less than 0.5 or not. And this extra bit is already there after multiplication by 100*360, that is bit 15. In pseudo code that would look like: //multiply sensor output by 100*360 temp = sensor * 36000; //round (increment integer part if bit 15 is set) if(temp & 0x8000) temp += 0x10000; //divide by 65536 temp >>= 16; You could still use the multiplication code generator for this, just tell it to use rounding and a 0% error. http://www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&Bits=16&endian=little&Const=0.54931640625&ConstErr=0&round=yes&Temp=TEMP&cpu=pic16 > I'm using this conversion routine, around 48us > http://www.piclist.com/techref/microchip/math/radix/b2a-16b5a-rl.htm This one is probably better, since it gets a digit at a time and can be called while LCD is still receiving the previous digit. But the other one seemed to take a few less cycles overall. Good luck! Nikolai -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body