John J. McDonough wrote: > I think I might take that a step farther. For control, floating > point is usually a bad thing, and with PICs, our objective is almost > always control. This may be true in your particular experience, but there are many things PICs do beyond control, and floating point has its uses. Your statement sounds more like a religious conviction or an attitude problem than a rational conclusion. The main deciding factor between fixed point and floating point is the dynamic range and precision required of the data. For example, let's say values are measured to 10 bits and you want to keep intermediate calculations good to 14 bits so that computational noise doesn't accumulate to a significant level. That means you can have a dynamic range of 32 bits - 14 bits = 18 bits = 260K:1 if using 32 bit fixed point. That's no problem for directly measured values, but may not be so easy to arrange for intermediate values especially if divide, square, or square root operations are required. It may also require different implied scale factors for the various numbers. There is nothing wrong with that mathematically, but it is harder to program and more error prone. For low to mid volume products, the decreased engineering, testing, and debugging cost is often worth the disadvantages of floating point. > Not once did I resort to floating point. That hardly proves the problem could not have been solved effectively using floating point. > One obvious problem with floating point is that it is large and slow. This is a common misconception. Again, depending on the dynamic range and accuracy, floating point can easily take less space. Floating point gives up a fixed number of bits (usually 8) in return for a guarantee that the remaining bits will all be significant over a very wide dynamic range. This means that in many cases 24 bit floating point is sufficient, but would require 32 bits or more and a lot of care to use fixed point. As for speed, some operations like addition and subtraction are usually slower in floating point due to the need to pre-normalize. However, multiplication and division is usually faster because there are fewer bits that need to be crunched. > Maybe more to the point for control, most FP algorithms tend to be > not very deterministic, which complicates control. This is just plain silly. Of course floating point is deterministic. There is one and only one answer for each case, just like fixed point computation. The difference I think you are alluding to is the nature of the computational noise. Floating point tends to introduce noise at a roughly constant signal to noise ratio, whereas fixed point introduces noise at a roughly constant amplitude. Neither one is inherently better, but each characteristic needs to be considered in the overall design. Generally both schemes deal with it by guaranteeing that the computational noise is small compared to measurement noise and then ignoring it. This is a valid approach, and works with both schemes. > But the most important point is this .... if you intend to control > something, you need to understand it. In complex controllers there > may be many variables with varying degrees of significance. Real > world sensors rarely have a range of more than about eight or ten > bits, although it is often more convenient to carry calculations out > to a little more precision than that. Understanding the implications > of the rangeability of the various measurements is key to making your > control work. If you need to resort to floating point, then you > don't understand the problem well enough. So all designers of systems using floating point were stupid and lazy? This is clearly rediculous. To summarize, the advantages of floating point are: 1 - Easier implementation. No need to determine the scale factors for various fixed point numbers. 2 - Auto-ranging, which makes them attractive when values can range widely. 3 - Usually fewer total bits required for the same minimum guaranteed precision unless the dynamic range of the values are rather small. 4 - Usually faster for multiply and divide. The disadvantages are: 1 - Slower addition and subtraction. 2 - Math routines require more code space. 3 - No data storage savings if the dynamic range of values is known to be limited. 4 - Writing floating point math routines is more difficult to implement than fixed point. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu