LED strip with external power RUINS interrupts

Hey,

Case:
In a complex project my arduino mega controls LED strips via power MOSFET and PWM output and in the same time control other things via interrupt pins (button’s, switches). Arduino is powered via power jack +5V.
Everything works work like a charm unitl I power up the external +12V led strip and make a current drain.

Problem:
When I turn on an external 12V power supply to power the LED strip AND open MOSFET via PWM

analogWrite(3, 255);

so current start going and after that ALL interrupt pins start going crazy and trigger endlessly. So it ruins all the workflow.

Interrupts are set to:

attachInterrupt(digitalPinToInterrupt(3), foo, RISING);

It happends on all interrupt pins.
I guess I should filter that noise from external power supply somehow - or maybe it’s another reason?

What I’ve tried:

  1. Tried setting:

pinMode(3, INPUT_PULLUP)

  1. Tried attaching a physical pull-down 10k resistor to that pin
  2. Tried 0.1uF, 1uf (ceramic) cap between arduino +5V and GND

Generously asking community to help as Im pretty new to shematics.

zi4rox: Hey,

Case: In a complex project my arduino mega controls LED strips via power MOSFET and PWM output and in the same time control other things via interrupt pins (button's, switches). Arduino is powered via power jack +5V. Everything works work like a charm unitl I power up the external +12V led strip and make a current drain.

Problem: When I turn on an external 12V power supply to power the LED strip AND open MOSFET via PWMso current start going and after that ALL interrupt pins start going crazy and trigger endlessly. So it ruins all the workflow.

Interrupts are set to: It happends on all interrupt pins. I guess I should filter that noise from external power supply somehow - or maybe it's another reason?

What I've tried: 1. Tried setting: 2. Tried attaching a physical pull-down 10k resistor to that pin

Generously asking community to help as Im pretty new to shematics.

Okay first problem is obvious. You are switching the ground of the LED strip instead of the 12V power. This is violating a basic tenet of electric engineering, you always switch the power lead. you do NOT switch the Ground or Neutral lead.

So what is happening? When you turn on the 12V power supply you have applied 12v to the LED strip. The only thing stopping the current from flowing is the MOSFET.

Fix the error in switching and make sure all the grounds are tied together.

See what is happening then.

Yes, you are right - if it were just a turn OFF/ON led strip via mosfet (as a switch) - I absolutely agree that I should've switch the power led.

But I'm driving led (or rgb) strip - using PWM to be able to dimm the strip from 0 to 255 for example - that's why it's on GND. (and it's working by the way)

Checked all ground connections again - all wired up. Also tried a decoupling cap between arduino GND and +5V (0.1 uf and 1uf ceramic) - still no effect.

zi4rox: Yes, you are right - if it were just a turn OFF/ON led strip via mosfet (as a switch) - I absolutely agree that I should've switch the power led.

But I'm driving led (or rgb) strip - using PWM to be able to dimm the strip from 0 to 255 for example - that's why it's on GND. (and it's working by the way)

Checked all ground connections again - all wired up. Also tried a decoupling cap between arduino GND and +5V (0.1 uf and 1uf ceramic) - still no effect.

I am not going to argue. The circuit is a violation of common engineering practices.

You need to switch the 12v instead of the Ground.

End of discussion.

I refuse to help anyone who has a complete disregard for basic engineering practices.

artisticforge: I am not going to argue. The circuit is a violation of common engineering practices.

You need to switch the 12v instead of the Ground.

You are completely wrong here.

It is extremely common, and completely normal, to switch the negative side of a load. In fact, competent designers will often go to some length to switch the low side so that they can use lower cost, higher performance N-channel MOSFETs (or in the past NPN transistors - NPN BJTs and N-ch MOSFETs always work better for given price point compared to PNP BJTs and P-ch MOSFETs), and avoid the added cost and complexity of a second transistor to control the P-channel MOSFET to switch the high side. Have you ever noticed that most LED strip has the positive side tied together, and the R/G/B channels on the negative side?

OP: That shouldn't be happening. Can you post a schematic of how things are wired?

DrAzzy: You are completely wrong here.

