Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: zifank on Mar 09, 2018, 03:28 pm

Title: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 09, 2018, 03:28 pm
Hello,

If anyone could give me some advise or example code that would be great.

I am using a custom 16 digit seven segment with 4 shift register 74hc595 for 3 rows


I am having trouble with the controlling each digits.

Thank you for your help!
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: ieee488 on Mar 09, 2018, 03:31 pm
You built the PCB before you verified that your circuit would work?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 09, 2018, 03:46 pm
no.
I bought it, at online store 3 months ago, the seller does not provide complete data sheets and the libraries. please give me solution.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 09, 2018, 03:53 pm
the PCB have a 5pins to arduino. VCC - R - C - S - Gnd
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: ieee488 on Mar 09, 2018, 04:01 pm
No clue, and don't want to bother.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 09, 2018, 07:32 pm
(https://forum.arduino.cc/index.php?action=dlattach;topic=534044.0;attach=248600)
(https://forum.arduino.cc/index.php?action=dlattach;topic=534044.0;attach=248602)

You should contact the vendor. If they do not have any code, perhaps they will have a data sheet or at least a schematic.

Can you see any codes/part numbers on the sides of the digits? Or the transistors?

I should warn you, it looks like it was designed by someone who is not very expert. There are no bypass caps for the chips, for example, and no reservoir caps. These could be added, if you can solder reasonably well.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 12:44 am
thanks @PaulRB for ur respon. maybe this is custom part or clone from original modul.


can you give me a sample code for controling a multi seven segment 7 digit?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 10, 2018, 08:45 am
can you give me a sample code for controling a multi seven segment 7 digit?
Yes, I could easily give you some example code. But it would be pointless. I know it would not work. Code has to be written to exactly match the hardware. I have never seen your hardware before.

If you can get no help from the seller, you can do some "reverse engineering". Identify the components from their part numbers. Trace the tracks on the PCB. Make your own schematic diagram. From that, you can write some code. We can help with some stages of that process. But you have to start, because you have the hardware in front of you.

Looking closely at the board, this is what I believe I can see and guess. There are 4 chips. It would make sense if they are 74xx595 shift registers as you say. The chip closet to the connector drives 6 transistors which in turn drive the commons for the digits in that column. The other 3 shift registers drive the segments for the digits in the 3 rows, via current limiting resistors. The 4 shift registers must be "daisy-chained", given there are only 5 pins on the connector, including power and ground. I would guess that S=Serial data, C=Clock and R=latch.

The code must perform the multiplexing, sending 3 bytes of segment data and 1 byte to select the digit column, and lighting one column of digits at a time. The most important answers you need to find out, I believe, are the digits common anode or common cathode and are the transistors NPN or PNP (or are they FETs). The part numbers written on the displays and transistors may help answer those questions.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 02:24 pm
you are the the "rock" master @PaulRB, u bright my day... :)

the digits as common cathode, the transistor is PNP
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 10, 2018, 05:09 pm
the digits as common cathode, the transistor is PNP
Are you sure? How do you know? The transistors appear to be connected to the digit common pins. If the digits are common cathode, I would have expected NPN transistors. For common anode, I would expect PNP.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 05:12 pm
i test one transistor with multimeter, and the result is PNP, but for the digits i'm not sure.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 06:10 pm
sorry my bad, the 7 segment is SM4112 and work common anode
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 10, 2018, 08:26 pm
And two LEDs per segment. Do you know what colour the LEDs are? I wonder if a 5V supply will be enough.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 08:38 pm
The color is RED, yes. i used 9volt supply
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 10, 2018, 08:44 pm
i used 9volt supply
Used it for what? You could damage components by applying too high a voltage. What kind of 9V supply did you use and what was the result?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 08:59 pm
the power is POWER SUPPLY Adapter 9V 1A for arduino. and the result is it's brighter than I use under 9volt, the power is not problem right now, but i still confused to get columns and rows.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 09:07 pm
this my result and the unfinished codes

Code: [Select]
int latchPin = 10;
int clockPin = 9;
int dataPin = 8;

// digits from the right
const byte digit[10] =      //seven segment digits in bits
{
  B10000001,  // 0
  B11110011,  // 1
  B01001001,  // 2
  B01100001,  // 3
  B00110011,  // 4
  B00100101,  // 5
  B00000101,  // 6
  B11110001,  // 7
  B00000001,  // 8  fix
  B00100001,  // 9
};


void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
}

