Hello,
I am trying to generate an audio output with sine wave generation on Simulink. With arranging the frequencies and duty cycle, i can currently output a sinusodial PWM from pins. I feed it into a basic low-cost class-AB amplifier. I was wondering if i can directly use s32k144 as a Class-D amplifier. This type of amplifier basically transforms analog signal into a high frequency PWM and then filters it to original signal with higher amplitude. S32k144 can output 0-5V PWM, so theoretically i can low-pass filter it and connect it to a speaker. My concern is the current consumption. Will the speaker try to consume more current? I think the maximum current is about 30mA in s32k144, please correct me if am wrong.
In summary, i am trying to generate audio with the PWM output of the microcontroller. Do i need to amplify it? I already have 0-5V output from PWM.
Thank you.
Solved! Go to Solution.
Hello Umut Ülker,
Regarding the request above, may I ask what application do you want to design?
In general, all microcontrollers' pins have a very limited current output (10-25mA), and they cannot be used as a Class-D amplifier.
Instead, the typical diagram should be the following:
The PWM pin from MCU is filtered and current is limited by a resistor that is feed to a driver, and its outputs is tied to the Load (speaker).
The Driver can be an Op-Amp for low power application or headphones, or it can be a Class-D amplifier for speakers.
A very simple schematic to test the Sine output from S32K144 is the following:
Where Vout is 5V, Q1 is a simple NPN transistor 2N3904 and the PWM output pin of the S32K144 is connected to R1 resistor with values from 220 to 1k Ohms.
One simpler approach is to use the Motor Control Shield for DEVKIT and plug it into the S32K144-Q100 Evaluation Board
Then you can connect the speaker between the Phase A and Ground on the J13 (green) connector from the Motor Control Shield.
There might be needed to add some capacitors in order to filter the output better.
Hope this information helps,
Stefan V.
Hello Umut Ülker,
Regarding the request above, may I ask what application do you want to design?
In general, all microcontrollers' pins have a very limited current output (10-25mA), and they cannot be used as a Class-D amplifier.
Instead, the typical diagram should be the following:
The PWM pin from MCU is filtered and current is limited by a resistor that is feed to a driver, and its outputs is tied to the Load (speaker).
The Driver can be an Op-Amp for low power application or headphones, or it can be a Class-D amplifier for speakers.
A very simple schematic to test the Sine output from S32K144 is the following:
Where Vout is 5V, Q1 is a simple NPN transistor 2N3904 and the PWM output pin of the S32K144 is connected to R1 resistor with values from 220 to 1k Ohms.
One simpler approach is to use the Motor Control Shield for DEVKIT and plug it into the S32K144-Q100 Evaluation Board
Then you can connect the speaker between the Phase A and Ground on the J13 (green) connector from the Motor Control Shield.
There might be needed to add some capacitors in order to filter the output better.
Hope this information helps,
Stefan V.
Hi Umut,
Yes, for a speaker of that high power 9W, you will need a MOSFET bridge with driver, and details are in previous post regarding connections.
The simplest solution is to get the Motor Control Shield for DEVKIT and plug it into the S32K144-Q100 Evaluation Board.
Then you will need only a 12Vdc Power Supply, and you can connect the speaker on the J13 (green) connector from the Motor Control Shield.
A guide for getting started with the boards above is written in the page: Getting Started with the S32K144 BLDC/PMSM Development Kit | NXP Semiconductors
In order to generate a better Audio signal, filters are needed and regarding the output of MCU, the 16-bit FlexTimer (FTM) can generate a much higher PWM resolution than the 8bit DAC inside the S32K144.
You're welcome,
Stefan V.