Amplifying a PWM signal

View: New views
17 Messages — Rating Filter:   Alert me  

Amplifying a PWM signal

by Dumitru Stama-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys,
i have a question. My PIC18F2520 is set up to output a PWM signal. I
want to amplify the signal's current and feed it into a speaker.
Right now using only a single PN2222A i can hear the sound but the
volume is quite low.
I tried a LM386 and the output is what i really want but only if i
select the 200x gain schematics.
I don't know what should i try now, i really want to use only simple
components and not a dedicated amplifyer like LM386.

Thank you very much in advance
Dumitru Stama


--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

schematic.JPG (28K) Download Attachment

Re: Amplifying a PWM signal

by Jinx-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> want to amplify the signal's current and feed it into a speaker.

Dumitru, what is the speaker impedance and have you tried the
transistor on the low side (and without the 1k) ?


--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Thomas C Sefranek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

  ----- Original Message -----
  From: Dumitru Stama
  To: Microcontroller discussion list - Public.
  Sent: Wednesday, November 04, 2009 5:59 PM
  Subject: [EE] Amplifying a PWM signal


  Hi guys,
  i have a question. My PIC18F2520 is set up to output a PWM signal. I
  want to amplify the signal's current and feed it into a speaker.
  Right now using only a single PN2222A i can hear the sound but the
  volume is quite low.
  I tried a LM386 and the output is what i really want but only if i
  select the 200x gain schematics.
  I don't know what should i try now, i really want to use only simple
  components and not a dedicated amplifyer like LM386.

  Thank you very much in advance
  Dumitru Stama



------------------------------------------------------------------------------


  --
  http://www.piclist.com PIC/SX FAQ & list archive
  View/change your membership options at
  http://mailman.mit.edu/mailman/listinfo/piclist

What PWM frequency?
Where is your integrator?


  *
  |  __O    Thomas C. Sefranek  tcs@...
  |_-\<,_   Amateur Radio Operator: WA1RHP
  (*)/ (*)  Bicycle mobile on 145.41, 448.625 MHz

ARRL Instructor, Technical Specialist, VE Contact.
http://hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Jo Scherpenisse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


----- Original Message -----
From: "Jinx" <joecolquitt@...>
To: "Microcontroller discussion list - Public." <piclist@...>
Sent: Thursday, November 05, 2009 1:36 AM
Subject: Re: [EE] Amplifying a PWM signal


>> want to amplify the signal's current and feed it into a speaker.
>
> Dumitru, what is the speaker impedance and have you tried the
> transistor on the low side (and without the 1k) ?

It should work, but then you get a big DC-component through the speaker.
This heats the speaker and also diminish the max power from the speaker.
Jo
>




--------------------------------------------------------------------------------



Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 8.5.424 / Virusdatabase: 270.14.48/2479 - datum van uitgifte:
11/03/09 19:38:00

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Dumitru Stama-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The speaker impedance is 8 ohms, 0.5W. It's a small speaker.
What do you mean by the transistor on the low side ?

On Thu, Nov 5, 2009 at 2:36 AM, Jinx <joecolquitt@...> wrote:

>> want to amplify the signal's current and feed it into a speaker.
>
> Dumitru, what is the speaker impedance and have you tried the
> transistor on the low side (and without the 1k) ?
>
>
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

RE: Amplifying a PWM signal

by Michael Rigby-Jones-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



> -----Original Message-----
> From: piclist-bounces@... [mailto:piclist-bounces@...] On
Behalf

> Of Dumitru Stama
> Sent: 04 November 2009 22:59
> To: Microcontroller discussion list - Public.
> Subject: [EE] Amplifying a PWM signal
>
> Hi guys,
> i have a question. My PIC18F2520 is set up to output a PWM signal. I
> want to amplify the signal's current and feed it into a speaker.
> Right now using only a single PN2222A i can hear the sound but the
> volume is quite low.
> I tried a LM386 and the output is what i really want but only if i
> select the 200x gain schematics.
> I don't know what should i try now, i really want to use only simple
> components and not a dedicated amplifyer like LM386.

Something doesn't add up here, what supply is your PIC and LM386 running
from? Do you have a filter or attenuator between the PIC and the
amplifier? (you very probably want a low pass filter).

If the output of the PIC is connected directly to the LM386 then you
should be driving the LM386 hard into clipping with a gain of 200 (in
fact you should be driving it hard into clipping with a gain of 20).

