PWM frequency - Page 1
Forum section: electronics / beginners

author: Medo
author_rank: Regular Contributor
timestamp: July 16, 2010, 07:16:20 pm
content: I control character LED backlight LED via PWM. I looks something like this:Code:12V --------------------------------------- LED+|E 1000uF||---- R 10Ohm ---------- LED-|PWM (14kHz) ---- MOSFET||GNDTechnically 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) becauseof interference with other parts of board or is higher PWM is better in order to get smoother output?

author: TheWelly888
author_rank: Frequent Contributor
timestamp: July 16, 2010, 08:28:29 pm
content: 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.

author: Medo
author_rank: Regular Contributor
timestamp: July 16, 2010, 08:41:00 pm
content: Quote from: TheWelly888 on July 16, 2010, 08:28:29 pmCapacitor 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.

author: Zero999
author_rank: Super Contributor
timestamp: July 17, 2010, 08:46:08 am
content: 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.

author: Time
author_rank: Frequent Contributor
timestamp: July 17, 2010, 03:28:51 pm
content: Quote from: Hero999 on July 17, 2010, 08:46:08 amBy pulsing the LED wouldnt you have slightly better power efficiency?

author: Zero999
author_rank: Super Contributor
timestamp: July 17, 2010, 03:41:15 pm
content: No, why would it?It's likely to be less efficient.

author: Medo
author_rank: Regular Contributor
timestamp: July 17, 2010, 04:58:52 pm
content: Quote from: Hero999 on July 17, 2010, 08:46:08 amLet 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.

author: Time
author_rank: Frequent Contributor
timestamp: July 17, 2010, 05:57:11 pm
content: Quote from: Hero999 on July 17, 2010, 03:41:15 pmAssuming 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.

author: Unknown
author_rank: Unknown
timestamp: July 17, 2010, 06:07:20 pm
content: 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.

author: Zero999
author_rank: Super Contributor
timestamp: July 17, 2010, 09:23:11 pm
content: Quote from: Time on July 17, 2010, 05:57:11 pmStill, how would that be more efficient?The duty cycle will only be 50% so it will be half as bright, meaning you gain nothing.Quote from: Medo on July 17, 2010, 04:58:52 pmWhy 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.QuoteThen 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.

author: Simon
author_rank: Unknown
timestamp: July 17, 2010, 10:02:28 pm
content: 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

author: Medo
author_rank: Regular Contributor
timestamp: July 18, 2010, 05:02:24 am
content: Quote from: Hero999I 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: Hero999Problem 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: Hero999555 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: Hero999No. 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: Hero999That definitely seems way I was intending things to go. I will attempt to find that datasheeet.

author: Medo
author_rank: Regular Contributor
timestamp: July 18, 2010, 05:07:59 am
content: Quote from: Simon on July 17, 2010, 10:02:28 pmI calculated it's size according to article athttp://dev.emcelettronica.com/how-to-use-pwm-to-generate-analog-or-analogue-voltage-digital-circuits-part-2As 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.Quote from: Simon on July 17, 2010, 10:02:28 pmResistor is 10 ohm.I wanted to lower voltage to 7V and this 10 ohm would be perfect value.

author: Zero999
author_rank: Super Contributor
timestamp: July 19, 2010, 08:40:21 am
content: 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.

author: Unknown
author_rank: Unknown
timestamp: July 19, 2010, 09:37:32 am
content: 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.

author: Zero999
author_rank: Super Contributor
timestamp: July 19, 2010, 01:00:36 pm
content: 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.

author: Medo
author_rank: Regular Contributor
timestamp: July 22, 2010, 08:36:41 pm
content: 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 filterP.S. Positive LED is at 12V (not shown here)