Pages: [1]   Go Down
Author Topic: 4 digit display flickering  (Read 1101 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi. I´ve been trying to make a timer. I´m using a 4 digit, 8 segment per digit, display. Handled with a 4051 multiplexer.
I was able to display the numbers individualy. However, when I try to display in every digit at once, it starts flickering and distortioning the numbers.
It´s made with the simple functions present in Arduino UNO r3. I´ve found that it can be fiked with bit angle modulation, but I wasn´t able to found anything within my level.
I´d really apreciate your help, and if any of you could post a link of a BAM tutorial (the simpler the better) it´d be awsome.

Here it is the function for the number 8, which is the one that flickers the most

Code:
void Timer::eight(){
  digitalWrite(A,HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,LOW);
  delay(2);
  digitalWrite(A,LOW);
  digitalWrite(B,HIGH);
  digitalWrite(C,LOW);
  delay(2);
  digitalWrite(A,HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,LOW);
  delay(2);
  digitalWrite(A,LOW);
  digitalWrite(B,LOW);
  digitalWrite(C,HIGH);
  delay(2);
  digitalWrite(A,HIGH);
  digitalWrite(B,LOW);
  digitalWrite(C,HIGH);
  delay(2);
  digitalWrite(A,LOW);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  delay(2);
  digitalWrite(A,HIGH);
  digitalWrite(B,HIGH);
  digitalWrite(C,HIGH);
  delay(2);
    }
 

These are the functions for picking the digit to turn on and picking the number to display.

Code:
int Timer::pickDigit(int x){

  digitalWrite(powa, LOW); // dig 1
  digitalWrite(powb, LOW); // dig 2
  digitalWrite( powc, LOW); // dig 3
  digitalWrite( powd, LOW); // dig 4

  switch(x){
    case 1: digitalWrite(powa, HIGH); break;
    case 2: digitalWrite(powb, HIGH); break;
    case 3: digitalWrite(powc, HIGH); break;
    case 4: digitalWrite(powd, HIGH); break;
  }
}

int Timer::pickNumber(int x){
    switch(x){
     case 1: one(); break;
     case 2: two(); break;
     case 3: three(); break;
     case 4: four(); break;
     case 5: five(); break;
     case 6: six(); break;
     case 7: seven(); break;
     case 8: eight(); break;
     case 9: nine(); break;
     default: zero(); break;
   }
}

And this is the function for displaying 4 numbers at once

Code:
void display(int a,int b,int c,int d){
  timer.pickDigit(1);
  timer.pickNumber(a);
 
  timer.pickDigit(2);
  timer.pickNumber(b);
 
  timer.pickDigit(3);
  timer.pickNumber(c);
 
  timer.pickDigit(4);
  timer.pickNumber(d);
 
 
}


I uploaded the datasheet of the multiplexer for you to check it out if necesary.

Thank you in advance.

* 397652_DS.pdf (347.74 KB - downloaded 34 times.)
Logged

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 1480
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi lolo,

Its very difficult to figure out how your design is intended to work without a full code listing and a schematic. But it seems to me you are trying to multiplex 4 digits one segment at a time, instead of the normal one digit at a time. If true, this will be very flickery!

Paul
Logged

Offline Offline
Faraday Member
**
Karma: 69
Posts: 2866
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have to use a 4051 you will see this phenomena.

A MAX7221 may  be the way to go. (up to eight digits per chip).   SPI (3 pins)

Logged

The way you have it in your schematic isn't the same as how you have it wired up! That goes for me too.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your answers.
I will try to work on what you suggest. But,is it possible to make some code changes  in order to improve the speed of the displaying of the numbers?
I had to add some delays on the number functions, and I think if I were able to remove them, it would work fine.
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19350
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Eight would flicker the most because it has the most delays?

You can probably rework it to have a state machine, and eliminate delays.

http://www.gammon.com.au/blink
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 1480
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi lolo, no I don't think improving the code will help very much. Removing the delays will reduce the flickering, but the display will be quite dim. The problem is that your "multiplexing ratio" is 1:32. You need to aim for 1:4 or 1:8 ideally.

Do you have 3 more Arduino outputs available? If so, you could use your 4051 to select one digit at a time and the Arduino pins to control the segments. You would also need 4 transistors, or a ULN2003/2803 to handle the larger currents on the common anodes/cathodes.

Paul
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried lowering the delay, but the display was really dim as Paul said.
I attached a rough schematic of the circuit I intend to do and some information of the 4051 and the display. I haven´t made the code for the countdown yet, because I focused on this.
I hope this give you a better idea of what I try to do.

* timer schematic.pdf (744.06 KB - downloaded 42 times.)
Logged

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 1480
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It still looks like you are set up to multiplex one segment at a time instead of one digit.

Where are your series resistors for the segments?

Would also suggest a 0.1uF cap accross the 4051's power pins.

Paul
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I did not include them in the schematic. What would be the capacitor function?
And I tried to figure how to multiplex an entire digit, but I couldn´t.
Would it be to much if I ask for an example or a link? I do not know how to work with bytes, and I´ve seen some examples that the multiplexing is managed with bites instead of digitalWrite.
Logged

West Yorkshire, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 1480
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi lolo, I have been having a think...

I think you could do 1:8 multiplex with this chip with a bit of lateral thinking. Actuall not too different from your original question, but turned on its head a little.

The main problem is the max current of 25mA of the 4051 and the Arduino outputs. Do you have a uln2803? Or 8 transistors?

Remind me: is the led display common cathode or anode?

Oh, the cap is just for "decoupling". Its a good idea to have one for every chip in any of your designs, as a matter of habbit. They satisfy any short increases in current required by the chip instead of causing interference to other parts of the circuit via the power rails.

Paul
« Last Edit: July 30, 2013, 03:12:36 pm by PaulRB » Logged

Pages: [1]   Go Up
Jump to: