Author Topic: PWM frequency  (Read 10189 times)

0 Members and 1 Guest are viewing this topic.

Offline MedoTopic starter

  • Regular Contributor
  • *
  • Posts: 69
PWM frequency
« on: July 16, 2010, 07:16:20 pm »
I control character LED backlight LED via PWM. I looks something like this:

Code: [Select]
12V --------------------------------------- LED+
                                       |
                                   E 1000uF
                                       |
                   |---- R 10Ohm ---------- LED-
                   |
PWM (14kHz) ---- MOSFET
                   |
                   |
                  GND

Technically everything does work in test environment and I am preparing to have it transfered to PCB.

However, I am wondering about PWM frequency. Would it be wiser to use lower frequency (140Hz) because
of interference with other parts of board or is higher PWM is better in order to get smoother output?
 

Offline TheWelly888

  • Frequent Contributor
  • **
  • Posts: 344
  • Country: gb
Re: PWM frequency
« Reply #1 on: July 16, 2010, 08:28:29 pm »
Get rid of the 1000u capacitor, it doesn't appear to have any useful purpose!  :-\

The human eye cannot see anything showing for less than 10ms so an LED flashing at 140Hz appears steady so 14kHz is unnecessarily fast and will leave your PIC less time to do other things.

You can do anything with the right attitude and a hammer.
 

Offline MedoTopic starter

  • Regular Contributor
  • *
  • Posts: 69
Re: PWM frequency
« Reply #2 on: July 16, 2010, 08:41:00 pm »
Get rid of the 1000u capacitor, it doesn't appear to have any useful purpose!  :-\

The human eye cannot see anything showing for less than 10ms so an LED flashing at 140Hz appears steady so 14kHz is unnecessarily fast and will leave your PIC less time to do other things.
Capacitor was my attempt at sort-of RC filter (http://dev.emcelettronica.com/how-to-use-pwm-to-generate-analog-or-analogue-voltage-digital-circuits-part-2). Since I do not have oscilloscope, I didn't know whether if would work or not (since it does differ from original schematics).

I am aware that 100Hz is good enough but PWM is controlled separately via 555 so there is no pin lost. :)
Higher frequency was my attempt at being gentle to LED. :)
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19933
  • Country: gb
  • 0999
Re: PWM frequency
« Reply #3 on: July 17, 2010, 08:46:08 am »
The human eye acts like a low pass filter, there's no need to add a capacitor.

PWM can be done with the MCU.

A 555 is capable of driving up to 200mA loads so no MOSFET is required, if a 555 is used.

Do you need to alter the brightness?

You do know that if there's no need for dimming, there's no need for PWM, unless you add an inductor and make a basic SMPS.
 

Offline Time

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: us
Re: PWM frequency
« Reply #4 on: July 17, 2010, 03:28:51 pm »
You do know that if there's no need for dimming, there's no need for PWM, unless you add an inductor and make a basic SMPS.

By pulsing the LED wouldnt you have slightly better power efficiency?
« Last Edit: July 17, 2010, 05:51:48 pm by Time »
-Time
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19933
  • Country: gb
  • 0999
Re: PWM frequency
« Reply #5 on: July 17, 2010, 03:41:15 pm »
No, why would it?

It's likely to be less efficient.
 

Offline MedoTopic starter

  • Regular Contributor
  • *
  • Posts: 69
Re: PWM frequency
« Reply #6 on: July 17, 2010, 04:58:52 pm »
The human eye acts like a low pass filter, there's no need to add a capacitor.
PWM can be done with the MCU.
A 555 is capable of driving up to 200mA loads so no MOSFET is required, if a 555 is used.
You do know that if there's no need for dimming, there's no need for PWM, unless you add an inductor and make a basic SMPS.

Let me explain my idea. I have need to control Character LCD (40x4) and it's backlight needs 300mA @ 4.2V. Because of this I decided that I need something that can handle more power than MCU can. I also wanted to make one board for another project which just requires small 16x2 display.

I do need to setup brightness of LCD to certain level that depends on surroundings but once it is set, it will stay like that for eternity. I decided to use 12V rail for backlight and to adjust it's voltage by mean of PWM which I created with 555 because it was available in my toolbox and because it can work on 12V.

