Yahoo Groups archive

SynthModules

Index last updated: 2026-04-28 23:14 UTC

Thread

Interrupt-based ADC scanning and filtering

Interrupt-based ADC scanning and filtering

2004-05-06 by djbrow54

I've got some interesting test code running.  It samples and averages
the ADC inputs during the timer interrupt.

I scan each input every 32 mS.  Each input is scanned in an
interleaved fashion.  Since the timer interrupts at 1 mS intervals,
every 8th interrupt I sample a different input.  I save the previous
samples and calculate an average over the last 8 samples and store
this into a circular buffer.  To retrieve the latest average, you
access the buffer at the current pointer value.

I'm not sure if this is fast enough of an update.  I have a simple
loop through code that simply takes the current average and outputs
it to the DACs.  The outputs are rock solid.

The scanning takes 325 uS every 8 mS.

What are your opinions?
Is an 8 samples average too much?
Is an update every 32 mS too slow?

Thanks. - Dave

Re: Interrupt-based ADC scanning and filtering

2004-05-06 by grantrichter2001

> What are your opinions?

There are a couple of things at work. The ADC will dither at the 
bit boundary based on the mount of noise in the incoming 
signal. With the ADC scaled for one "count" per 10 millivolts (10 
volts/1024 counts) and typical analog noise at 1 millivolt RMS, 
about 60% of the input step will be "dither free". The problem will 
be most apparent with slow moving analog inputs. Also 
succesive approximation converters have what is called 
"aperature jitter" that also adds some dithering.

> Is an 8 samples average too much?

I think it is too much. Two sample averages, or four should be 
enough to solve the problem. Or reduce it to an acceptable level. 
It is too late for me to calculate the corner frequency, but it is 
simply the frequency where an output step is reduced by half.

> Is an update every 32 mS too slow?

Much too slow for music. A MIDI byte takes around 320 
microseconds, and three bytes make a "note on" each 
millisecond. But that means a 8 note chord has a bult in "flam" of 
8 milliseconds. Which some people claim to be able to hear.

Latency of under 3 milliseconds is considered good, but less is 
better. A rule of thumb is all channels should be updated within 1 
millisecond (for example the Buchla keyboards scanning speed 
is 1 millisecond divided by the number of keys). The PSIM will do 
that now with no averaging, so any averaging should be kept to a 
minimum.

If you want to hear some awful dithering, try a Roland OP8m CV 
to MIDI converter. The PSIM far out performs that with no 
averaging at all.

Re: Interrupt-based ADC scanning and filtering

2004-05-06 by Mike Marsh

Is this for doing clock divisions?  Seems like it would work very 
well for that.  With an internal clock, it's simple to do 
arpeggiations for example, but trying to sync that to an external 
clock means you have to know what the BPM is a priori.  A running 
average is the way to go.

I don't know if your numbers will work until I actually try them, 
but they sound real good!  I would probably shorten the time by only 
scanning one input, since I imagine most applications would only 
need one sync clock.

Very useful stuff, Dave!  Can't wait to get my hands on it...

Mike

--- In SynthModules@yahoogroups.com, "djbrow54" <davebr@e...> wrote:
> I've got some interesting test code running.  It samples and 
averages
> the ADC inputs during the timer interrupt.
> 
> I scan each input every 32 mS.  Each input is scanned in an
> interleaved fashion.  Since the timer interrupts at 1 mS intervals,
> every 8th interrupt I sample a different input.  I save the 
previous
Show quoted textHide quoted text
> samples and calculate an average over the last 8 samples and store
> this into a circular buffer.  To retrieve the latest average, you
> access the buffer at the current pointer value.
> 
> I'm not sure if this is fast enough of an update.  I have a simple
> loop through code that simply takes the current average and outputs
> it to the DACs.  The outputs are rock solid.
> 
> The scanning takes 325 uS every 8 mS.
> 
> What are your opinions?
> Is an 8 samples average too much?
> Is an update every 32 mS too slow?
> 
> Thanks. - Dave

Re: Interrupt-based ADC scanning and filtering

2004-05-06 by djbrow54

I've rewritten the code to shorten the number of samples to 4.  I've
also interleaved the sampling so that IN-1 is sampled every 2 mS,
IN-2 is sampled every 4 mS, and IN-3 and 4 are sampled every 8 mS. 
This allows me to sample one input every 1 mS timer interrupt.  The
current code requires 250 uS execution time per interrupt so it's
consuming 25% of the available cylcles.  Next week I'll work on
optimizing the code.  I can make it simpler and faster for only 4
samples.

Dave


--- In SynthModules@yahoogroups.com, "grantrichter2001"
<grichter@a...> wrote:
Show quoted textHide quoted text
> > Is an 8 samples average too much?
> 
> I think it is too much. Two sample averages, or four should be 
> enough to solve the problem.
> 
> > Is an update every 32 mS too slow?
> 
> Latency of under 3 milliseconds is considered good, but less is 
> better. A rule of thumb is all channels should be updated within 1 
> millisecond (for example the Buchla keyboards scanning speed 
> is 1 millisecond divided by the number of keys).

My name is Scott and I am a PSimian....

2004-05-09 by Scott Stites

Hooked up the PSIM today.

Holy Mother of God!!!!!!!!!

To quote an unknown preacher in Eno/Byrne's 'My Life in the Bush of Ghosts':  

"Help me somebody".

So what do y'all tell your bosses when you don't show up for work for a week or two?

Cheers,
Scott


[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.