Share My Creation 4 seven segment with 74HC595 multiplexer IC

Hi all of you.
in this project I can use 4 seven segment with 4 74HC595 multiplexer IC.
my project wiring is shown below picture.

in each time I show a number in left seven segment and then shift it to next seven segment in right side.
I repeat up line 3 time.

I will be create a big clock and use this project on that.
 

Attachments

  • 74hc595.jpg
    74hc595.jpg
    40.1 KB · Views: 1,424
  • ۲۰۲۴۰۱۰۵_۲۳۱۱۴۸-1.jpg
    ۲۰۲۴۰۱۰۵_۲۳۱۱۴۸-1.jpg
    54.5 KB · Views: 150
  • -5780529383868576436_120.jpg
    -5780529383868576436_120.jpg
    25.1 KB · Views: 151
  • Untitled.png
    Untitled.png
    31.1 KB · Views: 140
Last edited:

emexes

Expert
Licensed User
Any chance of seeing the code, or at least the bit-banging serial output routine?

I still remember the revelation handed to me by my high school teacher when he saw my first attempt at a binary search. ?
 

vali khandangoll

Active Member
Any chance of seeing the code, or at least the bit-banging serial output routine?

I still remember the revelation handed to me by my high school teacher when he saw my first attempt at a binary search. ?
yes.
 

Attachments

  • 4_secen_segment_OK.rar
    780 bytes · Views: 102

emexes

Expert
Licensed User
Any chance of seeing the code

Hang on, that's in C, not B4R. ?

One thing that stands out is that you're latching the shift registers into the output latches after sending each digit, rather than at the end after sending all digits, when all the bits are finally in the right spot.

Fix by moving the latch_enable call out of here:
C:
void send_data(unsigned int data_out)
{
    int i;
 //   unsigned hold;
    for (i=0 ; i<8 ; i++)
    {
        if ((data_out >> i) & (0x01))
        digitalWrite(DATA_pin,HIGH);
        else
        digitalWrite(DATA_pin,LOW);     
        clock_signal();
    }
    latch_enable(); // Data finally submitted
}

into here:

C:
void show_number(byte n1, byte n2,byte n3,byte n4) {
    send_data(binary_pattern[n4]);
    send_data(binary_pattern[n3]);
    send_data(binary_pattern[n2]);
    send_data(binary_pattern[n1]);
    latch_enable(); // Data finally submitted
}

And if that doesn't fully fix the problem, then chances are that we've got the latch pulse upside down too.

It could be that LOW means the latch is "active" and the outputs to the LEDs are following the inputs from the shift registers "live", and HIGH means the latches are "inactive" and just holding the last value that was present.

So try flipping these two lines around and see if the LEDs stop flickering whilst the data is being shifted in:

C:
void latch_enable(void)
{
    digitalWrite(LATCH_pin, HIGH);
    digitalWrite(LATCH_pin, LOW);
}
 

emexes

Expert
Licensed User
This works ? :

C:
a1=(number /1000);
 
a2= number / 100;
a2=(a2 % 10);

a3=number % 100;
a3=a3 / 10;

a4=number % 10;

but would be simpler ?? as:

C:
int temp = number;

a4 = temp % 10;    // units
temp = temp / 10;

a3 = temp % 10;    // tens
temp = temp / 10;

a4 = temp % 10;    // hundreds
temp = temp / 10;

a1 = temp % 10;   // thousands
// final division not needed

and the pattern for future extension even more clear as:

C:
int temp = number;
a4 = temp % 10;  temp = temp / 10;    // units
a3 = temp % 10;  temp = temp / 10;    // tens
a2 = temp % 10;  temp = temp / 10;    // hundreds
a1 = temp % 10;                       // thousands    final division not needed

Personally I'd number the units to thousands digits as a0 to a3 rather than a4 to a1
so that a0 is the 10^0 ie units digit, a1 is the 10^1 ie tens digit, a2 is the 10^2 ie hundreds digit etc,
or you can think of it as the multipler (column) value of digit aN is 1 followed by N zeroes

but on the other hand, maybe the LED displays are already numbered 1 to 4, or some other reason exists to justify:
if it ain't broke, don't fix it ?
 
Last edited:

emexes

Expert
Licensed User
This works:

C:
void send_data(unsigned int data_out)
{
    int i;
 //   unsigned hold;
    for (i=0 ; i<8 ; i++)
    {
        if ((data_out >> i) & (0x01))
        digitalWrite(DATA_pin,HIGH);
        else
        digitalWrite(DATA_pin,LOW);   
        clock_signal();
    }
}

but maybe make the input parameter an 8-bit type eg byte or unsigned char

and another way of shifting out the eight bits is:

C:
void send_data(unsigned char data_out)
{
    for(int i = 8; i; i--)    // do 8 times
    {
        digitalWrite(data_out & 1);    // send current bit 0
        data_out >>= 1;    // bonus! do this first, while giving data line extra time to settle
        clock_signal();    // before we clock it
    }
}
 

vali khandangoll

Active Member
Hang on, that's in C, not B4R. ?

One thing that stands out is that you're latching the shift registers into the output latches after sending each digit, rather than at the end after sending all digits, when all the bits are finally in the right spot.

Fix by moving the latch_enable call out of here:
C:
void send_data(unsigned int data_out)
{
    int i;
 //   unsigned hold;
    for (i=0 ; i<8 ; i++)
    {
        if ((data_out >> i) & (0x01))
        digitalWrite(DATA_pin,HIGH);
        else
        digitalWrite(DATA_pin,LOW);   
        clock_signal();
    }
    latch_enable(); // Data finally submitted
}

into here:

C:
void show_number(byte n1, byte n2,byte n3,byte n4) {
    send_data(binary_pattern[n4]);
    send_data(binary_pattern[n3]);
    send_data(binary_pattern[n2]);
    send_data(binary_pattern[n1]);
    latch_enable(); // Data finally submitted
}

And if that doesn't fully fix the problem, then chances are that we've got the latch pulse upside down too.

It could be that LOW means the latch is "active" and the outputs to the LEDs are following the inputs from the shift registers "live", and HIGH means the latches are "inactive" and just holding the last value that was present.

So try flipping these two lines around and see if the LEDs stop flickering whilst the data is being shifted in:

C:
void latch_enable(void)
{
    digitalWrite(LATCH_pin, HIGH);
    digitalWrite(LATCH_pin, LOW);
}
thank
Moving this command solved the problem of flashing off segments.
Now there is no problem in displaying the numbers and the numbers are displayed very clearly.

Soon I will send the image of the clock that I want to make in large size.
 
Top