Since I do need to adjust brightness (although rarely) simple resistor is not really good for me - I wanted something that will use trimmer (not displayed in schematics). I was worried about stress that overdriving LED (cca 900mA when on (10 ohm resistor) and then some time off). That is why I am attempting this low-pass filter. My idea is to give 7V to this display (PWMed from 12V) and that voltage would suit fixed 10 ohm resistor just fine.

Of course, since I never did this before and unfortunately I have no oscilloscope I want to check whether my logic is sane or just crazy talk. I do not want to over do it (MCU control or unnecessary parts) but I do want to make something that will not burn LED after one month.
 

Offline Time

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: us
Re: PWM frequency
« Reply #7 on: July 17, 2010, 05:57:11 pm »
No, why would it?

It's likely to be less efficient.

Assuming the LED was enough, if you pulsed the LED with a 50% duty cycle you only have current flowing half the time.  The peak power would be the same as DC but the overall average power would be lower.
-Time
 

alm

  • Guest
Re: PWM frequency
« Reply #8 on: July 17, 2010, 06:07:20 pm »
But that's if you want to run the LED at less than full power (dim it), if you want to run it at full power, you might as well run it at a constant current, no point in stressing the led with twice the nominal current half of the time.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19933
  • Country: gb
  • 0999
Re: PWM frequency
« Reply #9 on: July 17, 2010, 09:23:11 pm »
Assuming the LED was enough, if you pulsed the LED with a 50% duty cycle you only have current flowing half the time.  The peak power would be the same as DC but the overall average power would be lower.
Still, how would that be more efficient?

The duty cycle will only be 50% so it will be half as bright, meaning you gain nothing.

Let me explain my idea. I have need to control Character LCD (40x4) and it's backlight needs 300mA @ 4.2V. Because of this I decided that I need something that can handle more power than MCU can. I also wanted to make one board for another project which just requires small 16x2 display.

I do need to setup brightness of LCD to certain level that depends on surroundings but once it is set, it will stay like that for eternity. I decided to use 12V rail for backlight and to adjust it's voltage by mean of PWM which I created with 555 because it was available in my toolbox and because it can work on 12V.
Why not use a 5V rail for the backlight and save 58.2% of the power required from 12V?

Increasing the voltage just increases the losses, the power in the series resistor is just wasted as heat.

If you can get a 5V SMPs mains adaptor it would be ideal.

Quote
Since I do need to adjust brightness (although rarely) simple resistor is not really good for me - I wanted something that will use trimmer (not displayed in schematics). I was worried about stress that overdriving LED (cca 900mA when on (10 ohm resistor) and then some time off). That is why I am attempting this low-pass filter. My idea is to give 7V to this display (PWMed from 12V) and that voltage would suit fixed 10 ohm resistor just fine.
Then don't overdrive the LED, use a resistor that will give 300mA at the maximum possible supply voltage and check the datasheet to ensure that 300mA is the recommend operating current, not the absolute maximum rating.

PWM is good though because it means you won't need a high powered variable resistor in series with the LED which will cost more than a cheap power resistor and a MOSFET. Why not drop the 555 and do PWM with the MCU? You could then use buttons or a pot with the ADC?

If you really must use 12V and efficiency is important. . .

Do you have a free comparator available on the MCU?

You could use it to build a very simple SMPs with just an inductor, a MOSFET, a few resistors, a capacitor, a diode and an inductor - there's a MicroChip app. note about this somewhere I could find if you're interested.

« Last Edit: July 17, 2010, 10:46:46 pm by Hero999 »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18031
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM frequency
« Reply #10 on: July 17, 2010, 10:02:28 pm »
you don't want the  100uF cap because it will just charge up while the mosfet is on and then keep the led alight when it is off, where is the led resistor ? without it you will likely blow the led
 

Offline MedoTopic starter

  • Regular Contributor
  • *
  • Posts: 69
Re: PWM frequency
« Reply #11 on: July 18, 2010, 05:02:24 am »
Quote from: Hero999
Why not use a 5V rail for the backlight and save 58.2% of the power required from 12V?
Increasing the voltage just increases the losses, the power in the series resistor is just wasted as heat.
If you can get a 5V SMPs mains adaptor it would be ideal.
I have 12V input only. 5V line is available for MCU and LCD via 7805. I didn't want backlight on that line because I noticed some backlights that need more than 5V to start with. I am building this project for specific LCD but I would like to re-use it for any future needs.