void loop()
{
  // step through each digit then increment
  // the counter by one, until nine
  for (int j = 0; j < 10; j++) {
    Serial.println(j);
    updateShiftRegister(0, j);
    delay(1000);
  }
}

void updateShiftRegister(int col, int num)
{
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, B00000101);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[num]);
  digitalWrite(latchPin, HIGH);
}
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 10, 2018, 09:09 pm
the result is it's brighter than I use under 9volt
The only way to supply power to the board is through the connector. The connector supplies power to the 74hc595 chips directly. The maximum voltage of those chips is 6V. By connecting a 9V supply, you may have damaged the chips. If you want my continued help, explain what else you have done that you have not already described. I do not wish to waste my time writing code for a board that is already damaged.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 10, 2018, 09:12 pm
this may result and the unfinishing code
Please try to speak better English, I did not understand what you just said. Please post any code  correctly, according to form guidelines in the sticky post.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 10, 2018, 09:15 pm
this is the seven segment picture with 9volt,
sorry, I have not explained that 9 volts I share with lcd and other devices.  
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 10, 2018, 11:45 pm
(https://forum.arduino.cc/index.php?action=dlattach;topic=534044.0;attach=248801)
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 11, 2018, 05:40 am
@paulRB, can you still help me?
if dont bother you, i hope you give me the sample code please.
tell me if you need more information.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 11, 2018, 09:31 am
Does the code you posted produce the digits shown in your picture? Do the digits change as the code runs?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 11, 2018, 11:05 am
my code is not working properly, still confused specify the position of digit, and I can not specify the columns and rows of each segment
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 11, 2018, 11:27 am
You keep asking if you are bothering me. It bothers me when you ignore a question that I ask.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 11, 2018, 12:03 pm
Here is some code to try:
Code: [Select]
int latchPin = 10;
int clockPin = 9;
int dataPin = 8;

// digits from the right
const byte digit[10] =      //seven segment digits in bits
{
  B10000001,  // 0
  B11110011,  // 1
  B01001001,  // 2
  B01100001,  // 3
  B00110011,  // 4
  B00100101,  // 5
  B00000101,  // 6
  B11110001,  // 7
  B00000001,  // 8  fix
  B00100001,  // 9
};

byte displayBuffer[3][6] =    //digit to display in each position
{
  {0, 1, 2, 3, 4, 5},
  {0, 0, 2, 4, 6, 8},
  {0, 1, 3, 5, 7, 9}
};


void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
}

void loop()
{
  updateShiftRegister();
}

void updateShiftRegister()
{
  // "static" variables do not loose their value when the function ends
  static unsigned long lastUpdateTime; // time from millis() when the dispaly was last updated
  static byte column; // the column currently being lit

  if (millis() - lastUpdateTime > 3)  // is it time to light the next column?
  {
    digitalWrite(latchPin, LOW);
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << column); // send the column enable mask
    digitalWrite(latchPin, HIGH);

    column++; // next time, we will light the next column
    if (column > 5) column = 0;
    lastUpdateTime = millis();
  }
}

It is unlikely that it will work correctly at the first attempt. I do not have your display and cannot test the code. I must rely on you to test it. This means you must be accurate and detailed in your description of any faults. Pictures, even video, may be useful.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 11, 2018, 12:34 pm


forgive me if I made a mistake in this post, ok paul, I will try the example code you provided,
I'm trying to learn and develop this code.
If successful or not successful then I will tell you in this forum.

