nuage4
March 13, 2017, 11:12pm
1
For some strange reason I had this working yesterday and now today its not working.
When I use the Fade example in arduino if doesnt turn the LED off when PWM reaches 0.
I've tried 2 arduino uno's and also tried all the PWM ports as I know 3 & 5 have been known to have issues.
Could anyone suggest where I might start troubleshooting this. I know that the code works as its in the example library for arduino.
Im using the following mosfet - IRLB8721PBF datasheet(1/9 Pages) IRF | HEXFET Power MOSFET
LED strip - https://www.amazon.co.uk/gp/product/B00V4GY1UO
Im very confused as it was working yesterday.
pert
March 14, 2017, 3:23am
2
Are you seeing any fade at all?
What do the LEDs do at PWM 0, are they very dim?
Have you tried a simple test of directly controlling the mosfet without the Arduino?
Have you tried controlling the mosfet via the Arduijno without PWM (i.e. using digitalWrite())?
Please show how you have things wired up.
nuage4
March 14, 2017, 8:17am
3
pert:
Are you seeing any fade at all?
What do the LEDs do at PWM 0, are they very dim?
Have you tried a simple test of directly controlling the mosfet without the Arduino?
Have you tried controlling the mosfet via the Arduijno without PWM (i.e. using digitalWrite())?
Please show how you have things wired up.
Yes it is fading, going full brightness and then just somewhat dim.
How would I control the mosfet without the arduino?
Ive just tried this code for digitalwrite:
int ledPin = 13;
unsigned int i=0;
boolean rise=true;
int period=1000;
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
if(i == period)
{
i=1;
rise= !rise;
}
if(rise == false)
{
digitalWrite(13, LOW);
delayMicroseconds(i);
digitalWrite(13, HIGH);
delayMicroseconds(period-i);
i=i+1;
}
if(rise == true)
{
digitalWrite(13, LOW);
delayMicroseconds(period-i);
digitalWrite(13, HIGH);
delayMicroseconds(i);
i=i+1;
}
}
and it still fades but doesnt turn completely off.
Here is the setup -
12v Power supply + -----> LED +
Left Pin Mosfet -----> 12v Power supply -
Middle Pin Mosfet -----> LED -
Right Pin Mosfet -----> Arduino 6 (or 13 when testing digital fade)
Here is the fading on digital, its the same as PWM never turns completely off
pert
March 14, 2017, 10:07am
4
When you're troubleshooting you need to remove any unnecessary complications to narrow down the cause of the problem.
The most simplified possible setup is to directly connect the LED to the power supply.
The next most simple setup is to directly control the mosfet by connecting the gate to 5 V or GND
After that is using the Arduino to switch the mosfet in a simple Blink type sketch. Like this:
const byte LED = 13;
const int intervalDuration = 1000;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(intervalDuration);
digitalWrite(LED, LOW);
delay(intervalDuration);
}
Next it's Blink using analogWrite():
const byte LED = 13;
const int intervalDuration = 1000;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
analogWrite(LED, 0);
delay(intervalDuration);
analogWrite(LED, 255);
delay(intervalDuration);
}
By starting from the most simple test configuration and then slowly adding in the other components of your project until the issue occurs you can pinpoint the cause, which makes it much easier to find a solution than randomly guessing at what's not working.
nuage4
March 14, 2017, 8:48pm
5
pert:
When you're troubleshooting you need to remove any unnecessary complications to narrow down the cause of the problem.
The most simplified possible setup is to directly connect the LED to the power supply.
The next most simple setup is to directly control the mosfet by connecting the gate to 5 V or GND
After that is using the Arduino to switch the mosfet in a simple Blink type sketch. Like this:
const byte LED = 13;
const int intervalDuration = 1000;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(intervalDuration);
digitalWrite(LED, LOW);
delay(intervalDuration);
}
Next it's Blink using analogWrite():
const byte LED = 13;
const int intervalDuration = 1000;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
analogWrite(LED, 0);
delay(intervalDuration);
analogWrite(LED, 255);
delay(intervalDuration);
}
By starting from the most simple test configuration and then slowly adding in the other components of your project until the issue occurs you can pinpoint the cause, which makes it much easier to find a solution than randomly guessing at what's not working.
thanks for this, ill go through these steps shortly but could you just explain the first point about the gate to 5v or GND ?? What would the whole circuit look like?
pert
March 14, 2017, 8:55pm
6
Instead of connecting the wire to pin 6 you would connect it to 5 V or GND.
nuage4
March 14, 2017, 9:52pm
7
pert:
Instead of connecting the wire to pin 6 you would connect it to 5 V or GND.
ok so following the same setup as before but instead of plugging into pin 6 i plug into 5v its does nothing, plugging into GND it goes fully bright
also i have noticed when i swap around the gate and source leads around the LED acts the opposite
So original wiring = LED would go fully bright --> not so bright
Swapped = LED goes fully off --> not so bright
nuage4
March 16, 2017, 8:06am
8
pert:
After that is using the Arduino to switch the mosfet in a simple Blink type sketch. Like this:
const byte LED = 13;
const int intervalDuration = 1000;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH);
delay(intervalDuration);
digitalWrite(LED, LOW);
delay(intervalDuration);
}
Next it's Blink using analogWrite():
const byte LED = 13;
const int intervalDuration = 1000;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
analogWrite(LED, 0);
delay(intervalDuration);
analogWrite(LED, 255);
delay(intervalDuration);
}
Just loaded up both of these and the both do the same thing; the both blink but the 'off' doesnt turn completely off, just slightly dim like in the other examples.
pert
March 16, 2017, 10:39am
9
Does it do the same if you connect it to a pin other than 13?
nuage4
March 16, 2017, 4:05pm
10
pert:
Does it do the same if you connect it to a pin other than 13?
yes same thing in the other pins i tested (both digital analog codes)