So many possibilities to troubleshoot... Where do I begin?

I have managed to dive into the “deep end of the pool” when it comes to a project I’m working on. I’ve designed and build a board to control some LEDs for a helicopter I’m building. The basic idea is a shift register feeding a darlington array and then output the darlington array to the LEDs. Attached are the pictures of the schematic, the board without the pro mini attached and a pic with the mini attached.

Also here is the code that I’m running to try and get the LED going:

#include <EEPROM.h>

//Pin connected to ST_CP of 74HC595
int latchPin = 4;
//Pin connected to SH_CP of 74HC595
int clockPin = 3;
////Pin connected to DS of 74HC595
int dataPin = 2;
int seq[14] = {1,2,4,8,16,32,64,128,64,32,16,8,4,2};
void setup()
{
  // start serial port at 9600 bps and wait for port to open:
  Serial.begin(57600);
      pinMode(dataPin, OUTPUT);       //Configure each IO Pin
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);

}

int inByte;

char inData[20]; // Allocate some space for the string
char inChar; // Where to store the character read
byte index = 0; // Index into array; where to store the character
int address = 0;
byte value;

void loop()
{
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {
    // get incoming byte:
    //inByte = Serial.read();
    //Serial.println("One way");  


    while(Serial.available() > 0) // Don't read unless
      // there you know there is data
    {
      if(index < 19) // One less than the size of the array
      {
        inChar = Serial.read(); // Read a character
        inData[index] = inChar; // Store it
        index++; // Increment where to write next
        inData[index] = '\0'; // Null terminate the string
      }
    }
    // Now do something with the string (but not using ==)
    if (strcmp(inData, "Read")  == 0){
      Serial.println("SndEprom");
      sendProm();
      
    }

  }
  
      for (int n = 0; n < 14; n++)
    {
        digitalWrite(latchPin, LOW);             //Pull latch LOW to start sending data
        shiftOut(dataPin, clockPin, MSBFIRST, seq[n]);          //Send the data
        digitalWrite(latchPin, HIGH);            //Pull latch HIGH to stop sending data
        delay(75);
    }
}

void sendProm(){
  for (int i=0; i <= 100; i++){
       // read a byte from the current address of the EEPROM
  value = EEPROM.read(address);
  
  Serial.print(address);
  Serial.print(",");
  Serial.print(value, DEC);
  Serial.println();
  
  // advance to the next address of the EEPROM
  address = address + 1;
  
  // there are only 512 bytes of EEPROM, from 0 to 511, so if we're
  // on address 512, wrap around to address 0
  
    
  delay(15);
   } 
   address = 0;
}

My first step will be to make sure that there is indeed 5v present at the LED SUP input. Any thoughts after that would be greatly appreciated.

Loren

You made about 5 steps at once. Do this step by step. You need for example a few test sketches, before trying to run the final project.

Is the Arduino board running, can you upload a sketch to it ? This is your board: http://arduino.cc/en/Main/ArduinoBoardProMini Can you make the led of the Arduino board blink when it is attached to your board ?

Check the wiring of the shift registers. Either the schematic is wrong, or you have connected them wrong. This is explanation and shows cascading for 2 shift registers: http://bildr.org/2011/02/74hc595/ You have enough pins, so you don't need cascading.

If the shift registers are working, you have to check how the ULN2004 are wired. The connectors to the leds have no power pin but a GND pin. The ULN2004 is like an open-collector output, you need a power pin for the leds. What do the leds look like ? Do they have a series resistor build in. I don't think so. You can't connect the leds like that.

Caltoa: You made about 5 steps at once. Do this step by step. You need for example a few test sketches, before trying to run the final project.

Is the Arduino board running, can you upload a sketch to it ? This is your board: http://arduino.cc/en/Main/ArduinoBoardProMini Can you make the led of the Arduino board blink when it is attached to your board ?

I'm certain that I'm able to get a sketch to work on the board. I've been able to communicate both ways to a processing sketch that I'm running on my laptop.

Caltoa: Check the wiring of the shift registers. Either the schematic is wrong, or you have connected them wrong. This is explanation and shows cascading for 2 shift registers: http://bildr.org/2011/02/74hc595/ You have enough pins, so you don't need cascading.

This is the schematic that I based my board off of. It appears that I missed a couple of things which are probably contributing to my problems.

I missed the capacitor which isn't shown in the link you provided. I'll try and look up the specific data sheet for the 595s I ordered and look into the master reclear pin. After looking at the diagram again with "fresh eyes" I missed the fact that the data needs to loop through each 595.

Caltoa: If the shift registers are working, you have to check how the ULN2004 are wired. The connectors to the leds have no power pin but a GND pin. The ULN2004 is like an open-collector output, you need a power pin for the leds. What do the leds look like ? Do they have a series resistor build in. I don't think so. You can't connect the leds like that.

I'll do a little more digging on the darlington.

Thanks for your help

I never used that capacitor. But the rest is like it should be. Can you toggle an output of the shift register with a test sketch ?