best regards for you
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 12, 2018, 11:51 pm
What was the result of testing my suggested code?

Are you going to post that schematic you received from the vendor? You should explain how the schematic is incorrect.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 13, 2018, 05:06 pm
@paulRB Sorry for the late reply,
I've tried the code you provided, but still not working (later show the picture), the vendor said the scheme was never published because it is still a beta version and say that schematic correct.
I was told to wait for the release version for 2 weeks later.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 13, 2018, 05:52 pm
...say that schematic correct.
Remember those transistors that you checked with your meter and found out they were PNP? Where are they on the schematic?!?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 13, 2018, 06:18 pm
yes, the vendor make me crazy !!!,,,

I think, I had to wait for 2 weeks for the answer.


thanks PaulRB for u support...
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 13, 2018, 08:07 pm
Anyway, you have not yet explained what happens when you run that code I have you.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 14, 2018, 06:33 am
this is result with your code


Code: [Select]
https://youtu.be/cgQGx81rPo8
Code: [Select]
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 14, 2018, 07:37 am
You don't use code tags to post links, you use link tags, like this (https://youtu.be/cgQGx81rPo8). Did you read the forum guidelines yet? Please do that.

And why have you not posted that schematic? You only do half the things that I ask!
(https://forum.arduino.cc/index.php?action=dlattach;topic=534044.0;attach=249376)

Try this
Code: [Select]

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column+1)); // send the column enable mask
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    digitalWrite(latchPin, HIGH);
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 15, 2018, 04:09 am
paulRB, this is second result.


Code: [Select]
int latchPin = 4;
int clockPin = 3;
int dataPin = 2;

// digits from the right
const byte digit[10] =      //seven segment digits in bits
{
  B10000001,  // 0
  B11110011,  // 1
  B01001001,  // 2
  B01100001,  // 3
  B00110011,  // 4
  B00100101,  // 5
  B00000101,  // 6
  B11110001,  // 7
  B00000001,  // 8  fix
  B00100001,  // 9
};

byte displayBuffer[3][6] =    //digit to display in each position
{
  {0, 1, 2, 3, 4, 5},
  {0, 1, 2, 3, 4, 5},
  {0, 1, 2, 3, 4, 9}
};



void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
 
}

void loop()
{
 
  updateShiftRegister();

}

void sevoff() {
  static byte column; // the column currently being lit
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 5)); // send the column enable mask
  for (byte row = 0; row < 3; row++) // update each row for the current column
  {
    shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// send the segment data for each row

  }
  digitalWrite(latchPin, HIGH);
}

void test() {
  static byte column; // the column currently being lit
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 0)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[1]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[1]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[1]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 1)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[2]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[2]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[2]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 2)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[3]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[3]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[3]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 3)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[4]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[4]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[4]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 4)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[5]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[5]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[5]);
  digitalWrite(latchPin, HIGH);
  delay(1000);
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 5)); // send the column enable mask
  shiftOut(dataPin, clockPin, MSBFIRST, digit[6]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[6]);
  shiftOut(dataPin, clockPin, MSBFIRST, digit[6]);
  digitalWrite(latchPin, HIGH);
}



void updateShiftRegister()
{
  // "static" variables do not loose their value when the function ends
  static unsigned long lastUpdateTime; // time from millis() when the dispaly was last updated
  static byte column; // the column currently being lit

  if (millis() - lastUpdateTime > 3)  // is it time to light the next column?
  {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column+1)); // send the column enable mask
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    digitalWrite(latchPin, HIGH);

    column++; // next time, we will light the next column
    if (column > 5) column = 0;
    lastUpdateTime = millis();
    delay(1000);
  }
}



