PWM to LOW Pass Filter, analog output

Hello,

I'm trying to supply 0-5V to a mosfet which controls a 100W LED. I have my power and my control function from arduino mega working.

Right now, I'm using PWM but my concern is when I dim the light I can see the dim and it is steppy.

I connected a potentiometer directly and tried to supply 0-5V to mosfet, it dims perfectly fine.

So, I have done my research and I added a Low pass filter to the PWM signal, but I still didn't get a good dim and its still steppy.

If anyone could help me build the right circuit so I can supply PWM and get analog output.

Using an arduino MEGA, Pin 5, changed frequency to 62.5KHz.

I have tried a number of resistors and capacitors, none of them worked.

I ordered a DAC from adafruit, which I think is my final option if I don't get a good output from filter.

When doing PWM, you [u]do not want[/u] to use a low pass filter on the gate of the MOSFET. It wastes power, and may burn up the MOSFET.

Are you using a logic level MOSFET?

For informed help, post the complete code (using code tags) and a circuit diagram.

Can’t have more than about 25 equal brightness steps with 8-bit PWM.
For smooth dimming, you need 12-bit PWM minimum.

Can’t use a high frequency for dimming either.
The mosfet switch frequency is “PWM frequency * bit depth”
62.5kHz*256= 16Mhz in your case.
Drop PWM to <1kHz (I use 12-bit/200Hz).

Don’t use a DAC/mosfet with a 100watt LED.
That would use the mosfet in it’s linear region.
It would generate a lot of heat in the mosfet (large heatsink needed).
Leo…

" Can't have more than about 25 equal brightness steps with 8-bit PWM. "

Why not, Leo?

Allan

The eye's response to brightness is not linear. You can clearly see the difference in LED brightness between PWM step 1 and 2, but you can't see any difference between PWM step 254 and 255. For LED dimming, with equal brightness steps, a lookup table is commonly used. About 20-32 steps for 8-bit PWM, and 256 steps for 12-bit PWM. Leo..

Google "Arduino 8-bit brightness CIE" for more info.

jremington - Yes, I'm using a LL Mosfet. Its basically sending a PWM signal to a MOSFET, which drives an LED.

Leo- Alright, as suggested Im dropping down the frequency to less than 1kHz, earlier when it was at its default freq, I could see the PWM oscillations on the LED, and had to bump up the frequency so I went all out max.

I'm going to try my experiment with MCP4725 right now, and will update this post on the results.

Do you suggest any other 12 Bit PWM alternatives? Also, what do you think of Digital pot AD5171?

Allan - As Leo said, at low level of PWM, the increment in power can be seen on the LED, but at higher level of PWM the increments isn't visible.

I just looked up Arduino 8-bit brightness CIE, I'm going to try this link, https://ledshield.wordpress.com/2012/11/13/led-brightness-to-your-eye-gamma-correction-no/ and see if it works.

What part of "No DACs" did you not understand? The same goes for the digipot on the gate. Linear regulation of a 100W LED is going to be a monster. In fact, how are you even regulating the power to it to begin with?

How is your MOSFET not already a smoldering pile of slag?

cpp333:
I could see the PWM oscillations on the LED, and had to bump up the frequency so I went all out max.

Got super-powers?
AFAIK no human being can see more than ~50Hz.
Film/theatre/movies “flickers” at 24Hz. Your monitor might be set for 60Hz.
Anything over 100Hz is too fast for us to see, except when something else is moving.
Then you see the strobing of that moving object.

You might be able to code a 16-bit PWM signal (<= ~244Hz) from the Arduino.
Never done this, so not sure how to.
Another solution could be a 16 channel/12-bit PWM PCA9685 breakout board (ebay, Adfafruit).

Tell us more about your “100watt LED”, the supply you intend to use, and what it is for.
There might be other solutions.
Leo…

Not really super powers but I have Iphone, and when I tried to take video of the light working, I could see the lines (like a pwm led output-on/off but very fast).

The supply is a 100W AC-DC power supply, the ones similar to the laptop charger kind. I'm not worried about the power as of now, or any voltage regulator or sort.

A friend had bought the required parts and never used it. I just borrowed it and wanted to work on it.

cpp333: The supply is a 100W AC-DC power supply, the ones similar to the laptop charger kind. I'm not worried about the power as of now, or any voltage regulator or sort.

Supply voltage and LED forward voltage is important, especially when you intend to use a simple mosfet (and a current limiting resistor). Parts can get big/hot quickly when you're working with a 100watt LED.

AFAIK 100watt COB LEDs commonly use 10 strings of 10 LEDs with a Vf of 33-36volt. Leo..

Forget about digital-analog converters and digital potentiometers.