It is extremely common, and completely normal, to switch the negative side of a load. In fact, competent designers will often go to some length to switch the low side so that they can use lower cost, higher performance N-channel MOSFETs (or in the past NPN transistors - NPN BJTs and N-ch MOSFETs always work better for given price point compared to PNP BJTs and P-ch MOSFETs), and avoid the added cost and complexity of a second transistor to control the P-channel MOSFET to switch the high side. Have you ever noticed that most LED strip has the positive side tied together, and the R/G/B channels on the negative side?

OP: That shouldn't be happening. Can you post a schematic of how things are wired?

Sorry, B.S.E.E. University of Illinois Urbana-Champaign, IL here. I still have the textbooks which clearly spell out why you do not switch the ground or neutral.

You are wrong. Switching the "low" side leaves the device energized when it should be off. That is in violation of multiple Best Practices of engineering.

You are doing nothing but prompting bad engineering.

OP: That shouldn’t be happening. Can you post a schematic of how things are wired?

Of course, it is attached to the very first post. Thank you

  1. Tried 0.1uF, 1uf (ceramic) cap between arduino +5V and GND

Try a 470 or 1000uF and a 0.1uF across the 12V and GND.

Also that 1.5K pull-up seems a bit strong. Try 10K. Is not clear what that is pulling up to. Should be 5V not 12V (12V could damage the Arduino pin), or make it a pull-down (the important thing is that the gate does not float as the Arduino starts up). Also it's not a bad idea to have a current limiting resistor between the mosfet gate/pull-up/down resistor and the Arduino pin, e.g. 220R.

Your switch-debounce circuit (which seems very complex and could probably be replaced with a couple of lines of code) seems to involve at least two logic chips. Do you have 0.1uF bypass caps close to the power pins of those chips?

artisticforge: You are wrong. Switching the "low" side leaves the device energized when it should be off. That is in violation of multiple Best Practices of engineering.

Bull sssss

Potential is relative and without a path for the current (cut low or high) there simply is no power. So I agree with DrAzzy fully. But use star GND and decoupling of the power. And yeah, PWM (especially with higher loads) can always introduce noise. Just filter it (hardware or software) and/or make inputs lower impedance (lower pull resistor).

Electrical Test Development Engineer with Electrical Engineering from University of Twente here ;)

septillion: Bull sssss

Potential is relative and without a path for the current (cut low or high) there simply is no power. So I agree with DrAzzy fully. But use star GND and decoupling of the power. And yeah, PWM (especially with higher loads) can always introduce noise. Just filter it (hardware or software) and/or make inputs lower impedance (lower pull resistor).

Electrical Test Development Engineer with Electrical Engineering from University of Twente here ;)

How are your light switches wired in your flat or home? The "Hot" lead is switched.

The Mains breaker of your home or flat switches the "HOT"

Switching the Ground or neutral leaves the device energizes. That is against Multiple Best Practices of Engineering.

I would suggest that you refresh your engineering safety courses.

Your wrong. Completely and utterly wrong.

Stop prompting unsafe engineering practices.

artisticforge: How are your light switches wired in your flat or home? The "Hot" lead is switched.

Both L or N for plugged in devices ;) I life in a Schuko country, no polarization :)

artisticforge: The Mains breaker of your home or flat switches the "HOT"

That's because it's a safety issue. Neutral is connected to Earth and thus there is still a path for a dangerous voltages. Not an issue here. And in case of floating power systems there is no L/Hot and Neutral.

And besides, it's AC. No matter which side you switch, you're device will still have positive (50% of the time) potential compared to the other supply line.

artisticforge: Switching the Ground or neutral leaves the device energizes. That is against Multiple Best Practices of Engineering.

Bull. What does "energized" even mean?

artisticforge: I would suggest that you refresh your engineering safety courses.

Now you're talking a completely different subject namely safety! That's a completely different game. And because we're talking low voltage here, leaving the device above (or below) earth potential is of no risk at all.

artisticforge: Your wrong. Completely and utterly wrong.

Stop prompting unsafe engineering practices.

I start to sense you're a mains guy only ;) But remember, we're not talking mains here. We're talking low voltage DC.

artisticforge: Sorry, B.S.E.E. University of Illinois Urbana-Champaign, IL here. I still have the textbooks which clearly spell out why you do not switch the ground or neutral.

You are wrong. Switching the "low" side leaves the device energized when it should be off. That is in violation of multiple Best Practices of engineering.

Sorry you are wrong here. That text book is probably about domestic wiring, with an RGB strip with all the anodes connected you can't switch on the high side.

To the OP. The ground on your 12V supply should be connected directly to the ground on the FET. From that point to should be connected to the Arduino. If you have it like the diagram then you are making the Arduino carry a lot of ground current which is causing you switching problems due to ground lift. You also need a big capacitor across the 12V supply.

Thanks a lot for your replies. I've added caps to 12v supply and some more additional caps + reconnected all the wires + used some of software filtering.

I will start learning about noises, filtering and proper PCB designs, because what works flawlessly on the breadboard will not be the same on a real world PCB. * Iam googling a lot right now on this topic - but if you have some really usefull links of articles on proper PCB design that you can share - I would appreciate this.

Thanks again to all of you

Grumpy_Mike:
Sorry you are wrong here. That text book is probably about domestic wiring, with an RGB strip with all the anodes connected you can’t switch on the high side.

To the OP. The ground on your 12V supply should be connected directly to the ground on the FET. From that point to should be connected to the Arduino. If you have it like the diagram then you are making the Arduino carry a lot of ground current which is causing you switching problems due to ground lift. You also need a big capacitor across the 12V supply.

Mike, I doubt that is an RGB LED Strip.
His diagram shows only one M0SFET, which leads me to believe that it is a single color LED strip.

If it is a single color LED strip switching the 12Volt is the same as the switching the Ground
Switching the Ground in the case of a single color LED strip is just wrong.

The textbook is on the Best Enigneering Practices for Safe and Maintainable electronic device design.
Grants it is from the era of RLO2, RPO7, PDP-11/23, PDP-11/70, VAX-11/780, etc.
The basic rule is, remove all power from the unit when it is OFF. Never leave the device energized.

artisticforge: If it is a single color LED strip switching the 12Volt is the same as the switching the Ground Switching the Ground in the case of a single color LED strip is just wrong.

This is because I have to not just switch it on or off, but to control it's brightness too. So led strip can be 0% (OFF) 30% 50% 100% brightness via PWM. How can you achive that and please the "Best Enigneering Practices"?

zi4rox: This is because I have to not just switch it on or off, but to control it's brightness too. So led strip can be 0% (OFF) 30% 50% 100% brightness via PWM. How can you achive that and please the "Best Enigneering Practices"?

Any current flowing into the LED strip from the 12v supply by definition will be the same current flowing out of the LED strip.

What is the MOSFET on the Ground switching? When the MOSFET is off there is no Ground on the LED strip. The 12volt power input is "Floating".

When you "dim" the LED strip what are you actually doing?

The MOSFET is switching fast enough that you via Persistance of Vision perceive that the LED are "dim" when in actuality the LED are being switched on and off extremely fast.

Mike, I doubt that is an RGB LED Strip.

But if it was then you would HAVE to bottom switch it woudn't you?

The textbook is on the Best Enigneering Practices for Safe and Maintainable electronic device design.

If that is what it says it is wrong. I used to work for a world wide consumer electronics company with its own safety and compliance department. I spent many an hour discussing safety for my products with them. Their are NO regulations that specify top switching, even in mains equipment. In fact any equipment who's safety is compromised by swapping live and nutral will fail all safety requirements. That makes a bit of a nonsense about top switching.

Grumpy_Mike: But if it was then you would HAVE to bottom switch it woudn't you?

Would I personally have to bottom switch. NO I would not use the LED strip solely because I would not switch the Ground.

Sorry, I have seen too many people injured and two cases killed by equipment that was supposely turn off.

artisticforge: Sorry, I have seen too many people injured and two cases killed by equipment that was supposely turn off.

@artisticforge: I do not wish to seem insensitive to the people you know who were injured or worse. But you seem to be saying that you have seen people seriuosly injured by 12V DC. Is that right? How did it happen?

PaulRB: @artisticforge: I do not wish to seem insensitive to the people you know who were injured or worse. But you seem to be saying that you have seen people seriuosly injured by 12V DC. Is that right? How did it happen?

They were injured because someone decided to switch the ground and not the HOT lead.

Basic violation of engineering practices.

Switching the ground is just lazy and/or incompetent designing.

Does not matter the voltage.

Switching the ground is wrong no matter what the voltage.