Problems with 74HC595 and ULN2003 to drive 12V 7 segment

Hi

This is my first post here. I have been working with arduino to drive a 12V seven segment display. The circuit diagram is attached.

I am following the code from bildr blog to cycle through numbers 0 to 9. However when the code gets to the part where number 8 is to be displayed, the leds dim down to almost no light. All other numbers work fine.

Here is the code with loop only showing code to display number 8:

int SER_Pin = 5; //pin 14 on the 75HC595
int RCLK_Pin = 6; //pin 12 on the 75HC595
int SRCLK_Pin = 7; //pin 11 on the 75HC595

#define number_of_74hc595s 1

#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

void setup(){
pinMode(SER_Pin, OUTPUT);
pinMode(RCLK_Pin, OUTPUT);
pinMode(SRCLK_Pin, OUTPUT);

clearRegisters();
writeRegisters();
}

void clearRegisters(){
for(int i = numOfRegisterPins - 1; i >= 0; i--){
registers = LOW;

  • }*
    }
    void writeRegisters(){
  • digitalWrite(RCLK_Pin, LOW);*
  • for(int i = numOfRegisterPins - 1; i >= 0; i--){*
  • digitalWrite(SRCLK_Pin, LOW);*
    _ int val = registers*;_
    digitalWrite(SER_Pin, val);
    digitalWrite(SRCLK_Pin, HIGH);
    _
    }_
    digitalWrite(RCLK_Pin, HIGH);
    _
    }_
    void setRegisterPin(int index, int value){
    _
    registers[index] = value;_
    _
    }_
    void loop(){
    _
    // 8 _
    _
    clearRegisters();_
    _
    setRegisterPin(0, HIGH);_
    _
    setRegisterPin(1, HIGH);_
    _
    setRegisterPin(2, HIGH);_
    _
    setRegisterPin(3, HIGH);_
    _
    setRegisterPin(4, HIGH);_
    _
    setRegisterPin(5, HIGH);_
    _
    setRegisterPin(6, HIGH);_
    _
    writeRegisters();_
    _
    delay(1000);_
    _
    }_
    _
    [/color]_
    Can anyone please help me with this issue?
    _
    *_

Where are the current limiting resistors? they are not shown on your diagram.

Every segment has to have its own resistor ( unless you are using a constant current generator type chip , which the ULN2003 isn't )

Subtract the forward voltage of the displays segment from the 12v supply, and divide it by the max recommended current of the segment in amps, and this will give you the value of the resistor in ohms.

There MUST be one resistor for each segment.

Your writeRegister is all wrong. You need to write / use a routine that sends a byte serially and then call multiple such routines to send a series of bytes. And the end of it, strobe the data - to avoid flickering.

Let say you have a functioned called hc595-write() that sends just one byte. You then can write a function to send a series of bytes this way:

Void writeRegister(unsigned char *str, unsigned char n)
For (I = 0; I < n; i++)
Hc595-write(str[ a]);

the 595 shift registers have a latch ( I use the TPIC6B595 which has the ULN2003 built in ) so to set your first 7 seg display to 8, you can use shiftout ( but dont forget the resistors ! )

 #define latchPin 6 // rck
#define clockPin 7  // sck
#define dataPin 5  // ser in

void setup () {  digitalWrite(latchPin, LOW);     
  shiftOut(dataPin, clockPin, LSBFIRST, B11111111);      
     digitalWrite(latchPin, HIGH); }  

void loop () { }  // you dont have to repeat it as its a latch

Hi Boffin1 and dhenry

Thanks for replying to my post. I have looked at your suggestions but have not had a chancee to try them out. Will hopefully try them out tonight and post the results.

With regards to your comment about resistors for seven segment display, I did not show them on the original diagram because the display I am using has resistors built into individual segments. The value of these resistors is based on a source supply of 12V.

I am attaching an image showing the schamtic of each of the segment in my display.

Regards
Taimoor

led array.PNG

Thats is right, should be fine

Seems to me you are taking an awful long way to get there.

All you really need is:
http://arduino.cc/en/Reference/ShiftOut

shiftOut(dataPin, clockPin, bitOrder, value)

In your case, expanding onwhat Boffin1 posted:

digitalWrite (RCLK_Pin, LOW);
shiftout(SER_pin, SRCLK_Pin, MSBFIRST,  numberArray[number_to_display]);
digitalWrite (RCLK_Pin, HIGH);'

numberArray would be your number fonts:

numberArray[] = {B00111111, // xGFEDCBA -> 0, with 1 = segment on
B00000110, // 1        a
B00101011, // 2    f        b
B01001111, // 3        g
B01100110, // 4   e         c
etc for 5-6-7-8-9       d
};

and number_to_display is the 0-9 that has its font pulled from the array and shifted it.

and the eigth spare bit you can use for flashing dots for a clock, or a decimal point, or any single LED display

Thank both Boffin1 and CrossRoads

I have tried your code suggestions and it works fine to display numbers 0 to 7 and 9 but the display still goes blank for 8.

I will post a link to a video I have uploaded on youtube. I think there is something wrong with my schematic but I am not sure.

Boffin1 I have ordered some TPIC6B595 as it has the darlington transistors built in. I am not sure but could 74HC595 being 8bit and ULN2003 only having 7 inputs/outputs could be causing thisproblem?

No my friend, a 7 segment display only has 7 segments to display 0 to 9, for the number 8, all 7 segments are on - look at Crossroads diagram above.

Post your latest code and we can advise.

Is your 12V supply up to the task? 7 segments is 140mA.