ΣSigmaStudio Ask AI Русский Log in

An Integrator Block for SigmaDSP

SigmaDSP & SigmaStudio KJBob Nov 2, 2012 00:00 4 replies Original on forum ↗
Subscribe
KJBob Question
Nov 2, 2012 00:00

Looking at GTG737's implementation of an adaptive mixer -- and GatsbyDSP's comment

that it would run away with itself -- gave me the idea to build an integrator, something that

several folks have asked for. This one is complete with Run/Stop and Reset control inputs:

With a DC source at the input as shown, it generates a ramp as expected:

An integrator has infinite gain at DC -- its output constantly grows. If your input

contains DC, you'll need to stop it before it overflows the DSP. You can replace the manual

switches shown with logic to perform this or other functions.

You can set a nonzero initial condition with a DC source.. If you also feed the integrator's output

around with an inversion, you solve the differential equation dy/dt = -y. The resulting curve

is characteristic of a RC circuit discharging, or your coffee getting cold with time.

Yep, you can build an analog computer with integrators like this, and rediscover how

differential equations were graphically solved some 60 years ago.

The circuit simplifies greatly if you don't need the controls. The core function is

incredibly simple -- an adder that feeds back to itself. This makes a perfect integrator,

unlike a low-pass filter which has a finite DC gain. Uses fewer instructions, too.

ramp

integrator

stop

analog_computer

run

differential_equation

Show More

6153.1c01cbaff41d354e06d250f26b386cd0.jpg
6153.1c01cbaff41d354e06d250f26b386cd0.jpg
6153.1c01cbaff41d354e06d250f26b386cd0.jpg-450x330.jpg
6153.1c01cbaff41d354e06d250f26b386cd0.jpg-450x330.jpg
7411.102cea808e173124acca47732ae56580.jpg
7411.102cea808e173124acca47732ae56580.jpg
7411.102cea808e173124acca47732ae56580.jpg-450x317.jpg
7411.102cea808e173124acca47732ae56580.jpg-450x317.jpg
0777.5106b7fdddb245acf22fa78569538f37.jpg
0777.5106b7fdddb245acf22fa78569538f37.jpg
0777.5106b7fdddb245acf22fa78569538f37.jpg-450x316.jpg
0777.5106b7fdddb245acf22fa78569538f37.jpg-450x316.jpg
ADIApproved Reply
Nov 7, 2012 00:00

Once again, this is great work. Thanks for contributing this to the community.

kaeroul Reply
Jul 25, 2018 00:00

good day everyone,@KJBob, @

I want to implement stand alone DSP to process integration of trapezoid rule repetitively. The firmware would be developed in the DSP's SIGMASTUDIO. Next I would read the integration output using Readback block by SPI of STM32F4 microcontroller. Readback block algorithm is ready.

For the integration of trapezoid rule,

,

where and .

lowbound,a = 1st sample, X0

upbound,b = 101th sample, Xn

intervals,n = 100

f(x) = sample(n)

Is it possible?

thanks

kal

KJBob Reply
Jul 28, 2018 00:00

Hello Kal,

I'm afraid it's been 45 years since my last calculus class, so the integrator that's the subject of this thread was of the simple zero-order variety. Lyon's book Understanding Digital Signal Processing shows a trapezoid-rule integrator with this formula: y(n) = 0.5 x(n) + 0.5 x(n-1) + y(n-1) Recognizing the first two terms as a moving-average FIR filter, it's easy to modify my integrator to perform the trapezoid rule:

Looking at the formula you provided, it appears you wish to calculate a definite integral of 100 intervals between 101 samples from x = a to x = b. You didn't specify the rate at which your samples arrive -- if this rate is sufficiently low, you might as well have your microcontroller perform the calculation. If on the other hand you wish to sample your input at a typical "audio" rate such as 48000 per second, you could press a SigmaDSP into this service.

The circuit shown below demonstrates an example calculation:

The top portion is a clock which counts sample intervals from 0 to 203 then resets. For the first 101 sample intervals your input signal is allowed through two scaling blocks to the 101-tap FIR filter which calculates the definite integral. After 101 intervals, comparator ABCD1 shuts off the input, while Hold1 retains the filter output at that moment. During the next 102 intervals the filter empties out to get ready for another integral, while Hold 2 latches the previous result and just before the process starts over, the GPIO signals an output pin on the DSP which you could use to trigger a SPI read from your micro (if needed). I drew up two similar versions of this project, for the ADAU1701 and the ADAU1466. Both worked about the same.

What I came up with is simply to show what you can do with these DSPs -- it may not do exactly what you need or perform it accurately enough (etc), but it does demonstrate the capability available to you. Remember that SigmaDSPs are fixed-point with 24 bits after the binary point (roughly six decimal digits), so be mindful of round-off errors. I recommend you scale the integrator's gain (time constant) according to the sort of signals you're measuring to minimize the errors. That's why I built a gain of 100 into the above example -- without it the result measured low by about 0.4%.

You can open the attached project in SIgmaStudio to examine details the screenshot doesn't show, such as the FIR coefficient table. If you have a ADAU1701MINIZ board you can run the project as well. The -1701 truncates the lowest four bits in its readback register, so for maximum precision you might wish to choose a different DSP-- although I suspect the major accuracy limitation is not reading the final result but with round-offs of much smaller numbers within the intermediate calculations.

BTW -- the legendary BrettG who years ago helped me get started with SigmaDSP, is no longer on these boards.

Best regards,

Bob

2605.a20b3ce81e5a6647db583e00acf85817.png
2605.a20b3ce81e5a6647db583e00acf85817.png
2605.a20b3ce81e5a6647db583e00acf85817.png-777x505.png
2605.a20b3ce81e5a6647db583e00acf85817.png-777x505.png
0878.ad7b390f3bde96a2bf9846e15c3723a0.png
0878.ad7b390f3bde96a2bf9846e15c3723a0.png
0878.ad7b390f3bde96a2bf9846e15c3723a0.png-1055x438.png
0878.ad7b390f3bde96a2bf9846e15c3723a0.png-1055x438.png
kaeroul Reply
Jul 29, 2018 00:00

Good Day Bob,

Thanks for the fast response with detail description. What an abundant info to chew but very great info for me to kick start the idea u provide.

And It's a big loss to us for him to been away from these boards.

By the way, your input is really helpful!

Best regards,

kal