A simple class B (push-pull) output stage with capacitive coupling to
the speaker should do what you want, but it won't deliver any more power
than the LM386, since you are ultimately limited by speaker impedance
and supply voltage.
http://www.ecircuitcenter.com/Circuits/pushpull/pushpull.htm

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Herbert Graf-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 2009-11-05 at 00:59 +0200, Dumitru Stama wrote:
> Hi guys,
> i have a question. My PIC18F2520 is set up to output a PWM signal. I
> want to amplify the signal's current and feed it into a speaker.
> Right now using only a single PN2222A i can hear the sound but the
> volume is quite low.
> I tried a LM386 and the output is what i really want but only if i
> select the 200x gain schematics.
> I don't know what should i try now, i really want to use only simple
> components and not a dedicated amplifyer like LM386.

What is the impedance of your speaker? What's the frequency of your PWM?
What's the purpose of R1?

TTYL

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Dumitru Stama-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys,
Thank you very much for trying to help me.
The PWM frequency is about 150kHz, my sound is sampled at 22050Hz using 8 bits.
I tried using a low pass RC filter but then the sound level is even
lower. I read somewhere on the web that if i feed the pwm signal
directly to the speaker it would be ok since the speaker cannot react
at 156kHz anyway. It works, i can say i don't have any noise except
the one generated by the fact i am using 8 bits per sample.
I thought about limiting the current from the base with R1.
The impedance of my speaker is 8 ohms, max. power is 0.8W. I can take
a few pictures with my circuit if they might help.
My power source is a bench source delivering 5V / 1.5A, i am not using
any LM7805 or other regulator. Both the PIC18F and LM386 are powered
from 5V.


On Thu, Nov 5, 2009 at 6:28 PM, Herbert Graf <hkgraf@...> wrote:

> On Thu, 2009-11-05 at 00:59 +0200, Dumitru Stama wrote:
>> Hi guys,
>> i have a question. My PIC18F2520 is set up to output a PWM signal. I
>> want to amplify the signal's current and feed it into a speaker.
>> Right now using only a single PN2222A i can hear the sound but the
>> volume is quite low.
>> I tried a LM386 and the output is what i really want but only if i
>> select the 200x gain schematics.
>> I don't know what should i try now, i really want to use only simple
>> components and not a dedicated amplifyer like LM386.
>
> What is the impedance of your speaker? What's the frequency of your PWM?
> What's the purpose of R1?
>
> TTYL
>
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Isaac Marino Bavaresco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dumitru Stama escreveu:

> Hi guys,
> Thank you very much for trying to help me.
> The PWM frequency is about 150kHz, my sound is sampled at 22050Hz using 8 bits.
> I tried using a low pass RC filter but then the sound level is even
> lower. I read somewhere on the web that if i feed the pwm signal
> directly to the speaker it would be ok since the speaker cannot react
> at 156kHz anyway. It works, i can say i don't have any noise except
> the one generated by the fact i am using 8 bits per sample.
> I thought about limiting the current from the base with R1.
> The impedance of my speaker is 8 ohms, max. power is 0.8W. I can take
> a few pictures with my circuit if they might help.
> My power source is a bench source delivering 5V / 1.5A, i am not using
> any LM7805 or other regulator. Both the PIC18F and LM386 are powered
> from 5V.
>  

I use this method in my products and it works OK, but you must low-pass
filter the PWM signal before sending it to the amplifier (a passive two
poles RC filter is OK).

The LM386 is OK, I use it myself, but your circuit with one transistor
is not going to work well.
You need an amplifier that can force current in both directions into the
speaker, something with high- and low-side active components, plus some
means to block DC through the speaker (a capacitor or a well balanced
BTL amplifier - the BTL amp. is better for low voltage applications).

A very important fact I learned: The processor's digital noise in the
audible range passes easily through the LP filter and gets amplified. I
solved this by passing the digital PWM (before LP filter) signal through
a logic gate (buffer or inverter) powered by its own well filtered and
regulated power circuit.

If you do things correctly, it is not needed to pump the gain up to
200x, the default 20x is enough.

Best regards,

Isaac

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/ 
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Jo Scherpenisse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A speaker with impedance of 8 Ohms means a DC resistance of about 4  Ohms.
Driving this speaker directly with the drain of a FET to 5 Volt means a
sigificant DCpower in the speaker. I would suggest to use a resistor in
series, for the max power in the speaker is 0,8 W.
That means you must limit the DC power (PWM on 50%) to about 0.2 - 0.3 Watt.

----- Original Message -----
From: "Dumitru Stama" <spanac@...>
To: "Microcontroller discussion list - Public." <piclist@...>
Sent: Thursday, November 05, 2009 6:53 PM
Subject: Re: [EE] Amplifying a PWM signal


