Go Down

Topic: So many possibilities to troubleshoot... Where do I begin? (Read 2157 times) previous topic - next topic

Loren

Feb 04, 2014, 03:50 am Last Edit: Feb 04, 2014, 03:54 am by Loren Reason: 1
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:

Code: [Select]


#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

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 ?

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.


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 ?


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.


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. 



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

Caltoa

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 ?

Loren


CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Loren

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:



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

LarryD

The way you have it in your schematic isn't the same as how you have it wired up!

Loren

Sorry about that...

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

Caltoa

#9
Feb 05, 2014, 01:38 am Last Edit: Feb 05, 2014, 01:47 am by Caltoa Reason: 1
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).

Loren

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.


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

LarryD

I haven't read everything in the post, but did you mean to leave QA unconnected?
The way you have it in your schematic isn't the same as how you have it wired up!

Loren


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.


LarryD

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
The way you have it in your schematic isn't the same as how you have it wired up!

Loren


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

Got it.

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?


Go Up