Pages: [1]   Go Down
Author Topic: Problems with 74HC595 and ULN2003 to drive 12V 7 segment  (Read 2310 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}


Can anyone please help me with this issue?


* Untitled.png (57.82 KB, 1182x886 - viewed 150 times.)
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 13, 2012, 04:36:42 pm by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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]);

Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ! )

Code:
#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

     

Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Newbie
*
Karma: 1
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 (9.33 KB, 352x138 - viewed 54 times.)
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats is right,  should be fine
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 517
Posts: 26268
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
digitalWrite (RCLK_Pin, LOW);
shiftout(SER_pin, SRCLK_Pin, MSBFIRST,  numberArray[number_to_display]);
digitalWrite (RCLK_Pin, HIGH);'

numberArray would be your number fonts:
Code:
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.


Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

With my mobile phone I can call people and talk to them -  how smart can you get ?

Offline Offline
Newbie
*
Karma: 1
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 16, 2012, 09:06:36 am by Boffin1 » Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 517
Posts: 26268
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: