Anyone done it, or know of projects that have? I'm thinking of using a microcontroller to implement a class-d bass amplifier (say <200hz) from audio input all the way to driving the gate drive transformer mosfets.
The attraction of this is (apart from fun) is that all the issues associated with producing a reliable and accurate amplifier can all be implemented & experimented with in software. For high power output all the relevent protection built in, without too much need for a crowbar on the output terminals!
cheers,
Rob.
The attraction of this is (apart from fun) is that all the issues associated with producing a reliable and accurate amplifier can all be implemented & experimented with in software. For high power output all the relevent protection built in, without too much need for a crowbar on the output terminals!
cheers,
Rob.
Would you consider a microcontroller with an external opamp for the input stage/integrator? Or did you mean using an internal A/D converter to sample the input? I would think that if you allowed for an external opamp, it would give you more flexability, but I'm just asking to clarify your intentions.
On a related note, there are SMPS power supply projects that use a microcontroller for all of their processing.
On a related note, there are SMPS power supply projects that use a microcontroller for all of their processing.
The modulator is the easiest part and it's actually harder to implement in software. A good analog modulator may be as simple as a single LM311 comparator. The hardest part is the power stage and its PCB layout and a DSP won't help there.
I would definitely have an external input stage, almost certainly an opamp. For the microcontroller, I would like to use something like this prototype board http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en536385 with one of these in ithttp://ww1.microchip.com/downloads/en/DeviceDoc/41350b.pdf page 117 onwards contains interesting PWM info on this PIC.
I was originally thinking along the lines of generating the pwm myself in software, however this might not be reliable, bearing in mind i'd like to do other things on the controller too. The above microcontroller has full bridge pwm generation capabilities built in, so could do the book-keeping for me.
I stumbled across some smps microcontroller stuff before, this is what got me thinking about this.. I've not yet looked deep enough into this idea to contemplate soldering yet. Although i did order a new breadboard yesterday 😉
cheers,
Rob.
I was originally thinking along the lines of generating the pwm myself in software, however this might not be reliable, bearing in mind i'd like to do other things on the controller too. The above microcontroller has full bridge pwm generation capabilities built in, so could do the book-keeping for me.
I stumbled across some smps microcontroller stuff before, this is what got me thinking about this.. I've not yet looked deep enough into this idea to contemplate soldering yet. Although i did order a new breadboard yesterday 😉
cheers,
Rob.
@eva, definitely agree about the output stage & its layout. I had originally considered using a microcontroller for all the peripheral functionality, fault detection etc.. leaving the amplifier itself entirely analogue, but then figured if i have a fast processor in there i could use it for everything short of driving the output stage! As i looked further i realised just how feature packed those PICs are..
cheers,
Rob.
cheers,
Rob.
I think even for 200Hz, you would be hard pressed to implement in a basic micro like a PIC18. Simply not having the I2S ports would be a major pain. A DSP is not very expensive. Freescale has a class-D reference based around one of their Symphony 24 bit audio DSPs. That could be used as a good reference.
Alvaius
Alvaius
Rob,
I hope you get something going.
It seems like the microcontroller could just generate the PWM stream directly without a modulator. The algorithm and coding might not be realtime, but you could add latency to the higher frequencies to sync them back up. This looks like a really fun project.
I hope you get something going.
It seems like the microcontroller could just generate the PWM stream directly without a modulator. The algorithm and coding might not be realtime, but you could add latency to the higher frequencies to sync them back up. This looks like a really fun project.
Microcontroller class D for audio = a big waste of time.
If you want it simple, self oscillating is the way to go and it outperforms the other solution.
If you want it simple, self oscillating is the way to go and it outperforms the other solution.
And now I'm looking for the same thing.
I wanted to open a separate topic, but I saw this old topic.
The idea is good and I think it has many advantages.
The problem is I have further complicated the situation: being and quality and very cheap
As advantages can read the SD card and directly out PWM:
Simple SD Audio Player with an 8-pin IC
I have tried with dsPIC SMPS specialized, but the results were below expectations:
- 16 bit high speed PWM out
- 10 bit 1MSPS A/D
Looking further improvement ideas
I wanted to open a separate topic, but I saw this old topic.
The idea is good and I think it has many advantages.
The problem is I have further complicated the situation: being and quality and very cheap
As advantages can read the SD card and directly out PWM:
Simple SD Audio Player with an 8-pin IC
I have tried with dsPIC SMPS specialized, but the results were below expectations:
- 16 bit high speed PWM out
- 10 bit 1MSPS A/D
Looking further improvement ideas
Anyone done it, or know of projects that have? I'm thinking of using a microcontroller to implement a class-d bass amplifier (say <200hz) from audio input all the way to driving the gate drive transformer mosfets.
cheers,
Rob.
Depends on how much you do outside the micro and how much inside.
You probably need a 20MHz micro to do a good job.
Or one with PWM on board.
Some of the PICs are pretty quick and have PWM outputs.
I am currently working on a LLC SMPS using a PIC16f506 running at 8MHz.
It does half bridge into a IR2113 into a pair of mosfets.
The LO and HO outputs are done in software.
I use 3 pwm frequencies. 166KHz, 125KHz and 144KHz.
The PIC is quite good because all none branch instructions are 1 cycle each.
Branch instructions take 2 cycles.
Had a few problems but getting there.
Depends on how much you do outside the micro and how much inside.
You probably need a 20MHz micro to do a good job.
Or one with PWM on board.
Some of the PICs are pretty quick and have PWM outputs.
A lot has evolved in available micros, compared to the years when this thread was started.
In the mean there are amazing micros + development tools out there,
which allow extremely powerful solutions even for people who are not nerds in uC technology.
Besides the PICs which Nigel mentioned one should also have an eye on the Arduino platform.
Another example is the XMC family.
It contains multiple high resolution PWM units and the development tool
already offers tons of universal Apps.
I.e. comfortable PWM Apps which already include dead time generation.
KIT_XMC45_RELAX_LITE_V1 Infineon Technologies | Mouser
As my personal learning project for microcontrollers I am using it for an RC model.
- Decoding the signals from the RC receiver
- Battery management
- Engine sound generation
- ClassD amp modulator 😀
All in one micro. Pretty amazing.
Even a dinosaur like me has to admit that modern micros offer low hurdles in getting things running and at the same time delivering unbelievable capabilities.
So far fully digital high quality PWM generation for classD amps is not common, but it is just a matter of time that the digital audio input will be converted to PWM directly and feedback is taken by an ADC and a digital loop control will become an everyday solution.
Last edited:
You probably need a 20MHz micro to do a good job.
I am currently working on a LLC SMPS using a PIC16f506 running at 8MHz.
It does half bridge into a IR2113 into a pair of mosfets.
Some years ago I saw a guy doing a project with PIC:
https://www.facebook.com/320voltcom/posts/414480012006860
Now on facebook....
Personally, I use this integrated, that just because it works at 5V(to not use 3.3V logic).
I took that program, compiled, but it did not work. Therefore I decided to make my own soft.
The dsPIC runs at 120MHz internal, which means 30M Inst / second.
In addition, this dsPIC can supports speech recognition and acoustic correction algorithms. (There are many examples on Microchip page)
Sure it's a few years ago technique...😛
Similarly, there is no point, put two drives MOS, as the author of the schematic.
- ClassD amp mo dulator 😀
All in one micro. Pretty amazing.
Could you give me more details, please ? About the ARM architecture, I just read about it
Last edited:
Could you give me more details, please ? About the ARM architecture, I just read about it
...well, read more - 😉
ARM Cortex-M - Wikipedia, the free encyclopedia
For the Infineon XMC family you will find multiple ten thousand pages of
detailed description - no way to summarize in short, at least for me there is no way.
If you want to chose the XMC or any other depends on your taste and needs.
Strolling through the available types, block diagrams, integrated peripherals and may be reading through specific options for advanced interrupt handling will help you to make your choice...
Also I am not convinced that these controllers would be my first choice
for audio processing, but I had smile on my face when I noticed that it allows
me to realize a primitive classD modulator, with just a few lines of code.
In my case I am using it to amplify an analogue signal, which limits the performance to the 12bit of the integrated AD converters.
The analogue signal is the engine sound which I am synthesizing from multiple PWMs (rythm) and analogue resonators (sound colour)....
My excitement comes from the fact that the free development tools allow to use these controllers without the need to dig manually into every register and already after reading few hundreds of pages and understanding just few tens of pages you can use it for surprinsingly demanding applications.
I don't know the XMC parts well but, yeah, any micro with a half bridge motor control peripheral is a candidate for a class D audio controller. NXP's LPC M4s have three phase peripherals that clock up to 204MHz. So they'll go for applications like stereo, biamp, triamp, and full bridge with much of the phase noise shifted out of band. The IRS20957 seems to have something like -80dB open loop linearity, so it's tempting use it (or similar parts) though one could also use the motor peripheral's dead time control and such with a focus on digital correction of high side level translation and probably get pretty decent open loop performance with some inductor spend. It's possible the NCDX modules might have an implementation in this direction, though the ATtiny13 used their previous generation seems to have been used only in a supervisory capability. Might be a DIYA thread with more details about that; I've not looked.
For DDFA kinds of approaches the M4s best suited for implementations with minimal parts are probably Analog's ADSP-CM4xx family. Their ADCs linear to around -80dB, -90dB if one's feeling like taking top datasheet specs. Would give ChocoHolic an extra bit or two too. 😉
For DDFA kinds of approaches the M4s best suited for implementations with minimal parts are probably Analog's ADSP-CM4xx family. Their ADCs linear to around -80dB, -90dB if one's feeling like taking top datasheet specs. Would give ChocoHolic an extra bit or two too. 😉
A lot has evolved in available micros, compared to the years when this thread was started.
In the mean there are amazing micros + development tools out there,
which allow extremely powerful solutions even for people who are not nerds in uC technology.
Besides the PICs which Nigel mentioned one should also have an eye on the Arduino platform.
Another example is the XMC family.
It contains multiple high resolution PWM units and the development tool
already offers tons of universal Apps.
I.e. comfortable PWM Apps which already include dead time generation.
KIT_XMC45_RELAX_LITE_V1 Infineon Technologies | Mouser
As my personal learning project for microcontrollers I am using it for an RC model.
- Decoding the signals from the RC receiver
- Battery management
- Engine sound generation
- ClassD amp modulator 😀
All in one micro. Pretty amazing.
Even a dinosaur like me has to admit that modern micros offer low hurdles in getting things running and at the same time delivering unbelievable capabilities.
So far fully digital high quality PWM generation for classD amps is not common, but it is just a matter of time that the digital audio input will be converted to PWM directly and feedback is taken by an ADC and a digital loop control will become an everyday solution.
This is an interesting thread, Hi there Mr Chocolate!
Hardware has certainly advanced extensively with the ARM, dsPIC and SHARC /BlackFin players.The realtime audio DSP research has increased extensively with lots of wonderful algorithms performing some amazing stuff!
Yet, there remains some interesting "non linear" analogue behaviour that becomes "over complex" having roots with control theory that can "only" be purely modelled mathematically expressed in code
analogue is really complex in the digital signal processing time domain I too feel its a waste of time to model its just to unconventional, the algorithms is just to complex even for a beginner to intermediate guy/girl
Their are other areas where I do see traction and that is power electronics.
The dsPIC controllers have PID libraries that allow dsp controlled SMPS (as they have some useful math instruction sets), I even attempted to read the code but the experience was horrible. (This is probably cause I lack the math and deeper aspects of SMPS design), as everything was from a mathematical control theory level to add to the nightmare it was all written in assembly (for good reason "performance")
Imagine taking your self oscillating hysteresis modulator reduced to low level assembly and having to maintain that code base, even worse debugging a problem in the software domain how will someone even start to debug a fast moving signal at the level.
It feels more like esoteric dsp knowledge, but I feel optimistic this is just my view.
For DDFA kinds of approaches the M4s best suited for implementations with minimal parts are probably Analog's ADSP-CM4xx family. Their ADCs linear to around -80dB, -90dB if one's feeling like taking top datasheet specs. Would give ChocoHolic an extra bit or two too. 😉