video
https://youtu.be/4UjsA-2mpME (https://youtu.be/4UjsA-2mpME)
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 15, 2018, 07:35 am
Interesting, but not what I wanted to see. I wanted to see if the code I gave you worked. That video shows the code you added running. I can see why your code does not light the leftmost digit.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 15, 2018, 08:01 am
Interesting, but not what I wanted to see. I wanted to see if the code I gave you worked. That video shows the code you added running. I can see why your code does not light the leftmost digit.
agree, your code almost right.
the light can't show the leftmost digit, how can i solved this?

maybe can you show me the code if the case is:

Row 1 (top, with 6 digits) show number "123.456"
Row 2 (middle with 4 digit) show "78.90"
Row 3 (bottom, with 5 digit) show "12.456"

thanks PaulRB, you are the Real Master..



Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 15, 2018, 11:58 am
Did you make the change I suggested in post #33? I hoped that would fix the leftmost digit.

If you take my code from post #25 and add the changes from post #33, what digits do you see displayed?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 15, 2018, 12:29 pm
Did you make the change I suggested in post #33? I hoped that would fix the leftmost digit.

If you take my code from post #25 and add the changes from post #33, what digits do you see displayed?
I've changed the code in the post #25,
and add the code in the post #33. the result is like in the video above, the display show a number from Array of displayBuffer are vertical not of horizontal.

Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 15, 2018, 12:36 pm
paulRb, one more question of new case,

how to hold the first number in first digit, and the second digit show a second number, i've a trouble to keep first digit. show only a second digit from two number. can u give me simple code to keep/hold that first number in first digit?

or

maybe can you show me the code if the case is:

Row 1 (top, with 6 digits) show number "123.456"
Row 2 (middle with 4 digit) show "78.90"
Row 3 (bottom, with 5 digit) show "12.456"

I'm trying to learn the code.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 15, 2018, 02:06 pm
I've changed the code in the post #25,
and add the code in the post #33. the result is like in the video above
No, it is not. I am not stupid. I can see that the video is not my code running. It is your code running. I said that in post #35. I asked you to describe what happens when you run my code. Until you do as I ask, I will give you no more help.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 15, 2018, 02:48 pm
sorry paul, Why should I lie to you?

Code: [Select]
int latchPin = 4;
int clockPin = 3;
int dataPin = 2;

// digits from the right
const byte digit[10] =      //seven segment digits in bits
{
  B10000001,  // 0
  B11110011,  // 1
  B01001001,  // 2
  B01100001,  // 3
  B00110011,  // 4
  B00100101,  // 5
  B00000101,  // 6
  B11110001,  // 7
  B00000001,  // 8  fix
  B00100001,  // 9
};

byte displayBuffer[3][6] =    //digit to display in each position
{
  {0, 1, 2, 3, 4, 5},
  {0, 1, 2, 3, 4, 5},
 {0, 1, 2, 3, 4, 5},
};



void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
 
}

void loop()
{
 
  updateShiftRegister();

}

void sevoff() {
  static byte column; // the column currently being lit
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column + 5)); // send the column enable mask
  for (byte row = 0; row < 3; row++) // update each row for the current column
  {
    shiftOut(dataPin, clockPin, MSBFIRST, B00000000);// send the segment data for each row

  }
  digitalWrite(latchPin, HIGH);
}


void updateShiftRegister()
{
  // "static" variables do not loose their value when the function ends
  static unsigned long lastUpdateTime; // time from millis() when the dispaly was last updated
  static byte column; // the column currently being lit

  if (millis() - lastUpdateTime > 3)  // is it time to light the next column?
  {
    // form code post#25
    //digitalWrite(latchPin, LOW);
    //for (byte row = 0; row < 3; row++) // update each row for the current column
    //{
      //byte d = displayBuffer[row][column]; // get the required digit for this row & column
      //shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    //}
    //shiftOut(dataPin, clockPin, MSBFIRST, 1 << column); // send the column enable mask
    //digitalWrite(latchPin, HIGH);
    //end code post #25

    //from code post #33
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column+1)); // send the column enable mask
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    digitalWrite(latchPin, HIGH);
    //end code post #3
    delay(1000);

    column++; // next time, we will light the next column
    if (column > 5) column = 0;
    lastUpdateTime = millis();
  }
}


 


