Flickering LED strip

I'm using a simple circuit with a PWM controlled MOSFET switching a 12v LED strip, but the laptop power supply I'm using doesn't seem to like it much, causing what looks to be around a 40hz flicker in the LEDs at certain values. At very low brightness it's fine, same with anything over about 50%, but in between it's a steady flicker.

Is this just a case of a crappy power supply, or could I fix the problem with an addition of capacitors or something else to my circuit?

Hi, what MOSFET? Does it have a logic-level gate?

Paul

Yes it's logic level, an IRL540.

I should add that it's a 20 watt load, the power supply is rated for 60w.

Hi,

Can you please post a copy of your sketch, using code tags? Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf? Do you have the gnd of the power supply and the arduino connected?

Tom..... :)

Sketch is pretty basic...

int incomingByte = 0;

void setup() {
        Serial.begin(9600);  
}

void loop() {

        if (Serial.available() > 0) {
                incomingByte = Serial.read();

                analogWrite(3, incomingByte);
        }
}

Circuit is basically a copy of this one, with an additional small resistor between the gate and arduino, and a Bluetooth module. Both grounds are connected.

I tried it powered with an ATX PSU and it doesn't flicker, so I'm thinking the laptop power supply just can't handle it. Still, it would be nice to overcome that deficiency if possible.

with an additional small resistor between the gate and arduino

Why did you do that? The example you linked does not do that. Have you tried taking it out?

I've seen it suggested a few times to protect the arduino pins. Example

I've currently using a 200 ohm, perhaps a lower value might help.

That code is bad. Just fix a value of the analog write in the setup, do not have any code in the loop, then you should see it work fine.

If you want to change the brightness through the serial input you will have to write proper code to do that. Remember the serial input is ASCII data.

Hmm okay, I'll give that a try. How come it doesn't flicker using an ATX PSU?

Update: I tried it with a single analogWrite line in the setup and nothing in the loop, but it still flickers. If i put the laptop psu right up to my ear I can hear it clicking at the same frequency.

Values above 100 for the analogWrite seem to be always stable, and below 50 always flicker, but around 60 I can affect the flickering by rotating the 2.1mm power jack.

Hi,

Hmm okay, I'll give that a try. How come it doesn't flicker using an ATX PSU?

I would say your power supply is able to supply the current needed, or you need more bypassing of the supply.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf? I mean as you have wired it and a photo of how you have wired it, are your wire guages heavy enough for the LED current.

Tom....... :)

Can't guarantee I've got it all correct...

Not sure how useful a photo of the circuit itself would be, I've got it soldered on a bit of perfboard.

I'm assuming the wire gauge is heavy enough as it works at full brightness, but I'm not sure what gauge it is exactly.

Hi, a photo will show us how you have connected everything, so you don'y have earth loops or putting current stress on parts of the assembly that could cause volt drops.

Tom.... :)

My phone's camera isn't very good, so I'm not sure how much you'll be able to make out from this mess.

Can you post a link to that DC to DC converter? It was not in the schematic you posted. How is it being powered? Have you got any capacitors on the inputs and outputs? If not then you need some.

It's one of these ubiquitous things.

I didn't put it on the schematic because the flickering was happening before I added it to the circuit.

I think you better update that schematic to show the whole of the power supply chain. While that module says it is good for 3A you also have a 30mA ripple current which is enough to show up as flickering.

It's only there to power the arduino, so I have the option of using some 24v LEDs if I want.

I just disconnected it and powered the arduino from USB to make sure, but it still flickers the same.