KJBob

It's Pi Day -- Compute the approximate value of Pi with SigmaDSP

Discussion created by KJBob on Mar 14, 2015
Latest reply on Mar 16, 2015 by JohnTo

    Engineers have a bad reputation for abusing things.  For example, power supply magnetics designers often abuse (and sometimes blow up!) audio power amplifiers to test their wound components at odd amplitudes and frequencies.  So, why not abuse a ADAU1701 to approximate the value of Pi on Pi Day.  Pi can be worked out by comparing the area of a unit square with that of an included circle -- the ratio of these is pi / 4.  Often this is done Monte-Carlo style with random number generators -- throw darts at the square and count those that land within the circle inside.  However, the white noise in SigmaDSP, being of Gaussian and not linear distribution, won't work for this. So I did a "raster scan" of two triangle wave generators.  Yes, think of the vertical and horizontal sweeps in the old TV I'm still watching, because it still works.  BTW -- please don't refer to things like my TV or last year's smartphone as a "dinosaur"  -- no need to insult these majestic creatures.

Compute-pi_pic.png

    The actual circuit shown works with a 2x2 square (from -1 to +1, with a one inch radius), since this turns out easier to work with.  For each sample interval, the circuit generates a new x,y point and computes the square of its radius.  If less than one, it counts as a "hit" and increases the output, otherwise the output is allowed to decay.  Eventually the output settles to something close to pi.  Obviously, one could do a much better job much faster with a general-purpose computer or last year's smartphone -- but it's more fun to push the tech in unusual directions.

Outcomes