video test 3
https://youtu.be/f23rSsLLO0E (https://youtu.be/f23rSsLLO0E)?
   
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 15, 2018, 08:17 pm
Ok.

Change this line:
Code: [Select]

    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column+2)); // send the column enable mask
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 04:07 am
this is the test 5, i changed from post#42


Code: [Select]
int latchPin = 4;
int clockPin = 3;
int dataPin = 2;

// digits from the right
const byte digit[10] =      //seven segment digits in bits
{
  B10000001,  // 0
  B11110011,  // 1
  B01001001,  // 2
  B01100001,  // 3
  B00110011,  // 4
  B00100101,  // 5
  B00000101,  // 6
  B11110001,  // 7
  B00000001,  // 8  fix
  B00100001,  // 9
};

byte displayBuffer[3][6] =    //digit to display in each position
{
  {1, 1, 1, 1, 1, 1},
  {2, 2, 2, 2, 2, 2},
  {3, 3, 3, 3, 3, 3},
};



void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);


}

void loop()
{
  updateShiftRegister();
}


void updateShiftRegister()
{
  // "static" variables do not loose their value when the function ends
  static unsigned long lastUpdateTime; // time from millis() when the dispaly was last updated
  static byte column; // the column currently being lit

  if (millis() - lastUpdateTime > 3)  // is it time to light the next column?
  {
    //from code post #33
    digitalWrite(latchPin, LOW);
    //from code post #42
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column+2)); // send the column enable mask //coloum
    for (byte row = 0; row < 3; row++) // update each row for the current column
    {
      byte d = displayBuffer[row][column]; // get the required digit for this row & column
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]); // send the segment data for each row
    }
    digitalWrite(latchPin, HIGH);
    //end code post #33

    column++; // next time, we will light the next column
    if (column > 6) column = 0;
    lastUpdateTime = millis();
  }
}




the video result is
https://youtu.be/i5ftj0wx1Pg (https://youtu.be/i5ftj0wx1Pg)



Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 16, 2018, 08:04 am
You changed this line:
Code: [Select]

    if (column > 6) column = 0;

but I do not think correcting that will fix the display.

Did you make other changes that I have not detected?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 16, 2018, 08:20 am
Put that delay(1000) back into updateShiftRegister(). Check that each column lights in turn, on all 3 rows. Then reduce to delay(500), then delay(250), delay(125), delay(63) and so on. At what point does the display to crazy like in your last video?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 08:23 am
yes i change, length of digit is 6 digit/rows,
and i change to this value too:

Code: [Select]
byte displayBuffer[3][6] =    //digit to display in each position
{
  {1, 1, 1, 1, 1, 1},
  {2, 2, 2, 2, 2, 2},
  {3, 3, 3, 3, 3, 3},
};
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 16, 2018, 08:26 am
I said, in a much easier post, that I think there are components missing from your board. I am beginning to think that might be part of the problem. Very close to each shift register chip, there are two holes. Can you solder 0.1uF ceramic capacitors there?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 08:28 am
Put that delay(1000) back into updateShiftRegister(). Check that each column lights in turn, on all 3 rows. Then reduce to delay(500), then delay(250), delay(125), delay(63) and so on. At what point does the display to crazy like in your last video?
What this case is called the flicker/ghosting/dimming?

oke. i'll try your advise to add delay for each column
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 16, 2018, 08:30 am
yes i change, length of digit is 6 digit/rows,
The length of the array is 6 but the indexes are 0 to 5. So 6 is not a valid index.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 08:43 am

I said, in a much easier post, that I think there are components missing from your board. I am beginning to think that might be part of the problem. Very close to each shift register chip, there are two holes. Can you solder 0.1uF ceramic capacitors there?
oke, i'll do that
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 09:24 am
hi PaulRB, All Problem Solved. flicker solved by change a power+Gnd to 5V from Arduino power pin  :)

