Saturday 9 May 2015

4511 BCD to 7 segment decoder - 7 Segment display








In this project we will look at the 4511 chip and get it to display and output to a standard common cathode 7 segment display.

By the end of this project you will have a fully working chip that only uses a few pins from the Arduino and gives you an awesome number display that's easy to change!

*4511 information*

 So what is the 4511?
The 4511 is a BCD or Binary-Coded Decimal to 7 segment decoder, and now that in English, the chip takes in binary data (off or on) processes what is has and then turns on some of its outputs in corresponds to its truth table (see below), these can be connected to a 7 segment LED and display a number.

So why should I use the 4511?
The amount of output pins the Arduino has is limited (unless you have an Mega) so you really want to make the most of them.  If you just plugged in all seven pins from the display in to board there would not be many left available.  The 4511 only takes up four pins, one for each binary input, this gives you more pins left to use for other things or more 4511's!

4511 pinout;

Nice and straight forward pinout.  There is nothing to complex with this chip.
 


Truth Table:

Using the table below you can work out what inputs need to be On / High and which pins need to be Off / Low to display the required segments on the display.

For normal operation on the 4511 you tie the BL (Blanking) and LT (Lamp Test) to positive rail (1) and LE (Latch Enable) to the negative rail (0).


    Key:         LE = Latch Enable             Inputs A,B,C,D = Binary in
                     BL = BLanking                  Outputs a,b,c,d,e,f,g = Outputs to 7 segment LED
                     LT = Lamp Test

                     0 = Low / Off
                     1 = High / On

 Binary:
As the full name suggest its a BCD so binary plays the main role in this chip.  The inputs are tied in to the first four progressions of binary so; A = 1, B = 2, C = 4, D = 8. 

Examples;
                 If you wanted to display the number "3" you have to have have "On" A and B.


 *The Project*

  That will you need:

  1. Ardunio UNO (NANO will suitable too with a few changes)
  2. Breadboard (One large one or two smaller)
  3. Lots of jumper wires
  4. 4511 chip (Sources at bottom of page)
  5. Common cathode 7 segment LED (any colour / size. I use the modern pinout)
  6. 7 x 150Ohm resistors (Resistor LED calculator LINK)

The diagram:
Now give and take a bit on this as dependant on your setup you may only be using a single bread board (like I used a half+ board!) and you may want to adjust the program (see further down) as I have made this in a rush and might have not used the most logical wiring method I could have done, so its open to improvements!






Key: Red = Positive voltage rail
         Black = Negative power rail
         Orange = Arduino to 4511 link
         Yellow = (via resistor) 4511 to 7 segment link

 The Code;

As per normal, you can copy the code or type it by hand if you wish!  Its a very simple program as I couldn't justify investing my time making a super complex mathematics function to add up and display the numbers, something I guess for a later project or your own experimenters.

This time I have added comments after key parts to explain them as drawing on the code would look a little messy! The comments can be see after anything with "//" after.

If you chose to copy the program don't worry about anything after "//" this is only for notes and wont be "used" by the Arduino or program, its only there for us humans.


const int ina = 2; // Sets Digital pin 2 as ina (Input A on the 4511)
const int inb = 3; // Sets Digital pin 3 as inb (Input B on the 4511)
const int inc = 4; // Sets Digital pin 4 as inc (Input C on the 4511)
const int ind = 5; // Sets Digital pjn 5 a ind (Input D on the 4511)
const int del = 1000; // Sets up del (my name for delay) with a setting of a second

void setup() {
 pinMode(ina, OUTPUT); // Next four lines are setting the Arduino
 pinMode(inb, OUTPUT); // up for digital output from ina to ind
 pinMode(inc, OUTPUT);
 pinMode(ind, OUTPUT);

}

void loop() { // Start the loop
  zero();     // Calls void named "zero"
  de();       // Calls void named "de" - my custom delay
  one();
  de();
  two();
  de();
  three();
  de();
  four();
  de();
  five();
  de();
  six();
  de();
  seven();
  de();
  eight();
  de();
  nine();
  de();
 
 
}

void de(){                      // The "de" void that calls delay
  delay(del);                   // Delay with setting from the top of program
}

void zero(){                    // This void displays the number 0
  digitalWrite(ina, LOW);       // Sets ina as low
  digitalWrite(inb, LOW);       // Sets inb as low
  digitalWrite(inc, LOW);       // Sets inc as low
  digitalWrite(ind, LOW);       // Sets ind as low
  }
 
void one(){                     // This void displays the number 1
  digitalWrite(ina, HIGH);      // Sets ina as high
  digitalWrite(inb, LOW);       // Sets inb as low
  digitalWrite(inc, LOW);       // Sets inc as low
  digitalWrite(ind, LOW);       // Sets ind as low
}

void two(){                     // This void displays the number 2
  digitalWrite(ina, LOW);
  digitalWrite(inb, HIGH);
  digitalWrite(inc, LOW);
  digitalWrite(ind, LOW);
}

void three(){                   // This void displays the number 3
  digitalWrite(ina, HIGH);
  digitalWrite(inb, HIGH);
  digitalWrite(inc, LOW);
  digitalWrite(ind, LOW);
}

void four(){                    // This void displays the number 4
  digitalWrite(ina, LOW);
  digitalWrite(inb, LOW);
  digitalWrite(inc, HIGH);
  digitalWrite(ind, LOW);
}

void five(){                    // This void displays the number 5
  digitalWrite(ina, HIGH);
  digitalWrite(inb, LOW);
  digitalWrite(inc, HIGH);
  digitalWrite(ind, LOW);
}

void six(){                     // This void displays the number 6
  digitalWrite(ina, LOW);
  digitalWrite(inb, HIGH);
  digitalWrite(inc, HIGH);
  digitalWrite(ind, LOW);
}

void seven(){                   // This void displays the number 7
  digitalWrite(ina, HIGH);
  digitalWrite(inb, HIGH);
  digitalWrite(inc, HIGH);
  digitalWrite(ind, LOW);
}

void eight(){                   // This void displays the number 8
  digitalWrite(ina, LOW);
  digitalWrite(inb, LOW);
  digitalWrite(inc, LOW);
  digitalWrite(ind, HIGH);
}

void nine(){                   // This void displays the number 9
  digitalWrite(ina, HIGH);
  digitalWrite(inb, LOW);
  digitalWrite(inc, LOW);
  digitalWrite(ind, HIGH);
}

*My Photos*
Please do excuse the small board its the only free from part way though projects, and yes I only used one resistor on the negative output of the 7 segment - very much a bodge job I agree!









Sources for the chips in the UK.
Maplin
CPC 

1 comment:

  1. Hi,
    I like your project and it works!
    My question is, can you make a code and diagram work for a 6-dgit, seven segment display? I would like to use your work on my 2.3" large display clock. I look forward to your reply.

    ReplyDelete