If you need floating point, download the libraries from Microchip. They aren't all that hard to set up and use, and actually work surprisingly well. The libraries use somewhere around 30 bytes or RAM a K or so of ROM, and perform around 1K floating-point ops/second with a 20 MHz clock. If you don't need lots of speed, they may prove easier than doing all the analysis needed to avoid over/under-flow with fixed-point numbers. That's why floating-point was invented, after all. > -----Original Message----- > From: Byron A Jeff [mailto:byron@CC.GATECH.EDU] > Sent: Wednesday, December 05, 2001 9:17 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: floating point > > > On Tue, Dec 04, 2001 at 06:10:14PM -0800, jinhong kim wrote: > > Hi all. > > I am wondering If I could assign a floating point > > number with using PIC16F876. > > Sure you can. But it'll be a lot of work. > > > Actually, I wanna set PI control constant Ki=0.1 Is > > this possible? > > You may want to think about fixed point. You can create a > fixed point number > simply by taking the original number and multiplying it by > the range that > you wish to represent it. For example if you wanted to > represent .1 in 16 > bits, take .1 and multiply it by 65536 giving 6553.6. Round > to 6554. Store > this in 16 bits and use a 16 bit multiply followed by a 16 > bit right shift > (which means simply leave off the lower 16 bits). > > Here an example. Say we wanted to multiply 20 by our .1. So > multiply 20 by > 6554 giving 131080. Then shift 16 bits, which effectively > divides by 65536. > The result of 2.0001220703 is close enough for govt. work > > Hope this helps. > > BAJ > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.