Any idea for optimized sawtooth phase control?
Hello all,
In a ADAU1701 application, I need to manage dynamically (from a DC offset block) the phase between two sawtooth signals. With most DSP, this is a trivial operation: add an offset to a 'master' sawtooth and perform a mask to do a wraparound when signal reaches 1.0. But since the ADAU1701 does not have bitwise logic... it's not trivial at all on this chip.
I have found a solution based on simple arithmetic (adding a constant, and perform a signal foldback when offseted sawtooth is over 1.0), but it's really time consuming (it takes more than 30 DSP cycles per phase control!). I really need to save CPU cycles on this application (if I can save 10 cycles per oscillator instance, I will be able to remove one DSP from the board!)
Does anybody have an idea to do this operation, in the most simple way?
Thanks a lot
Benoit
Audio Signal Processors
SigmaDSP Audio Processors
adau1701
Hi Benoit,
You can use the 'Sawtooth Wave with Phase and Gain"
The phase value can be 0 to 360 degrees.
Please follow the link below for more details.
Sawtooth With Phase and Gain [Analog Devices Wiki]
Thanks,
Venky
Hi Venky,
thank you for your answer. However, the "sawtooth with phase control" does not work in my case. As I wrote in my question, I need a dynamic phase control (the phase must be controlled by a DC input). The phase defined in the "sawtooth with phase control" is onyl defined in static way during program configuration. If you try to change the phase parameter dynamically with this block, it does not work (the value is only taken into account at reset)
Moreover, the phase accuracy with this block is not good enough. It's only 128 steps for 360°.
Benoit
Hello Benoit,
What is the frequency of the sawtooth you are using?
What is the sampling rate you are using?
Also, can you attach a project showing how you tried this in your first attempt?
What are you trying to do? create a phase locked loop? It may help to better understand what you are trying to do with the sawtooth waves.
Thanks,
Dave T
Hi Dave,
the master sawtooth frequency is variable from 30Hz to 2000Hz, it is used in synthesizer application (band limited oscillator based on Differential Parabolic Waveform). You can see the application here : http://imodular-synth.com
Sampling frequency is 48kHz (but it can ber switched to 96kHz when user wants higher maximum frequency, but this lowers the maximum polyphony)
Here is the phase control I have implemented for now (the one I would like to optimize). This block is copied in each oscillator voice (there is one for two sawtooh sources)
Benoit
Hi Benoit:
Looking at your schematic, I see a couple of potential optimizations you can do.
1.-By right clicking on the first adder (Add2), simply add another pin to avoid the need for the 2nd adder (Add1).
2- You can also avoid 2 instantiations of the DC block by creating a T connection that connects the first DCblock (DC3) with the 2nd pin of your subtraction.
If you would like to contact a 3rd party that can make one block out of this, specially please contact us and we can point you to the right person.
Hope this helps.
Miguel
Hi mmmike,
thank you for your optimization proposals. I tried to use them to see how many CPU cycles I would save (see below)
First, I have to provide you some details about my application. I need to fit 16 band limited oscillators in one DSP. Each oscillator feeds one voice, so there will be 8 voices. Right now, I am able to put only 7 voices, so I would need an extra DSP just for the last voice, which is not acceptable.
In my application, the input of the phase control is fed by a non-band-limited sawtooth oscillator. On output, you will then get a phase-controlled image of this non-band-limited signals. The two sawtooth signals are then send to the band limitation algorithm, in order to generate various band limited signals.
Without your proposed optimization, my DSP code is 964 bytes long (for 7 voices polyphony, so we can extrapolate roughly that an 8th voice would need 1100 instructions - more than the allowed 1024)
With your optimization, the code size is reduced by 5 instructions for each phase control, so I save 35 instructions in the current program. The complete program becomes 929 instructions for 7 voices, the 8th voice still does not fit (1061 instructions total)
The key of the problem is that the SigmaStudio toolbox does not have a bitwise logic for the ADAU1701. On other DSP, the phase algorithm is much more efficient: in order to generate the phase, it is only needed to add a constant to sawtooth and make it wraparound on let's say 24 bits, which is nothing else than a AND to keep needed bits (MSB are getting cleared). On ADAU1701, this logic is missing (only "1 bit logic" is available) and adding a constant to sawtooth signal with an adder makes it saturate, it does not make a wraparound.
I have a last question: what are the requirements to become a 3rd party developer, in order to create new objects for the SigmaDSP toolbox (except the NDA of course)?
Benoit
Hi Benoit:
You might be wanting to do with the SigmaDSP core something that uC and other processors do more easily. Bit-wise operations on the SigmaDSP core are very limited. SigmaDSP mostly have word operators. The SigmaDSP was designed for audio purposes and has HW accelerators to simplify the instructrion set. The wraparound that you mention is also easy as the core itself clips at its limits (instead of wrapping around).
In other words, it's not that the library doesn't have the operators you are looking for. It's the core itself.
I wonder if there are further optimizations that can be made in the rest of your schematic. Is this something you can share? I see we are almost there.
Send me an email for more info and if you prefer to keep things confidential.
Regards
Miguel
Hi Miguel,
thank you for these explanations. I am a bit surprized that SigmaDSP do not have full bit-wise operators, but OK.
Following your earlier suggestions, I have been able to reduce the number of operators. I also found that the pre-scaling in my phase shifter was useless : I wanted to keep the signal in the -1..+1 range, but since the SigmaDSP are Q5.23 and not Q1.xx, I can work with shifted signals between 0 and +2. This saved me a few adders, DC sources and multipliers.
I have been also suprized to see (after your explanations) that the DC sources are taking more resources than I expected. For me, it was just a reading of a memory cell, but the code generated seems more complex. I found that if you have the same value for a constant, it's more efficient to put one DC with a T connection rather than duplicating the DC sources.
And finally... I have reorganized my code with all these optimizations and tadaaaaa!! I am now able to fit my 8th voice in the DSP and it takes only 938 bytes! In other words, there are now 16 band limited oscillators with mutliple waveforms running in a single ADAU1701
Thank you for your help, I will contact you in private for another topic.
Benoit
HI Benoit:
Yes DC sources have their own code even if at a certain point, the parameter is the same. From a DSP/SigmaStudio perspective, there is no way to tell if this parameter will change and needs be made independent. In your case, you have prior knowledge that the parameter will not change.
Glad to see that everything is working for you.
Regards
Miguel
Please log in to reply.



