Seven segment with 595 Shift register

Discussion in 'Embedded Systems and Microcontrollers' started by liamneeson248, Feb 8, 2016.

  1. liamneeson248

    Thread Starter New Member

    Jan 11, 2016
    14
    1
    i am using a 595 Shift register to display seven segments.
    everything is good as i am using common cathode segment with 220ohm resistor on every led.
    but its making problems like now its keep G of the Led always on, Sometimes it on some other unexpected LED on during counting
    i am providing VCC from arduino 5v but i also use external 5v supply to it,it keeps making problem also then.

    Is 220ohm is good enough ?
    is it something to do with common anode or common cathode ?
    What can be the problem ?

    Really sorry for my bad english.
    I hope anyone here can help me regarding my issue My advance Thanks to you guys
     
    ErnieM likes this.
  2. Papabravo

    Expert

    Feb 24, 2006
    10,179
    1,800
    Schematics! Schematics Schematics! Sounds like a broken record, doesn't it?
     
  3. dannyf

    Well-Known Member

    Sep 13, 2015
    1,835
    367
    So which statement is true: everything is good or something isn't right?

    Both statements cannot be true at the same time.
     
    eetech00 likes this.
  4. absf

    Senior Member

    Dec 29, 2010
    1,493
    373
    What does G stand for in the above? Are you using RGB LED?

    Allen
     
  5. liamneeson248

    Thread Starter New Member

    Jan 11, 2016
    14
    1
    G stands for the G segment on 7 segment display
     
  6. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,815
    835
    You know, I'd like to see how you're using the two 5V sources. How can I find that out? I know! A schematic!
     
  7. absf

    Senior Member

    Dec 29, 2010
    1,493
    373
    Is this how you connect your display to the 595?

    Which 595 are you using LS,HC,HCT or STD?

    liamneeson.PNG
     
    JohnInTX likes this.
  8. liamneeson248

    Thread Starter New Member

    Jan 11, 2016
    14
    1
    [​IMG]
    Here is the schematics and first of all i did tried using 5v VCC from arduino regulator but then i use external power supply but it doesnt work on anything Sometimes it works like it show 0 to 9 but then it behaves like it forget to turn off G on segment or some other LED on segment.
    is there any problem with my resistor here ?
    and why is every one on internet is using common anode Segments it doesnt make sense to me can you please answer that too ?
    and what do i have to to in order to use common anode because you know simply 595 cannot give ground to all 7 LEDs.

    i am using : 220 OHM resistors will all LEDs,common cathode segment.74HC595 shift register,arduino uno

    And Thank you all for your kind replies !


    and here is a simple code that i am using with my arduino

    int latchpin = 4;// connect to pin 12 on the '595
    int clockpin = 3; // connect to pin 11 on the '595
    int datapin = 2; // connect to pin 14 on the '595
    // the array contains the binary value to make digits 0-9
    // for the number '11' use code '31' for CC and '224' for CA
    int segment[10] = {63,6,91,79,102,109,125,7,127,111 }; // for common cathode
    //int segment[10] = {192,249,164,176,153,146,130,248,128,144 }; // for common anode

    void setup()
    {
    pinMode(latchpin, OUTPUT);
    pinMode(clockpin, OUTPUT);
    pinMode(datapin, OUTPUT);
    }
    void loop()
    {


    digitalWrite(latchpin, LOW);
    shiftOut(datapin, clockpin, MSBFIRST, 7); Shows the Number 7 on display
    digitalWrite(latchpin, HIGH);
    delay(1000);

    }
     
  9. liamneeson248

    Thread Starter New Member

    Jan 11, 2016
    14
    1
    so there is no one here to answer my question ? strange !
     
  10. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,652
    768
    Yes, it is.
     
  11. absf

    Senior Member

    Dec 29, 2010
    1,493
    373
    If your using 74xx or 74LSxx TTL family, then it is better to using common anode 7-segment LED. The 74 and 74LS chips can sink more current than sourcing the LED. But I checked the 74HC595 datasheet and it can source and sink maximum of 25mA, so either sourcing or sinking (CC or CA 7 segment LED) are OK with it.

    I cant get the Arduino to work in proteus because it doesn't accept the Arduino sketch .ino file. It can only accept .hex or .obj type file. I couldn't find any 74HC595 or LS595 handy and my Arduino uno is not with me at the moment.

    arduino with HC595.PNG
    Allen
     
  12. absf

    Senior Member

    Dec 29, 2010
    1,493
    373
    Sorry for the delay. I finally got the uno to work on proteus.

    I modify the program to display 0-9 repeatedly.

    liamneeson_0-9.PNG
    oops, I forgot to tie /MR high....

    Here's the code

    Code (C):
    1.  
    2. int latchpin = 4;// connect to pin 12 on the '595
    3. int clockpin = 3; // connect to pin 11 on the '595
    4. int datapin = 2; // connect to pin 14 on the '595
    5. // the array contains the binary value to make digits 0-9
    6. // for the number '11' use code '31' for CC and '224' for CA
    7. int segment[10] = {63,6,91,79,102,109,125,7,127,111 }; // for common cathode
    8. //int segment[10] = {192,249,164,176,153,146,130,248,128,144 }; // for common anode
    9.  
    10. void setup()
    11. {
    12. pinMode(latchpin, OUTPUT);
    13. pinMode(clockpin, OUTPUT);
    14. pinMode(datapin, OUTPUT);
    15. }
    16. void loop()
    17. {
    18.  
    19. for (char x=0; x < 10; x++)
    20. {
    21. char data = segment[x];
    22.  
    23. digitalWrite(latchpin, LOW);
    24. shiftOut(datapin, clockpin, MSBFIRST, data); //Shows the Number 7 on display
    25. digitalWrite(latchpin, HIGH);
    26. delay(1000);
    27.  
    28. }
    29. }
    30.  
    Hope Elvis hasn't left the building YET....:D

    Allen

    p/s hex file for proteus is included..
     
    Last edited: Feb 14, 2016
    Evanguy and JohnInTX like this.
  13. liamneeson248

    Thread Starter New Member

    Jan 11, 2016
    14
    1

    Thank you so much sir that's very nice of you !
    Sir if you may answer some questions for me which are very confusing for me
    1- Why people on internet tutorials are using common anode Segments mostly?
    2-Even if i use common anode can 74HC595 provice ground voltages for it to work ? if then how ?
    3-can a 74HC595 provide enough current to light a complete common cathode seven segment ?
     
  14. Austin Clark

    Member

    Dec 28, 2011
    409
    44
    1) My guess is that those are easier to drive using NPN BJT's and 7400 series TTL logic ICs. Personally I've only ever used one application-specific LED matrix driver, and it requires a common cathode configuration.

    2) With the display hooked up properly (Common Anode configuration), you will be required to turn ON leds with LOW outputs. Basically, 0/LOW output means "LED ON". It's just a matter of making the change in software.

    3) For individual segments, yes, but keep in mind the total current consumption of the entire chip. That shouldn't exceed about 70mA. I'd limit individual segment currents to 5-10mA, which should be plenty bright.
     
  15. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,399
    497
    Because most chips are not designed to provide current to led. When you have 7 segment, you have 7 led, each led will need something like 10-15 mA, 7*15 mA=105 mA. So the chip has to provide around 70-100 mA just for led, that does not count all the other connections that the chip might have.

    It is far safer to let chip receive current (sink). Your led are light up and you are not stressing the chip.
     
Loading...