> Hi guys,
> Thank you very much for trying to help me.
> The PWM frequency is about 150kHz, my sound is sampled at 22050Hz using 8
> bits.
> I tried using a low pass RC filter but then the sound level is even
> lower. I read somewhere on the web that if i feed the pwm signal
> directly to the speaker it would be ok since the speaker cannot react
> at 156kHz anyway. It works, i can say i don't have any noise except
> the one generated by the fact i am using 8 bits per sample.
> I thought about limiting the current from the base with R1.
> The impedance of my speaker is 8 ohms, max. power is 0.8W. I can take
> a few pictures with my circuit if they might help.
> My power source is a bench source delivering 5V / 1.5A, i am not using
> any LM7805 or other regulator. Both the PIC18F and LM386 are powered
> from 5V.
>
>
> On Thu, Nov 5, 2009 at 6:28 PM, Herbert Graf <hkgraf@...> wrote:
>> On Thu, 2009-11-05 at 00:59 +0200, Dumitru Stama wrote:
>>> Hi guys,
>>> i have a question. My PIC18F2520 is set up to output a PWM signal. I
>>> want to amplify the signal's current and feed it into a speaker.
>>> Right now using only a single PN2222A i can hear the sound but the
>>> volume is quite low.
>>> I tried a LM386 and the output is what i really want but only if i
>>> select the 200x gain schematics.
>>> I don't know what should i try now, i really want to use only simple
>>> components and not a dedicated amplifyer like LM386.
>>
>> What is the impedance of your speaker? What's the frequency of your PWM?
>> What's the purpose of R1?
>>
>> TTYL
>>
>> --
>> http://www.piclist.com PIC/SX FAQ & list archive
>> View/change your membership options at
>> http://mailman.mit.edu/mailman/listinfo/piclist
>>
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist


--------------------------------------------------------------------------------



Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 9.0.698 / Virusdatabase: 270.14.51/2482 - datum van uitgifte:
11/05/09 08:37:00

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Herbert Graf-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 2009-11-05 at 22:42 +0100, Jo Scherpenisse wrote:
> A speaker with impedance of 8 Ohms means a DC resistance of about 4  Ohms.
> Driving this speaker directly with the drain of a FET to 5 Volt means a
> sigificant DCpower in the speaker. I would suggest to use a resistor in
> series, for the max power in the speaker is 0,8 W.
> That means you must limit the DC power (PWM on 50%) to about 0.2 - 0.3 Watt.

Frankly that seems a little wasteful to me. I'd much rather put a cap in
series, that eliminates the DC component but keeps the full swing on the
speaker.

TTYL

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Jinx-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> What do you mean by the transistor on the low side ?

In this configuration

http://www.tpub.com/neets/book7/25c.htm

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Dumitru Stama-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I use this method in my products and it works OK, but you must low-pass
> filter the PWM signal before sending it to the amplifier (a passive two
> poles RC filter is OK).
>
> The LM386 is OK, I use it myself, but your circuit with one transistor
> is not going to work well.
> You need an amplifier that can force current in both directions into the
> speaker, something with high- and low-side active components, plus some
> means to block DC through the speaker (a capacitor or a well balanced
> BTL amplifier - the BTL amp. is better for low voltage applications).
>
> A very important fact I learned: The processor's digital noise in the
> audible range passes easily through the LP filter and gets amplified. I
> solved this by passing the digital PWM (before LP filter) signal through
> a logic gate (buffer or inverter) powered by its own well filtered and
> regulated power circuit.
>
> If you do things correctly, it is not needed to pump the gain up to
> 200x, the default 20x is enough.
>
> Best regards,
>
> Isaac

Thank you all for helping me
I think the push-pull schematic which was suggested earlier is doing
just that : forcing current in both directions into the speaker. I
will try to implement all of the solutions and figure out which one
works best.
One question abot the fet : is it a much better choice than the
bipolar transistor for this kind of job ?
Jinx : in that transistor configuration i don't think i get current
amplification. I might be mistaken though.
In this weekend i will try to implement what i learned so far. I will
try to make a youtube video with my findings.
Thank you again for all your help, guys

Dumitru
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Jinx-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Jinx : in that transistor configuration i don't think i get current
> amplification. I might be mistaken though.

