S32K144 Audio Generation with Simulink

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K144 Audio Generation with Simulink

Jump to solution
778 Views
Umutulker
Contributor I

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.

 

0 Kudos
Reply
1 Solution
717 Views
stefanvlad
NXP Employee
NXP Employee

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:

stefanvlad_0-1706533240959.png

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:

 

stefanvlad_2-1706534961642.png

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.

 

View solution in original post

0 Kudos
Reply
3 Replies
718 Views
stefanvlad
NXP Employee
NXP Employee

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:

stefanvlad_0-1706533240959.png

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:

 

stefanvlad_2-1706534961642.png

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.

 

0 Kudos
Reply
702 Views
Umutulker
Contributor I
Hello,

I was trying to generate audio signals from the s32k144.
Just as I thought, I need a MOSFET driver then for higher power outputs. My speaker can output maximum power of 9W. So the circuitry should be like this: PWM pins -> Filter -> MOSFET Drivers -> MOSFET bridge -> Speaker. Am I correct?

Also, is there a better/easier way to generate audio with s32k144? Use of the DAC with Simulink?

Thank you for your help!
0 Kudos
Reply
688 Views
stefanvlad
NXP Employee
NXP Employee

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 

stefanvlad_0-1706795294295.pngIn 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.

0 Kudos
Reply