result pic:
(https://drive.google.com/file/d/1oEGx-zav311OQriC4QAF6MqM2VrxExm3/view?usp=sharing)

and the working code is from you.

Code: [Select]

int latchPin = 4;
int clockPin = 3;
int dataPin = 2;

const byte digit[11] =      //seven segment digits in bits
{
  B10000001,  // 0  129 0x81
  B11110011,  // 1  243 0xF3
  B01001001,  // 2   73 0x49
  B01100001,  // 3  97 0x61
  B00110011,  // 4  51 0x33
  B00100101,  // 5  37 0x25
  B00000101,  // 6  5 0x5
  B11110001,  // 7  241 0xF1
  B00000001,  // 8  1 0x1
  B00100001,  // 9  33 0x21
  B11111111,  // BLANK
};

byte displayBuffer[3][6] =    //digit to display in each position
{
  {2, 2, 2, 2, 2, 2},
  {0, 0, 6, 7, 8, 9},
  {0, 1, 2, 3, 4, 5},
};

void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
}

void loop()
{
  updateShiftRegister();
}
static unsigned long lastUpdateTime; // time from millis() when the dispaly was last updated
static byte column; // the column currently being lit

void updateShiftRegister()
{
  if (millis() - lastUpdateTime > 0)
  {

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 1 << (column));
    for (byte row = 0; row < 3; row++)
    {
      byte d = displayBuffer[row][column];
      shiftOut(dataPin, clockPin, MSBFIRST, digit[d]);
    }
    digitalWrite(latchPin, HIGH);
    column++;
    if (column > 5) column = 0;
    lastUpdateTime = millis();
  }
}


thanks for God and you PaulRB...
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 16, 2018, 10:45 am
(https://forum.arduino.cc/index.php?action=dlattach;topic=534044.0;attach=249651)
Great news.

So what power supply was it using when the flickering was happening?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 11:52 am
i used this paul, the site tell the 9V 1A Power Adapter for Arduino (2-Flat-Pin Plug / 100CM Cable)

(http://img.dxcdn.com/productimages/sku_126288_1.jpg)

Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 16, 2018, 03:31 pm
Was that powering the display directly when it was flickering? The display does not seem to have its own voltage regulator. 9V could have fried it. Or did you power the Arduino with that PSU and then power the display from the 5V pin on the Arduino? The Arduino's regulator may have been overloaded.

And you are powering the Arduino and display from USB power now?
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 05:06 pm
Was that powering the display directly when it was flickering? The display does not seem to have its own voltage regulator. 9V could have fried it. Or did you power the Arduino with that PSU and then power the display from the 5V pin on the Arduino? The Arduino's regulator may have been overloaded.

And you are powering the Arduino and display from USB power now?
yes, the display flickering when connect to Adapter 9V. now, i don't use that adapter. Arduino only use USB cable power from my USB Laptop.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: PaulRB on Mar 16, 2018, 05:32 pm
yes, the display flickering when connect to Adapter 9V.
Yes, you must use a regulated 5V supply with the display. I think you were very lucky that the display was not permanently damaged by connecting it to a 9V supply. 9V exceeds the safe limit for the chips and leds on the display.
Title: Re: Having trouble controlling 3 Row Seven Segment with 4 shift register 74hc595
Post by: zifank on Mar 16, 2018, 06:55 pm
Ok PaulRB. thanks for everything..

but I've one problem again, i've a one Water Flow sensor connect to Arduino with pin 11, the sensor result is work perfectly on arduino uno or mega.
but when i try to upload with USBasp to Atmega32 in pin PD3. the sensor can't show the flow sensor result.
how to solved this? this problem stuck from two month ago.  :smiley-confuse:

(maybe, i must change/move this post to sensor category post)