2024-06-21 12:22 AM
Problem Statement: Amplifying Low-Amplitude Audio Signal on STM32 Nucleo64 Board
Hello STM community! I'm new here and seeking some guidance. I'm working on a project using the STM32 Nucleo64 board to create an announcement maker. My setup involves using an interrupt to handle an 8kHz frequency sampled audio, which is converted into an array. This array is then outputted from a PWM pin.
However, I'm facing an issue with the audio amplitude. The output signal amplitude is very low, less than 3.3V, which is insufficient to trigger the amplifier circuit and effectively broadcast the audio.
Is there a way to internally amplify the signal output coming from the STM32 board? Any suggestions or guidance would be greatly appreciated!
Solved! Go to Solution.
2024-06-21 02:49 AM - edited 2024-06-21 07:16 AM
The PCM data ranges from 0-255 that is it's 8bit data
Indeed, very low data range scale vs the full scale of the timer counter/CCR which are 16-bit.. If you multiply these values by 256 (to amplify the values)? what happens?
You can also see this video starting from 3:27. I think you can start by generating a sine wave before moving to generate audio signals to validate the theory and the HW!
2024-06-21 12:59 AM - edited 2024-06-21 12:59 AM
Welcome, @Yato, to the community!
An STM32 can be operated with a maximum of 3.6V, from which the internal DAC is also operated. For this reason, no higher voltage can be output in principle.
However, you can amplify the signal, whereby the choice of amplifier depends on the load to be driven, e.g. a loudspeaker with which parameters?
Regards
/Peter
2024-06-21 01:07 AM
Hello and welcome to the community?
Not sure what do you mean by "I'm facing an issue with the audio amplitude. The output signal amplitude is very low, less than 3.3V". Do you mean the GPIO pin voltage level? how much? which GPIO pin?
As you generating an audio signal using PWM, did you add an external filter? do you mean the low voltage is on the filter output?
You can also refer to these articles:
Custom Signal generation using PWM and DMA
How to generate a sine wave using PWM and RC filter with the STM32 Part1
How to generate a sine wave using PWM and RC filter with the STM32? Part2
2024-06-21 02:11 AM
I am using tim2 ch1 for pwm generation , the pin I am using is PA0 but I also tried with PC6 that is tim8 ch1. The main issue is that I am getting less then 1V on signal output (GPIO Output) and after this circuit that i attached , The audio is audible but the loudness is way less than my requirement. Just for references I tried the same algorithm with another Microcontroller (not STM) with 5V output voltage using the same data the loudness was excellent. I mean even if we go by the logic that STM32 has 3.3V output Voltage I can understand that the level of loudness will be slightly low but actually it way less. The STM 32 audio sound can be heard for the distance of 100cm around 3 feets but with that different microcontroller the whole room is covered even in slightly noisy environment.
2024-06-21 02:14 AM
I am using a 8ohm speaker. I know that the stm32 has limitation of 3.3V and I am using two stage amplifier (you may see the circuit in the other comment I have replied to). I am using GPIO pin PA0
2024-06-21 02:31 AM - edited 2024-06-21 02:40 AM
I am using tim2 ch1 for pwm generation , the pin I am using is PA0 but I also tried with PC6 that is tim8 ch1. The main issue is that I am getting less then 1V on signal output (GPIO Output)
Just for references I tried the same algorithm with another Microcontroller (not STM) with 5V output voltage using the same data the loudness was excellent. I mean even if we go by the logic that STM32 has 3.3V output Voltage
Sorry, but how you did measure the IO pin voltage? during the PWM generation? I think your data does not reach the full scale of your 16 bit timer as you are using the same data from a 5V MCU. You need to adapt your data according the STM32 timer. Maybe you need to amplify your signal in your lockup table.
2024-06-21 02:40 AM
In addition to that: your amplifier circuit is a simple double inverter, where you can omit the second stage and connect the speaker directly to Q1. Q2 has no advantage, only the disadvantage that you permanently connect the speaker to 5V when the PWM output is inactive, which dynamic speakers don't like at all.
To remove the DC offset of the PWM signal, you should provide a capacitive coupling and also connect a real audio amplifier, e.g. the TS4871. In its data sheet you will find an example schematic that already contains the capacitive coupling mentioned above.
2024-06-21 02:42 AM
Yes, I measured it when data was being transmitted on PWM pin. I have added few lines so when the data is being transmitted to the pin from flash the onboard led turns on. Also I am using third party software for PCM data generation by converting audio data sampled at 8khz frequency to PCM bytes. The PCM data ranges from 0-255 that is it's 8bit data
2024-06-21 02:49 AM - edited 2024-06-21 07:16 AM
The PCM data ranges from 0-255 that is it's 8bit data
Indeed, very low data range scale vs the full scale of the timer counter/CCR which are 16-bit.. If you multiply these values by 256 (to amplify the values)? what happens?
You can also see this video starting from 3:27. I think you can start by generating a sine wave before moving to generate audio signals to validate the theory and the HW!
2024-06-21 03:16 AM
I will try to scale the data, also I can hear the audio clearly so I don't think the problem is with generation of signal.