Sigma Delta Audio DAC Object
Chris Micro
Posts: 160
hello all together,
I'm new to the propeller chip and just began to get the LED's blinking at my Triblade Propeller.
What I want to do next, is, to produce some audio waveforms. To do this, I would need an audio dac object in spin. I couldn't find any object in the objects library. Yes; I know, there is this spatial room demo, which is very advanced to produce sound. But to keep it simple, I need an simple an Object with following inputs: LeftPin, RightPin, ADCValue Left, ADCValueRight. Why isn't there any simple Object to do this? For an beginner like me it is essential to have a simple code example to learn from and to expand it step by step. Probably anybody can give me a hint about this isue.
chris
I'm new to the propeller chip and just began to get the LED's blinking at my Triblade Propeller.
What I want to do next, is, to produce some audio waveforms. To do this, I would need an audio dac object in spin. I couldn't find any object in the objects library. Yes; I know, there is this spatial room demo, which is very advanced to produce sound. But to keep it simple, I need an simple an Object with following inputs: LeftPin, RightPin, ADCValue Left, ADCValueRight. Why isn't there any simple Object to do this? For an beginner like me it is essential to have a simple code example to learn from and to expand it step by step. Probably anybody can give me a hint about this isue.
chris
Comments
Perhaps because it's to simple to set up a DAC with the propeller counters. A counter in the DUTY mode generates
a high frequency PWM output, which is nearly ideal for Audio DACs. See the application note AN0001 for a description
of the Propeller counters.
After setting the counters into the right mode, you can simply write the DAC value to the FRQA and FRQB registers.
The counter produces then the according PWM pulswith. The value should be centered at $8000_0000 to get the
best possible result ($0000_0000=max negativ, $8000_0000=middle, $FFFF_FFFF=max positiv).
The DAC outputs should have an R-C lowpass filter to eliminate the high PWM frequencies (in the MHz).
The following example shows how to set up the counters and produces 2 slightly detuned triangle waves at the left
and right output. You can play with the DDS values (63_000_000) to get other frequencies.
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
Thank You, nice example, but I do not really understand it.It seems to be a delta sigma adc and delta dac but only single channel. A Delta Dac would probably produce results which have a higher quality than pure PWM. Therefore I would prefer this to have it in an DAC-Object than only PWM.
@Ariba
Thank you for this nice example. At least it was easy to run. For a synthesizer I would prefer to separate the signal generation and the DAC. This is due to the fact that in my opinion the timing conditions could be met easier and in a later stage of programming the DAC part could be enhanced with some filters and mixers. As far as I understood, the DAC value could be transfered to the DAC Object by a pointer to the propeller main memory.
In your example the loop timing is very unclear. To produce a certain pitch, lets say 440Hz, it would be very useful to have a constant loop cycle of lets say 20KHz. With this to values the increment for the phase accumulator can be easily calculated ( I saw your synthesizer project, congratulations )
I will try to make a pure DAC Object with PWM and pointer input as learning example. Of course it would be better to have an Object with a Delta DAC but that seems to complicated for now.
chris
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
I'm still trying to make the simple DAC-Object. And as I'm new to Spin, there seems to be a pointer problem. Has anybody a hint?
The PWM frequency varies with the value. The shorter puls length part is always 1 clock cycle (12.5ns @80MHz).
The longer pulslength part is adjusted in the length so that the ratio corresponds to the value.
At value $8000_0000 you have a PWM frequency of 40MHz (1 high, 1 low cycle) ! At $0000_FFFF ou have only 2.4 kHz (1 high, 32767 low cycles).
Spin is not fast enough for Audio processing, this must be done in Assembly.
Andy