[sdiy] Wavetable Design Update

Paul Maddox paul.Maddox.mail-list at Synth.net
Thu Feb 3 03:32:58 CET 2011


Matt,

> This might work with assembly (which I guess is what you used from past
> conversations,) but I discovered that an array of 128 unsigned chars in C
> takes up a fair bit more than 128 bytes.

HUH?
What compiler are you using, that's wrong, so very wrong.
you don't have chars promoted to int or something do you?

> Having now moved to 256 bits per
> sample and an ever-growing list of samples, this far exceeds the FLASH
> capacity of the TINY2313 I had been hoping to use.

ahhh, ok, I forgot that part.
You don't have enough IO on that to do what I suggested.

> Otherwise, what I don't understand (I'm probably being a bit thick here) is
> how doing this is how a loop can be run at the right speed without the use
> of timers and interrupts - going back to the same issue.

Use the phase accumulator approach.
Only don't use 8 bits for address, just use the MSBit as your output
to your counter circuit.
All your ATTiny2313 need do then is the following;

Add one 32 bit number (control word) to a 32 bit number (accumulator),
if MSBit of accumulator = 1, set output pin high
else if MSBit of accumulator = 0, set output pin low

Just do that in your main loop and *nothing* else.
The you have a UART RX interupt, and you have such that you send the following

0x80 0xVV where "VV" is the lower 8 bits of your control word
0x80 0xWW where "WW" is bits 8 to 15 of your control word
0x80 0xYY where "YY" is bits 16 to 23 of your control word
0x80 0xZZ where "ZZ" is bits 24 to 32 of your control word (ensure bit
32 is always 0)

> Remember that I'm using VARIABLE rates to scan the table - wherever it is -
> with number of samples per cycle being constant. As I'm also looking to use
> arbitrary values to allow for detuning and possibly modulation, the issue of
> calculating values for timer registers still occurs.

This will generate your variable rate, see
http://en.wikipedia.org/wiki/Numerically-controlled_oscillator for an
explaination, figure 1 sums it up quite nicely, the only difference is
you're using one bit, the MSBit of the accumulator to feed into your
counter for waveform lookup.

> I'd have thought it would be tricky to operate from a MEGA8 (at 8MHz) when
> the top scan speed of 3.2MHz is nearly half clock speed.

The MEGA8 will run 16Mhz, the 8 referes to the size of flash, 8Kbyte.

> That's the way things tend to turn out for me - I tend to start off with a
> highly complex design, which I can only simplify when I've seen it in action
> (even if this is on paper.) So yes, I probably am - at least at this stage!
> (And thanks for your ongoing patience - it must be quite exasperating
> watching me flounder around like this!)

Look at the Monowave Schematics posted from a few emails ago.
There I used an AT90s1200 to generate a single variable wate square
wave that fed a counter and wave lookup.
The AT90s1200 was controlled from another CPU (admittedly using
parallel data but the 90s1200 didn't have a UART).

> This specific design, however, came about from an attempt to build the whole
> thing from discrete logic and re-cycled EPROMs. (The discrete logic has
> become a CPLD, but it's still showing discrete logic on the schematic
> capture ;-) The microcontroller was only ever going to be a timing source
> for testing - the idea being that this would be a module with a clock input
> that could come from "somewhere."

Yep, So you'd have

MIDI -> MCU(MIDI) -> Tiny2313 (Oscillator) -> CPLD -> EPROM -> DAC

to get a second oscillator, you could easily use the same MCU, like
this (excuse bad ASCII)

MIDI -> MCU(MIDI) -> Tiny2313 (Oscillator 1) -> CPLD -> EPROM -> DAC
                             -> Tiny2313 (Oscillator 2) -> CPLD -> EPROM -> DAC

> Anyhow, my copy of Chamberlain's MAOMP has finally turned up today (yay!) so
> I'll be getting stuck into that after my nap.

superb, there's a whole chapter on phase accumulator oscillators.
It's a great book, wish I had kept my copy now.

Paul



More information about the Synth-diy mailing list