MOS-FETs are like switches. Very few have a linear range.

That is why you use MOS-FETs instead of transistors.

Working in the linear range would need a special MOS-FET with a huge heatsink.

PWM seems to be the only solution.

Just think that the MOS-FET is a digital device: ON or OFF.

In this case a low-pass filter makes no sense at all.

The basic frequency of the Arduino PWM is 490Hz.

You should not be able to see any flickering. The human eye is limited to 26Hz.

Just adapt your code in such a way, that you have a minimum output of 20 ore 50 (try it). With low values you will see inconstancies when the light should be dimm.

You might also use some code in such a way, that your linear inputs are converted into nonlinear outputs.

If you have enough time and passion, you could define an arry turning input values into output values.

cpp333: Hello,

I'm trying to supply 0-5V to a mosfet which controls a 100W LED. I have my power and my control function from arduino mega working.

Right now, I'm using PWM but my concern is when I dim the light I can see the dim and it is steppy.

You need much more than 256 linear brightness steps to match the eye's response - configuring timer1 as a 16 bit timer is one way (on Uno), jittering your PWM between adjacent levels is another. To match the eye's response you want to step by roughly 0.5 to 1dB steps, 16 bit gives about 48dB, the standard 8 bit is only 24dB (and the first step is a 3dB step

I connected a potentiometer directly and tried to supply 0-5V to mosfet, it dims perfectly fine.

Except the MOSFET will overheat and risk being destroyed and you waste power doing this - use switch-mode for power control, not analog, if you want efficiency and cool running circuits.

So, I have done my research and I added a Low pass filter to the PWM signal, but I still didn't get a good dim and its still steppy.

Low pass filtering a PWM is trying to do the same as you potentiometer above, its inefficient and doesn't change the step size

If anyone could help me build the right circuit so I can supply PWM and get analog output.

Using an arduino MEGA, Pin 5, changed frequency to 62.5KHz.

On the Mega, pin 5 is controlled by timer3, setting that to 16 bit might be the easiest fix

I have tried a number of resistors and capacitors, none of them worked.

I ordered a DAC from adafruit, which I think is my final option if I don't get a good output from filter.

arduinoaleman: That is why you use MOS-FETs instead of transistors.

Say it with me: MOSFETs are transistors.

MOSFETS. ARE. TRANSISTORS!

What do you think the T stands for?

The eye's response to brightness is not linear. You can clearly see the difference in LED brightness between PWM step 1 and 2, but you can't see any difference between PWM step 254 and 255. For LED dimming, with equal brightness steps, a lookup table is commonly used. About 20-32 steps for 8-bit PWM, and 256 steps for 12-bit PWM. Leo..

Hmmm .. OK...

But years ago I worked on digital video, and we only digitised to 8 bits.

Seemed to work.

Allan

allanhurst: Hmmm .. OK... But years ago I worked on digital video, and we only digitised to 8 bits. Seemed to work.

I'm not very familiar with video Allan, but I suspect that the hardware, either directly or by use of some kind of "companding" (compression and expanding) algorithm, made the perceived brightness a much more linear function of those 8 bits.

Wawa isn't arguing that 256 linear steps in perceived brightness wont give reasonable fading. The problem is that, because of the nonlinear relation between LED current and perceived brightness, you just can't get anything even remotely like 256 equal steps (with 8 bits).

I've only played around with this a little bit, however I did once try to implement a linear fade on a LED and soon found that the PWM steps I needed to do this were decidedly non linear.

To quote:

I'm not very familiar with video Allan, but I suspect that the hardware, either directly or by use of some kind of "companding" (compression and expanding) algorithm, made the perceived brightness a much more linear function of those 8 bits.

..................

Nope - no companding - it was straight linear. And good enough for broadcast by the BBC.

Regards

Allan

allanhurst: Nope - no companding - it was straight linear. And good enough for broadcast by the BBC.

So they never made any use of gamma correction anywhere in the entire system from video capture at the camera to the final video display?

http://www.cambridgeincolour.com/tutorials/gamma-correction.htm

https://en.wikipedia.org/wiki/Gamma_correction

Of course there was a load of that - plus dsp-style processing all done with ecl -- but the input linear digitising limits the dynamic range.

42dB was reckoned OK for broadcast.

Allan

Video bits can get real misleading real fast. 8 bit video can mean 8 bits for each of R, G, and B which is 24 bits total. Or, the video stream can be 8 bits but adding a palette DAC (look up table) can increase the screen resolution to 24 bits or greater. The palette DAC trick was used in the early pc color graphics. I once designed one.

The stuff I worked on used composite PAL as an input.

It was a long time ago....

Allan