Hi everyone!!! i'm new to STM32f4. i was wondering if this microcontroller can amplify an input analog signal through audio jack i.e an audio signal and produce amplified voltage at any gpio pin...
Hi nomikhan,
It's hard to give a definite answer to your question. Some will say yes some will argue and say no. The reason for this is you specifically stated "produce amplified voltage at any gpio pin..."
If we answer yes to your question, how is the audio signal processed?
At the input you have to convert the signal from analog to digital. At the output you need to convert the digital samples back to analog. Typically, you will need a DAC (external or internal to the MCU), filter, and driver. The use of the term "GPIO pin" is where the argument will arise.
Digital-to-Analog Converter
As daith stated he doesn't believe you will be able to do the amplification because STM32F4s don't have a DAC (please post the particular STM32F4 that you have; the STM32F410 for example have a 12-bit DAC, some members of the family may even have 2). However, microcontrollers can implement a class D amplifier and note that Cortex-Ms can be run at high clock rate. If we use the strict definition of GPIO then you can implement the class D amplifier in software (usually this is done only as exercise not in practical application). If you loosen the specification at the output, you can use a timer (preferably with PWM capability) instead of GPIO to alleviate the CPU of the processing burden.
Filter
For high-fidelity audio application, filtering of PWM signal is difficult but for the purpose of showing that your question can be answered yes, simple filters are adequate. I remember that Norton Diagnostics (a diagnostic program for microcomputers in the DOS era) includes a speaker test that sends a short digitized speech to the PC's speaker. The speaker is only controlled through the programmable interval timer and a gating signal. The speaker circuit does not have a special filter; the speaker is connected to the driver only through a limiting resistor; in some cases capacitive coupling is employed to prevent DC-driving the speaker. I admit though that the audio output is often hardly intelligible.
Driver
Microcontroller (GPIO) pins have modest drive level but they are capable of driving small speakers.
Of course Class D amplifiers are used in applications where efficiency is a crucial factor. Instead, I suggest that you use a DAC (PWM is also a form of digital-to-analog conversion but I am referring to circuits which can produce multiple voltage levels corresponding to the code at the input) for your early experiments in processing audio signals using microcontrollers. In addition if you want higher level of amplification you need a driver/amplifier.
Regards,
Goodwin
Thanks very much. You're quite right, a proper engineer tries to think of a way to get round a problem especially for someone starting off with some circuit. It is much more interesting anyway than just being given something that does the job. And as you say the clocks are high enough now to do a proper job rather than things like Baa Baa Black Sheep, the Lone Ranger music and Jet Set Willy.
Anyway if you want to do the simplest possible input as well you might I guess be able to make a successive approximation ADC by using two GPIO pins and a few resistors to balance the output against your input and the voltage range to match the bottom of the input hysteresis range of one pin and the top of the other. No I've never tried anything like that and make no guarantees but you might find it fun trying ;-)
Hi
Yes you can do it ....
All you need to do is to think outside the Box....
Yes you can do it by using the ADC12 to sample the audio signal and outputting the sampled data using the timer as PWM signal generator to drive a Mosfet H bridge
By driving the 1/2 H bridge using a PWM signal you will create a class D power amplifier and depend on the Mosfet used,drive voltage and current you can produce many watt of power and by multiplying the sampled data by a factor you can provide digital volume control all done in software.
When setting the timer for producing the PWM signal remember to use a dual phase output with dead time in between pulse(phase) other wise the Mosfet will burn to the steak....
Use the STM32F4 timer1 as he capable to best do the work.
Yuval I
Arm Microcontroller expert
No I don't believe so. If you look at the manufacturers page you'll see it implements S/PDIF which is a digital interface for audio but it does not implement any analogue to digital or digital to analogue converters. And you really wouldn't want to drive a speaker directly from a microprocessor.
-Ulp, looking again I see it does implement ADC which would have been the main impediment. Sorry about that.