Quote from: Hero999
Then don't overdrive the LED, use a resistor that will give 300mA at the maximum possible supply voltage and check the datasheet to ensure that 300mA is the recommend operating current, not the absolute maximum rating.
Problem is that in this case I am overdriving LED backlight from smaller display (16x2). I need something that can work with both of them.

Quote from: Hero999
Why not drop the 555 and do PWM with the MCU? You could then use buttons or a pot with the ADC?
555 was available and I did manage to use pot with it. Board layout was mainly done and that unused pin was burried so I didn't want to test my luck with rerouting whole thing. :)

Quote from: Hero999
Do you have a free comparator available on the MCU?
No. I have single MCU pin available. :(
Not only that but board is quite full (limited size) so bigger MCU would probably complicate things more than it is worth.

Quote from: Hero999
You could use it to build a very simple SMPs with just an inductor, a MOSFET, a few resistors, a capacitor, a diode and an inductor - there's a MicroChip app. note about this somewhere I could find if you're interested.
That definitely seems way I was intending things to go. I will attempt to find that datasheeet.

 

Offline MedoTopic starter

  • Regular Contributor
  • *
  • Posts: 69
Re: PWM frequency
« Reply #12 on: July 18, 2010, 05:07:59 am »
you don't want the  100uF cap because it will just charge up while the mosfet is on and then keep the led alight when it is off, where is the led resistor ? without it you will likely blow the led
I calculated it's size according to article at
http://dev.emcelettronica.com/how-to-use-pwm-to-generate-analog-or-analogue-voltage-digital-circuits-part-2
As always with me, I am not sure whether there is any logic behind that article. When I do check with DMM (cheap one), it does seem valid but I have no oscilloscope to verify it's operation for my purpose.


where is the led resistor ? without it you will likely blow the led
Resistor is 10 ohm.
I wanted to lower voltage to 7V and this 10 ohm would be perfect value.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19933
  • Country: gb
  • 0999
Re: PWM frequency
« Reply #13 on: July 19, 2010, 08:40:21 am »
You're looking at it the wrong way. To drive LEDs, you need to limit the current, not the voltage, the LEDs will determine the voltage.

The low pass filter is to get a steady voltage from a PWM signal and is not suitable for powering LEDs. You need a constant current to be PWMed so use the correct resistor value and do away with the capacitor as everyone's being telling you all along.

Now you say you want to drive different displays with it. What's the maximum/minimum voltage and current required by the different displays?

It's possible to overdrive an LED display adjust the PWM so it doesn't overheat, so you could use one resistor for several different displays and vary the PWM accordingly but adjusting it with a variable resistor is a haphazard way of doing it: it's easy to get the wrong setting, causing the LEDs to burn out. Doing it in software is a better method because you can accurately control the duty cycle and there doesn't need to be any hardware modifications when the display is changed and it's possible to do PWM with one MCU. Another method is to use a 555 oscillator or similar and control the duty cycle with fixed resistors.
 

alm

  • Guest
Re: PWM frequency
« Reply #14 on: July 19, 2010, 09:37:32 am »
If you do it in software, make sure to keep in mind what happens if the uC is reset or gets stuck somewhere. It wouldn't be very nice if the LED is destroyed when you re-program the uC or something goes wrong.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19933
  • Country: gb
  • 0999
Re: PWM frequency
« Reply #15 on: July 19, 2010, 01:00:36 pm »
Good point. I suppose you then need some protection to prevent the from remaining on if the output from the MCU stays high continuously, which would probably need monostable such as a 555 anyway, there again you still have the advantage of being able to change it without tweaking pots or hardware.
« Last Edit: July 19, 2010, 04:32:15 pm by Hero999 »
 

Offline MedoTopic starter

  • Regular Contributor
  • *
  • Posts: 69
Re: PWM frequency
« Reply #16 on: July 22, 2010, 08:36:41 pm »
Hi,

I finally got to use oscilloscope and results with RC filter are quite satisfying.

Thanks to everybody for advice.


In attach I added picture of signal:
   o  yellow is "analog" output signal (cca 8V)
   o  blue is same output but before RC filter

P.S. Positive LED is at 12V (not shown here)
« Last Edit: July 22, 2010, 08:38:38 pm by Medo »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf