Go Down

Topic: Confusion around resistors, PWM and mosfets (Read 498 times) previous topic - next topic

Delsey

Feb 11, 2018, 12:04 am Last Edit: Feb 11, 2018, 10:53 pm by Delsey
So I'm following Adafruits tutorial and I have the same circuit as shown here: https://learn.adafruit.com/rgb-led-strips/usage
I'm using the stp16nf06l mosfets, which were recommended to me in this forum. Now when setting a color to 0, it still lights up slightly. When using 1k resistors between pwm pins and gate, it lights up more, without them it lights up a bit. What resistor do I have to use and how do I know that?

Edit:// This could be due to something else aswell, since i noticed that the brightness differs from mosfet to mosfet even though theyre all set to 0. The strip is powered directly, as described in adafruits tutorial, the mosfets are just supposed to control how much power is going to the leds. It seems that the mosfets always provide a little bit of power. Is there any way I can fix this? Do I need different mosfets?

Edit2 in response to Wawa://
1) Did you set the (PWM?) pin to OUTPUT with pinMode(). // Yes

2) Did you connect source to supply(-) and Arduino ground. // + and - are connected to the breadboard and ground is wired back to the GND of the arduino. Wiring can be found and the adafruit link above.

3) Did you use a breadboard, and can it handle the (unknown) strip current. // Yes. The PS I am using right now has 12V, 600MaH, which is exactly what I need for a 1m Strip (according to adafruit). Using 1m for testing purposes only, when I am done with the code, I will solder it together to be able to use longer strips with higher currents.

4) Does the breadboard have uninterrupted power rails. // Yes. The only problem is that when all Pins are set to 0, the strip lights up slightly. Everything else works just fine.

// Here is a short excerpt of my not so beautiful code
Code: [Select]

int colorSave[3];
int red = 9;
int green = 10;
int blue = 11;

void setup()  {
  Serial.begin(57600);

  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);

// all off
  analogWrite(red, 0);
  analogWrite(green, 0);
  analogWrite(blue, 0);
} // end of setup

void loop()  {
  if (Serial.available() > 0) {
    color = Serial.read();
  } // end of if

// This goes from A-Z. It contains different colors and fade loops. redConf is to configure the strip if the colors are off
  if (color == 'a') {
    colorSave[0] = 255 - redConf;
    colorSave[1] = 0;
    colorSave[2] = 0;
    analogWrite(red, colorSave[0]);
    analogWrite(green, colorSave[1]);
    analogWrite(blue, colorSave[2]);
}

Wawa

Use a 220ohm resistor between pin and gate, and a 10k resistor from pin to ground.

Did you set the (PWM?) pin to OUTPUT with pinMode().
Did you connect source to supply(-) and Arduino ground.
Did you use a breadboard, and can it handle the (unknown) strip current.
Does the breadboard have uninterrupted power rails.

Post your code,a and a clear picture of the wiring.
Read the forum rules first.
Leo..

Delsey

#2
Feb 11, 2018, 02:31 pm Last Edit: Feb 11, 2018, 02:37 pm by Delsey
Use a 220ohm resistor between pin and gate, and a 10k resistor from pin to ground.

Did you set the (PWM?) pin to OUTPUT with pinMode().
Did you connect source to supply(-) and Arduino ground.
Did you use a breadboard, and can it handle the (unknown) strip current.
Does the breadboard have uninterrupted power rails.

Post your code,a and a clear picture of the wiring.
Read the forum rules first.
Leo..
I have honestly no Idea why I am using 1k resistors. I started this project last year and just came back to it. I updated the question. Am going to swap the resistors the way you told me to. If this doesnt fix it, I will provide wiring. Thanks for now man

Delsey

First of all, sorry for bumping this thread again.

I fixed my issue by changing to Tip122. I would not recommend stp16nf06l-mosfets to anyone trying to power less than 15m because you are probably going to get some problems with them sooner or later.

The pulldown that wawa suggested didnt help and the 220ohm transistor didnt change much aswell. I'm now using the Tip122 with a 330ohm between the pin and the gate. Thanks for the ideas anyways.

Wawa

A TIP122 is not a mosfet, so doesn't have a gate. It has a base.
It should work ok if your strip isn't that long.
The TIP122 has some volt drop when 'on', so your strip is not running at full supply voltage (less bright).

Mosfets gates can easilly be damaged by ESD. You must have damaged it by handling it wrong.
General rule (on e.g. a breadboard) is to connect the gate last, and disconnect it first.
Tip: When soldering, you short all pins together by running a bare wire through the legs (touching the gate last), then solder, and then remove the wire.
Leo..

Grumpy_Mike

Quote
The pulldown that wawa suggested didnt help and the 220ohm transistor didnt change much aswell.
That is a 220 ohm resistor not a transistor and you will not see any difference except your Arduino will not be damaged. The pull down resistor stops random turning on with the strip powered but the Arduino not. These things should be done whether you see a difference or not.

Now you have a transistor and not a FET then you need that 220R resistor more than ever as without it the Arduino is damaged by having about twice the maximum current taken from it.

Delsey

It should work ok if your strip isn't that long.
I will be using ~1A/transistor


Mosfets gates can easilly be damaged by ESD. You must have damaged it by handling it wrong.
probably


General rule (on e.g. a breadboard) is to connect the gate last, and disconnect it first.
Tip: When soldering, you short all pins together by running a bare wire through the legs (touching the gate last), then solder, and then remove the wire.
I didnt know that, thanks.


resistor not a transistor
Not my native language, I keep messing that up.


Now you have a transistor and not a FET then you need that 220R resistor more than ever as without it the Arduino is damaged by having about twice the maximum current taken from it.
I calculated that I need a 330ohm resistor. Shouldnt make much of a difference.
Thank you for your answers.

Wawa

I will be using ~1A/transistor

I calculated that I need a 330ohm resistor. Shouldnt make much of a difference.
I thought you were using a TIP122 (darlington transistor).
They need a base current of 1/250 of the collector current for full saturation (least volt drop when 'on').

A common "1A transistor" (not a darlinton) needs 5-10% of the collector current in the base for full saturation.
"I calculated 330ohm for a 1A transistor" means you're not expecting to switch more than 250mA.

A common misunderstanding is that Hfe (transistor gain) has to be used to calculate base current.
Leo..
 

Go Up