Photography Project; need help with mysterious glitch

Hi! (My first post here)

I'm dealing with a bit of a head scratcher here...

My project consists of 10 LED's (12v 3W COB) that light up independently and in an ordered sequence (one after the other, turning off the last one). At the same time, while each LED turns ON individually a CANON camera takes a picture. (a technique called RTI if anyone's curious)

Specifically, when you start the program a single LED shines in order to get the user a chance to set up the camera (exposure, white balance, etc.) then, by pressing a push button on pin2, the sequence actually starts; going from digital pin13 to pin4; the camera shutter/trigger is connected to pins 0 & 1.

My setup is I guess a bit Overkill but here it is:

  • x10 LED's
  • x10 N-channel MOSFETS (IRFZ44N)
  • x1 Arduino Uno
  • x1 12v 3 Amp Power Supply (AC Wall adapter)
  • x1 2.5mm Audio cable (for triggering the camera)

Imgur

This PCB/Schematic shows the way the MOSFETs are connected to the LED's with their respective Arduino signals and power supply.

The CODE is fairly simple:
https://drive.google.com/open?id=0B9wLZtMtEUCiSUhkdjFnZGFiVEk

int i =13;
int estado, estado_ant, cont,valor;

void setup() {
 
for(i=13;i>=4;i--){
  pinMode(i,OUTPUT);
  digitalWrite(i,LOW);
}

pinMode(2,INPUT);
pinMode(1,OUTPUT);
pinMode(0,OUTPUT);

digitalWrite(0,LOW);
}

void loop() {
 
//botón (this toggles between "LED/Shutter sequence" mode and "single LED" (pin 9) mode)
 estado = digitalRead(2);
  if((estado==HIGH) && (estado_ant==LOW)){
      valor= 1 - valor;
    }
    estado_ant = estado;
  
  if(valor == 1){
     for(i=13;i>=4;i--){
  pinMode(i,OUTPUT);
  digitalWrite(i,LOW);
}

for(i=13;i>=4;i--){
  digitalWrite(i+1,LOW);
  digitalWrite(i,HIGH);
  digitalWrite(1,LOW); //shutter on
  delay(4000);
  digitalWrite(1,HIGH);//shutter off
  delay(100);
}
  
  }else{
   digitalWrite(9,HIGH);//Single LED shines for camera setup/adjustments
   digitalWrite(1,HIGH);
    }
}

The actual issue is that for some reason MOSFET #9 (pin5) isn't turning ON at all. Everything else works perfectly as its supposed to.

I've tried the following:

  • Adding 10k resistors to each of the MOSFET's Gates (to GND)
  • Replacing the MOSFET (with a P60NF06)
  • Revising my code (seems good to me)
  • Checking my electronics (all connections are fine)
  • Checking the actual LED (it works fine)

Nothing seems to work.

What am I missing?

Thanks in advance.

Edit: I meant 10k resistors instead of 100k
Edit: A kinda better schematic

You should be using logic level MOSFETS instead of IRFZ44, which are designed to be turned on by Vgs = 10V. You should have a 220 Ohm resistor between the port pin and the gate.

The PCB image doesn't help. Please post a proper schematic diagram.

This is probably not the problem, but it is not doing what you appear to expect on the first iteration:

   for (i = 13; i >= 4; i--) {
     digitalWrite(i + 1, LOW);
     . . . 
     . . .
   }

It is doing something with digital pin 14, which I believe on a Uno maps to A0.

In your and in many other cases, it is sufficient to have a pinMode() in setup() only.

If you suspect your code is causing the problem, the smallest sketch could verify that:

void setup() {
   pinMode(5, OUTPUT ) ;
   digitalWrite( 5, HIGH ) ;

}

void loop() {}

You should avoid using pins 0 and 1 in your code if possible because this limits the possibility to use Serial.print() erc. for debugging. If you are running out of digital pins, you can use the analog pins A0 to A6 as digital pins.

jremington:
You should be using logic level MOSFETS instead of IRFZ44, which are designed to be turned on by Vgs = 10V. You should have a 220 Ohm resistor between the port pin and the gate.

The PCB image doesn't help. Please post a proper schematic diagram.

Hi! first of all, thanks for your response... but, (and I'm sorry if I sound challenging) I've got a couple of questions.

How come the rest of the LEDs/MOSFETs are working fine?
Do you recommend any particular model of "logic level Mosfet"?
The 220 Ohm Resistor should be for the current setup or for the logic level ones?

Please excuse my schematic but Eagle has been failing on me recently:
Imgur

6v6gt:
This is probably not the problem, but it is not doing what you appear to expect on the first iteration:

   for (i = 13; i >= 4; i--) {

digitalWrite(i + 1, LOW);
    . . .
    . . .
  }




It is doing something with digital pin 14, which I believe on a Uno maps to A0.

In your and in many other cases, it is sufficient to have a pinMode() in setup() only.

If you suspect your code is causing the problem, the smallest sketch could verify that:



void setup() {
  pinMode(5, OUTPUT ) ;
  digitalWrite( 5, HIGH ) ;

}

void loop() {}




You should avoid using pins 0 and 1 in your code if possible because this limits the possibility to use Serial.print() erc. for debugging. If you are running out of digital pins, you can use the analog pins A0 to A6 as digital pins.

Thanks a lot for your suggestions!

The thing with the first chunk of code is because I'm not so good at it and I figured that was a way to turn off the "previous" LED (i+1) (13 being the first one).

Regarding the pin5 test, I've already done a not-so-similar test by rewiring a known to work signal to the "faulty" MOSFET and it didn't work; but perhaps I could totally eliminate the code as a culprit by running that test.

Thanks again

Using pins 0 and 1 is not recommended unless you know what you are doing as these pins carry the serial communications, so wiring stuff to it can make uploading code difficult.

How come the rest of the LEDs/MOSFETs are working fine?

They might appear to work but it will not be fine. Have you checked the signals with an oscilloscope? You will probably find that the FETs are not turning on fully.

Stupid question I'm sure but do those leds draw more than 25mA?

"They might appear to work but it will not be fine. Have you checked the signals with an oscilloscope? You will probably find that the FETs are not turning on fully."

FETs that are neither fully off or on crank out a lot of what I call "heat of inefficiency".

I got TTL level MOSFETs, 50 for $5. They're only good for switching 200mA though. Got what I paid for.

If you can watch Youtube, check out AddOhms' channel for the MOSFET tutorial. I wonder if he ever got the disk with all his shows out -- I kinda want one of those so I don't have to rewatch parts online 10-20 times to get all the details down.

Hi,
Can you please post a copy of your complete circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Please attach it to your post, rather than post it off forum.

How have you got your button wired, as I do not see a pull_up statement in your setup.
As already stated, leave pins 0 and 1 unused, they are for programming and serial comm to the outside world.

Thanks.. Tom.. :slight_smile:
Forget about Eagle for the moment, a hand drawn schematic I have found is far easier to read.
Please do not go back and edit posts to answer questions asked further down the thread, it disrupts the flow of information and makes it hard to follow for anyone who wants to later read it.

"makes it hard to follow"

LOL.... I'd say "harder", and that applies to the majority of threads.