...I am more optimistic.Imagine taking your self oscillating hysteresis modulator reduced to low level assembly and having to maintain that code base
When generating the PWM in digital domain, then the self oscilating ideas would overcomplicate things - exactly opposite to their simplicity in analogue solutions.
When doing it in fixed clocked method we do not need a dynamic hysteresis.
And for fixed clocked solutions already today extremely powerful PWM algorithms exist, the Apps for the XMC even allow a dynamic dead time setting. Also PID feedback algorithms are in use in mass production since years.... then pairing this with an high end ADC for measuring the output (or also for handling analogue inputs) - IMHO such solutions are not so far away.
Likely it won't be me to develop the dsp algorithms, my strength is in analogue electronics + switching power stage designs + magnetics.It feels more like esoteric dsp knowledge, but I feel optimistic this is just my view.
But there is a crowd of guys who have their strength in the digital domain + software, and for some of them even very strange dsp math is not esoteric. Funny thing - for the concerned digital brains who I met, the details of switching power stages appeared esoteric... 😉
If necessary many of them would be able to deliver pretty high quality solutions for the dsp and loop control algorithms within 1 year.
But obviously the managements of the capable companies do not regard it as necessary (= commercially attractive) for classD. So these solutions will enter classD later - after they have become a commodity in more industrial applications.
If you look into companies like TI, ST, Infineon, +++, ++, - they all have the guys for the switching power stages and also guys for the digital domain as well. It is just a management decision for which projects which resources are used.
And it is not likely that any management will decide to spend massive man power for a solution, which would still have an disadvantage in hardware costs. Analogue classD modulators are so cheap and good, that there is no commercial momentum to substitute them by a fully digital solution with identical quality. That's the situation today, but the costs will converge...
Has anyone considered an FPGA? I think the basic architecture is mostly an ADC then some digital processing for the pwm followed by the output driver. Add a second ADC for feedback or do both input plus feedback in the analog domain. I think both are reasonable. FPGA are inherently faster than a micro and very deterministic.
Also, FPGA handle DSP functions very well. In my opinion an FPGA plus a micro is a good solution. I suppose sample rate and ADC resolution factor heavily on the quality of this approach.
In regards to Eva, I would like to see a side by side comparison of all analog vs digital pwm. I assume tripath pwm was a digital process and people liked it to some degree.
Also, FPGA handle DSP functions very well. In my opinion an FPGA plus a micro is a good solution. I suppose sample rate and ADC resolution factor heavily on the quality of this approach.
In regards to Eva, I would like to see a side by side comparison of all analog vs digital pwm. I assume tripath pwm was a digital process and people liked it to some degree.
- Status
- Not open for further replies.
- Home
- Amplifiers
- Class D
- using a microcontroller for 'whole' class-d amplifier