Shop OBEX P1 Docs P2 Docs Learn Events
Floating point math — Parallax Forums

Floating point math

Brian LBrian L Posts: 60
edited 2007-12-24 20:57 in Propeller 1
1.) Is it worthwhile (meaning, would it speed things up?) to connect one of the uM-FPU coprocessors to a Prop, or are there objects in the library that allow the prop to handle floating point plenty fast on it's own already?

2.) Same question about connecting stand-alone ADC chips. I've seen references to the prop being able to do it's own ADC, but nothing very specific about it. I'd like to be pointed toward some documentation showing both hardware and software details how this is accomplished, and also hear some opinions about whether it is a fast and accurate way to do it, compared to a stand-alone ADC. And just how many bits of resolution can you get doing ADC on the prop anyway?

Thanks for any input,
Brian

( Witty catch phrase coming soon!! I just haven't thought of mine yet. )

Comments

  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-12-22 06:09
    The uM-FPU is a sophisticated chip and has more functions than are available in the Prop floating point library. The Prop floating point library comes in two versions, one that has the most common functions in a single COG, and an version2 with additional functions, requiring two cogs. If the functions you need are mostly there, especially in the small version, then there would certainly be an inducement to keep it all on the Prop. The uM-FPU offers many more commands, though, beyond the two COG version, and also has the useful facility to store multi-step user functions of several variables (loaded into registers on the uM-FPU) that you would otherwise have to build up and execute on the Prop. Do you need FFTs? Matrices? And the uM-FPU also has a couple of ADCs, and a timer, and an auxiliary serial port with functions for automatically parsing NMEA sentences. Speed of execution is a tradeoff. It depends. The Prop has to send commands to the uM-FPU along with the data, and retrieve results, but that can happen fast with the SPI interface and interleaving. There is a learning curve either way. See the data sheet. BTW, the same guy who invented the uM-FPU also wrote the Prop floating point library. (Cam Thompson of MicroMega).

    Re the ADC. You can find the AN001 document on the COG counters on the Parallax web site, downloads page, and it shows how to set up the sigma delta mode. This recent thread http://forums.parallax.com/showthread.php?p=677204 also gets into it and has links to earlier discussions. Again, it comes down to what you want to do. Dedicated chips can have a wealth of features that are not possible with the built-in mode. For example, if you want high input impedance or a differential input, you could add some analog circuitry, but at that point it might already be time to look at an offboard ADC. Or if you need lots of ADC channels, you might need a mux anyway. As sigma-delta converters go, the Prop version has only a first order loop filter and has noise issues and cannot match the high stability and resolution of a dedicated sigma-delta chip. In order to achieve the best results with the Prop ADC, one has to pay close attention to circuit layout. That said, the Prop ADC can be fast enough for low res audio as seen by many of the examples here, and it is be great for minimalist situations, or situations where special timing or programming is part of the ADC algorithm.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-22 06:10
    Have you looked in the Object Exchange? You'll find the answers to your questions there.
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-22 08:58
    I couldn't say it better than Tracy, but I can elaborate on it:

    (1) Speed: The (few) FloatMath functions (+,-,*,/) give you insight into how FP simulation is done. There is no speed to mention. I displaced my benchmark results I did half a year ago, but they work within miliseconds per operation.

    Float32 is fine, and also quite complete wrt basic mathematical operations, also trigonometry; there are also variants of Float32 with many more quite specific functions (e.g. nautical!). Most work within 10µs per operation; using 6 oder seven COGs altogether the Propeller comes close to a 1Mega-FLOPS machine, which is quite remarkable...
    The FPU Chip is a garden variety of a microcontroller and does nothing else. As it is not as powerful as the Propeller it is basically slower than Float32! However it is much more "intelligent", as all its code is dedicated to FP processing. However this "FPU's" working can completely (and faster!) be emulated on the Prop if you will take the time to code all algorithms in Propeller machine language!

    (2) ADC We are nowadays accustomed to have an ADC integrated within an MCU without much scrutinizing its accuracy in the hobby scene... Stabilizing and calibrating high speed precision ADCs is still a challenge. I personally see it to be a good thing that you can (have to) choose your ADC from a transparent market rather than be bound to a MCU supplier's good taste...

    Delta-Sigma modulation works fine, but it has to be adapted to each situation anew. You have to understand what you are doing!

    (3) Documentation: All "objects" are undocumented and "as-is" wrt industrial standards. For accessing the FPU there is not even an interfacing object (I think..). The interface to many ADCs is wrapped into object, but generic Delta-Sigma modulation has to be adapted for each case.

    You are not coming to a settled situation here! This is gold digging we are doing smile.gif Be welcomed!

    Post Edited (deSilva) : 12/22/2007 9:45:02 AM GMT
  • Brian LBrian L Posts: 60
    edited 2007-12-23 20:34
    Thanks for the info guys. At this point I'm leaning toward the belief that the FPU's make a great addition to a slower uController like the Basic Stamp, but the Prop can probably do fine without it, unless you're already running low on spare cogs. And since I won't be needing advanced functions like FFT's I'm going to explore the floating point objects in the library.


    On the ADC issue:
    I was already leaning toward the use of off-chip ADC, because I like (and need) the multiplexers and the sample-and-hold function that is included in many of those devices. However I'm still a little bit curious and confused about the Delta-Sigma method of AD conversion. Until I started reading about the Prop I'd never even heard of this. I already understand the successive approximation method used by the stand-alone ADC's, and I'm pretty impressed with how well it works. But I've just finished reading the AN001 Prop Counter document, and it didn't really give a very basic introduction into the operating principles of how Delta-Sigma works. I did however, notice a few remarks on page 17 that seem to throw doubts on the accuracy and noise immunity of Delta-Sigma.

    So here's the new question:
    Can anyone point me toward some introductory information about how Delta-Sigma AD conversion works? I suspect that it may prove useful in the future and I'd like to understand it, even though I probably won't use it right now.

    Thanks.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-23 20:38
    There's an introduction and further links in the Wikipedia. Do a web search for "wiki delta sigma".
  • Brian LBrian L Posts: 60
    edited 2007-12-23 20:44
    Thanks Mike. I'll do that now. I've got to get the hang of that Wiki thing. I've never used it or heard of anyone using it until this forum.
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-23 22:23
    Brian,
    Delta-Sigma modulation is neither new nor uncommon. You might have lived in the early period of CD players: They started with 10 to 11 bit accuracy, a good one had 12, then 14. After some years 16 bits was considered "high-end". Then it became "1-bit" smile.gif

    That was when the high frequencies (30 to 100 MHz) required for high resolution delta-sigma could be controlled in cheap consumer devices.

    Delta-Sigma has nearly advantages only, Second or higher order delta.sigma has an extremely high signal/noise ratio. The drawback is, that is is very touchy to external effects and has to be built according to the best HF standards possible.

    I generally recommend reading this www.beis.de/Elektronik/DeltaSigma/DeltaSigma.html


    Edit:
    I just see: Philldapill is giving some of those Delta-Sigma ADCs away www2.informatik.hu-berlin.de/~hochmuth/bvp/ads1210.pdf
    in exchange of a simple SPI driver ...
    Take your chance smile.gif

    Post Edited (deSilva) : 12/23/2007 10:44:47 PM GMT
  • Tracy AllenTracy Allen Posts: 6,660
    edited 2007-12-24 20:43
    Brian,

    Did you take a look at the threads on sigma-delta here on this forum? The principle behind it as implemented on the Propeller (or other microcontroller) is very simple. The complexities come from the higher order filters and sampling theory. There are also good tech notes on the Linear Technology web site. Successive approximation converters top out at 14 bits, maybe pushed to 16, most common at 12.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Brian LBrian L Posts: 60
    edited 2007-12-24 20:57
    Thanks again for the info. I'll do that reading and see if I can get a handle on it.
Sign In or Register to comment.