Multiplexing seven segment display, Need help

Hi,

I was able to understand bit of 74595 and was able to code it using examples from the internet and now onto multiplexing 8 seven segment displays, and now bit perplexed in coding it, if the circuit is in the way which I have shown you, how would I be able to code for displaying two different number since it is connected together

//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;



void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);




}

void loop() {
  // count from 0 to 255 and display the number
  // on the LEDs
  // for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
  // take the latchPin low so
  // the LEDs don't change while you're sending in bits:

  zero();
  delay(20);
  one();
  delay(20);

  //delay(500);
  //  }
}

void zero()
{
  digitalWrite(latchPin, LOW);
  // shift out the bits:
  shiftOut(dataPin, clockPin, MSBFIRST, 0b11111111);// second 74595 register//among eight binary values lsb is Q0 which is 15th pin of 74595
  //delay(1000);

  shiftOut(dataPin, clockPin, MSBFIRST, 0b11111101); // first 74595 register, last bit is dp, last but two is middle line

  //take the latch pin high so the LEDs will light up:
  digitalWrite(latchPin, HIGH);
}

void one()
{
  digitalWrite(latchPin, LOW);
  // shift out the bits:
  shiftOut(dataPin, clockPin, MSBFIRST, 0b11111111);// second 74595 register//among eight binary values lsb is Q0 which is 15th pin of 74595
  //delay(1000);

  shiftOut(dataPin, clockPin, MSBFIRST, 0b01100000); // first 74595 register, last bit is dp, last but two is middle line

  //take the latch pin high so the LEDs will light up:
  digitalWrite(latchPin, HIGH);
}

Now I need to have the code to display two different numbers, I have attached the circuit diagram

Logeswari12: Hi,

I was able to understand bit of 74595 and was able to code it using examples from the internet and now onto multiplexing 8 seven segment displays, and now bit perplexed in coding it, if the circuit is in the way which I have shown you, how would I be able to code for displaying two different number since it is connected together

Now I need to have the code to display two different numbers, I have attached the circuit diagram

But where is it?

Try to understand multiplexing. You output the segment data for one digit, then enable the related display. Wait some time, then send out the next digit to the next display. And so on... Search for LED matrix or cube, to find many comparable projects.

Lacking any circuit information, I'd guess that using TPIC6B595 instead of the simple 74595 could simplify your circuit a lot.

Circuit diagram

Circuit Diagram

gpio pins in the above circuit diagram is fed using outputs of 74595 shift register which is controlled using arduino

How is it connected?
Which one connected to 1st 74595 shift register and 2nd 74595 shift register?
You have both segment data and digits data.

Edit:

OP attach image

87edf6e43b98f9eb2f68aa44afc02e921a5a9f75.jpg

Have attached the whole circuit diagram in my previous post

You'll need to put the resistors in the anode lines as in your first circuit - otherwise the brightness of the lit segments will depend on how many are turned on

regards

Allan.

You have both 595's inputs paralleled without any additional selecting lines from the Arduino. How are you going to differentiate the segment data from the position data? One suggestion would be to use a separate RCLK line from the Arduino to each 595. This way you shift in segment data to both 595's then pulse the RCLK line on the segment 595 to latch the segment data to the output. Then shift in the position data to both 595's and pulse only the position 595 RCLK to latch it's output. Pause a little then clear both 595's along with their output buffers and repeat. (There is a separate pin on the 595 that clears the shift register but not the output register, after clearing the 595 you will have to pulse RCLK on each 595 to prevent displaying gibberish as you shift in new segment data.)

You have both 595’s inputs paralleled without any additional selecting lines from the Arduino. How are you going to differentiate the segment data from the position data?
One suggestion would be to use a separate RCLK line from the Arduino to each 595. This way you shift in segment data to both 595’s then pulse the RCLK line on the segment 595 to latch the segment data to the output. Then shift in the position data to both 595’s and pulse only the position 595 RCLK to latch it’s output. Pause a little then clear both 595’s along with their output buffers and repeat. (There is a separate pin on the 595 that clears the shift register but not the output register, after clearing the 595 you will have to pulse RCLK on each 595 to prevent displaying gibberish as you shift in new segment data.)

I find it difficult to understand can you explain this in detail, or can you provide some document so that I could read that and understand

Your wiring and code is correct, so far. With every shiftOut() a byte is output to the shift registers, with the first byte determining the display, and the second byte the segments on that display. This means that in the first byte only one bit should be set (1), which turns on the transistor for that display. Every set bit in the second byte turns on the related segment.

But your zero() and one() functions, as is, will show the same digit in all displays, because the first byte contains all 1s. You better write a function to show a given digit on a given display, like this:

void showRaw(byte segments, byte display)
{
 digitalWrite(latchPin, LOW);
 // shift out the display bits:
 shiftOut(dataPin, clockPin, MSBFIRST, display);// second 74595 register
 // shift out the segment bits:
 shiftOut(dataPin, clockPin, MSBFIRST, segments); // first 74595 register, last bit is dp
 //take the latch pin high so the LEDs will light up:
 digitalWrite(latchPin, HIGH);
}

Now you can show a zero in the first display, by calling

showRaw(0b11111101, 0b00000001);

or a one in the second display

showRaw(0b01100000, 0b00000010);

The following code will show both in multiplex:

void loop() {
showRaw(0b11111101, 0b00000001);
delay(10);
showRaw(0b01100000, 0b00000010);
delay(10);
}

Try to make this example work.

Next comes code to show arbitrary digits on all displays...

Sorry about that. Having taken a closer look at your drawing I now see that you have configured the two 8 bit shift registers into a 16 bit shift register.