I'll try and give that a shot.

Connect HC595 OE/ to Gnd. Get rid of any caps on control lines Connect MSCLR to +5. Put 0.1uF cap from Vcc pin to Gnd. Right click HC595 symbol click INVOKE, will make Power & Gnd pins appear. RCK is the Output register clock, LATCH connects to that. ULN2004 http://www.ti.com/lit/ds/symlink/ulq2004a.pdf can only drive its outputs low, so: +5 to anode, cathode to resistor, resistor to ULN2004 output.

CrossRoads,

Wow thanks for all of the pointers. I've made all of the appropriate adjustments to the schematic, but I do have one additional question:

CrossRoads: ULN2004 http://www.ti.com/lit/ds/symlink/ulq2004a.pdf can only drive its outputs low, so: +5 to anode, cathode to resistor, resistor to ULN2004 output.

I'm going to be using LED strips. I thought I saw current limiting resistors on the strip. If they have them on the strip would it be necessary to include them on this board?

Thanks again guys,

Loren

What LED strip, link please.

Sorry about that...

Here is the link: http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=17407

Those are not seperate leds, that is a led strip.
So you don’t need the shift registers, and you don’t need the ULN2004 drivers, you need to control a led strip.
Or do you want to control 8 led strips ?

Simple led strips can be controlled by a 12V pwm signal (or 3 for RGB color), some have a control chip.
I think you have a simple one.

The best way is to use 3 mosfets for a 12V pwm signal.
On this page:
http://www.pighixxx.com/abc-arduino-basic-connections/
Click on “Set 2 (Card 4,5,6)”, look at card 5 how to control a led strip.
The orange label “OUT” is an arduino pin. So you need 3 pwm arduino pins, and that is all (for just one led strip that is).

Here is my idea. I’m building a hexacopter. I’d like my LED controller to take telemetry data from the flight controller and change the colors based on information from the flight controller.

Caltoa:
Or do you want to control 8 led strips ?

Actually 7 (one strip per leg. to help me see the orientation easier and a “heartbeat” LED) All of them RGB

For my application size and weight will matter a little. I’ll look around a bit to see if I can get a mosfet small enough to fit on my 55mm square board.

Also based on the attached drawing (that I revised) did I take care of Crossroads suggestions?

I can’t thank you all enough for the tremendous help!

Loren

I haven't read everything in the post, but did you mean to leave QA unconnected?

LarryD: I haven't read everything in the post, but did you mean to leave QA unconnected?

Yes, to make the layout work a little easier.

Keep in mind in the future projects, a ULN2803 or 2804 has 8 divers rather that the 2004 with 7. When you add the decoupling capacitors install them as close as you can to VCC and GND on the I.C.s

LarryD: Keep in mind in the future projects, a ULN2803 or 2804 has 8 divers rather that the 2004 with 7.

Got it.

LarryD: When you add the decoupling capacitors install them as close as you can to VCC and GND on the I.C.s

should there be one per IC? I'm assuming .1uf?

I would use 1 per.
If you use a surface mount ceramic these are easy to solder under the I.C.

imagesCAW7AIBS.jpg

Would placing them like this be good?

Great. You could thicken the longer trace.

So I’ve made several more adjustments to this project. Attached is the latest schematic.

Caltoa:
Check the wiring of the shift registers. Either the schematic is wrong, or you have connected them wrong.
This is explanation and shows cascading for 2 shift registers:
bildr Can you move over? The 74HC595 8 bit shift register - bildr
You have enough pins, so you don’t need cascading.

Could I address each shift register individually? If I can address each register individually are there any downsides to doing so other than using extra pins?

Loren:
I’m going to be using LED strips. I thought I saw current limiting resistors on the strip. If they have them on the strip would it be necessary to include them on this board?

I did see that there are resisters on the LED strips. Does anyone have a recomendation as to whether or not I should include current limiting resistors as part of this schematic?

Again many thanks everyone!

Loren

[u]Shift registers:[/u] Shift registers can be used in many ways, but is it useful ? Pushing 24 bits into the shift registers is very fast. I think there is no need to change it. But you could connect the latch to individual Arduino pins, and if you don't chain them, you can use one at a time. That would result in 5 pins on the Arduino, not a problem. Updating all of them will not be faster. You can seperate the serial data, and use 7 pins on the Arduino. But the extra code in the sketch will still not make it faster.

[u]Led strip resistors:[/u] The led strip is for 12V. Often 3 leds in series are used, with a resistor, to make it work for 12V. With a led strip, you don't need extra resistors.

[u]fade[/u] To get all the RGB colors, a PWM signal is used for every 'R', 'G' and 'B'. Since you use the shift registers, using PWM is a lot harder and not so smooth anymore. Did you know that ?

[u]maximum current[/u] I see you have the 12V at the led connector, and the ULN as driver. The ULN chips have a maximum current per output and a total maximum current. Can you check that ? The current depends on the length of the led strip.