Hi, I didn't mean that specific example, just where the transistor
would be as a low-side device. If I understand what you're trying
to do, the transistor is acting basically as a switch, being driven
hard off and on by the PWM. You'll be able to control the tone
(and volume) to some extent with the duty cycle, varying from
'thin' to 'thick'. An RC filter will help remove the harmonics from
the square wave and soften the sound somewhat. A technique
used to smooth DAC-generated or bit-stream waves

eg

http://www.romanblack.com/picsound.htm

http://www.edn.com/article/CA240913.html

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Vasile Surducan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Dumitru,
The schematic posted is an emiter repeater. It does not amplify the
voltage, only the current flow through your low impedance speaker. If
the PWM is properly filtered, you have the chance of hearing almost
nothing, but this is logic.

Vasile

On 11/4/09, Dumitru Stama <spanac@...> wrote:

> Hi guys,
> i have a question. My PIC18F2520 is set up to output a PWM signal. I
> want to amplify the signal's current and feed it into a speaker.
> Right now using only a single PN2222A i can hear the sound but the
> volume is quite low.
> I tried a LM386 and the output is what i really want but only if i
> select the 200x gain schematics.
> I don't know what should i try now, i really want to use only simple
> components and not a dedicated amplifyer like LM386.
>
> Thank you very much in advance
> Dumitru Stama
>
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
>
>
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Dumitru Stama-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I have enough voltage in my PWM signal (~4.5V) but not enough current
to drive that small speaker. I can hear the sound but is weak. I will
try with that push-pull suggested in the previous posts to see if the
results are better.
Thank you for your reply

Dumitru


On Sun, Nov 8, 2009 at 7:28 PM, Vasile Surducan <piclist9@...> wrote:

> Hi Dumitru,
> The schematic posted is an emiter repeater. It does not amplify the
> voltage, only the current flow through your low impedance speaker. If
> the PWM is properly filtered, you have the chance of hearing almost
> nothing, but this is logic.
>
> Vasile
>
> On 11/4/09, Dumitru Stama <spanac@...> wrote:
>> Hi guys,
>> i have a question. My PIC18F2520 is set up to output a PWM signal. I
>> want to amplify the signal's current and feed it into a speaker.
>> Right now using only a single PN2222A i can hear the sound but the
>> volume is quite low.
>> I tried a LM386 and the output is what i really want but only if i
>> select the 200x gain schematics.
>> I don't know what should i try now, i really want to use only simple
>> components and not a dedicated amplifyer like LM386.
>>
>> Thank you very much in advance
>> Dumitru Stama
>>
>> --
>> http://www.piclist.com PIC/SX FAQ & list archive
>> View/change your membership options at
>> http://mailman.mit.edu/mailman/listinfo/piclist
>>
>>
>>
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Re: Amplifying a PWM signal

by Vasile Surducan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe you will like this amplifier better than an ordinary push-pull
(like I did):
http://www.edn.com/contents/images/6702271.pdf
page 45-46

Vasile

On 11/8/09, Dumitru Stama <spanac@...> wrote:

> Hi,
> I have enough voltage in my PWM signal (~4.5V) but not enough current
> to drive that small speaker. I can hear the sound but is weak. I will
> try with that push-pull suggested in the previous posts to see if the
> results are better.
> Thank you for your reply
>
> Dumitru
>
>
> On Sun, Nov 8, 2009 at 7:28 PM, Vasile Surducan <piclist9@...> wrote:
> > Hi Dumitru,
> > The schematic posted is an emiter repeater. It does not amplify the
> > voltage, only the current flow through your low impedance speaker. If
> > the PWM is properly filtered, you have the chance of hearing almost
> > nothing, but this is logic.
> >
> > Vasile
> >
> > On 11/4/09, Dumitru Stama <spanac@...> wrote:
> >> Hi guys,
> >> i have a question. My PIC18F2520 is set up to output a PWM signal. I
> >> want to amplify the signal's current and feed it into a speaker.
> >> Right now using only a single PN2222A i can hear the sound but the
> >> volume is quite low.
> >> I tried a LM386 and the output is what i really want but only if i
> >> select the 200x gain schematics.
> >> I don't know what should i try now, i really want to use only simple
> >> components and not a dedicated amplifyer like LM386.
> >>
> >> Thank you very much in advance
> >> Dumitru Stama
> >>
> >> --
> >> http://www.piclist.com PIC/SX FAQ & list archive
> >> View/change your membership options at
> >> http://mailman.mit.edu/mailman/listinfo/piclist
> >>
> >>
> >>
> > --
> > http://www.piclist.com PIC/SX FAQ & list archive
> > View/change your membership options at
> > http://mailman.mit.edu/mailman/listinfo/piclist
> >
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist