## 4 digits 7 segments

grptx
Posts: 15
Joined: Sat Jun 17, 2017 10:37 am

### 4 digits 7 segments

Hi all,
i'm a total beginner so please be patient with me.

i'm trying to display 4 digits on a 4*7 segments display using a ranspberry pi 3 using as example this tutorial
https://www.hackster.io/davek17/rpi-7-s ... 1ic-8972f5

but I have a strange behavior when a i switch between the digits. i made this video to explain my issue:

here my code:

Code: Select all

``````void *displayDigits (void *dummy)
{
uint8_t digit ,i;
uint8_t index, d ;
int delay = 150000;
for (;;)
{
for (digit = 0 ; digit < 4 ; ++digit)
{
d = toupper (digits [digit]) ;
index = d - '0' ;
for(i=0;i<4;i++){
digitalWrite (segments_ar[i], bcdD [index * 4+(3-i)]) ;
}

digitalWrite (digits_arr[digit], 1);
delayMicroseconds (delay);

digitalWrite (digits_arr[digit], 0);
if(delay>10000) {
delay-=500;
printf("delay :%d\n",delay);
}

}
}
}``````
In practice reducing the delay time until all 4 digits are displayed some of unexpected happens

here the components i using

C library: http://wiringpi.com/reference/
BCD : http://www.datasheetcatalog.com/datashe ... 11BC.shtml
transistors: https://www.onsemi.com/pub/Collateral/BC337-D.PDF
7 segments display: http://www.peterparts.com/CatalogPages/57/1023.pdf

rzusman
Posts: 309
Joined: Fri Jan 01, 2016 10:27 pm

### Re: 4 digits 7 segments

You need to scope the outputs to determine exactly what is happening, but I’d bet that the rise or fall times of your outputs are too slow, and so multiple transistors are being turned on.

grptx
Posts: 15
Joined: Sat Jun 17, 2017 10:37 am

### Re: 4 digits 7 segments

here my schematic: http://www.enslavedcoder.org/sketch.jpg

about the timing I gradually decreased the delay in my code to find the optimal value

Code: Select all

``````digitalWrite (digits_arr[digit], 1);
delayMicroseconds (delay);

digitalWrite (digits_arr[digit], 0);
if(delay>10000) {
delay-=500;
printf("delay :%d\n",delay);
}``````
I thought the correct value was about 16000 µs (60hz) but with this delay the digits are still overlapping and flickering

the problem can be the values of resistors on the base of transistors? (i using 1k now)

drgeoff
Posts: 8094
Joined: Wed Jan 25, 2012 6:39 pm

### Re: 4 digits 7 segments

Try 220 ohm base resistors as in the tutorial.

grptx
Posts: 15
Joined: Sat Jun 17, 2017 10:37 am

### Re: 4 digits 7 segments

I use 220 ohm between the bcd 4511 and the display and 1k ohm between the raspberry and the transistor .. as in the tutorial

DougieLawson
Posts: 32723
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

### Re: 4 digits 7 segments

Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

grptx
Posts: 15
Joined: Sat Jun 17, 2017 10:37 am

### Re: 4 digits 7 segments

i have already did this project, but now i wish to use the bcd to reduce the GPIO lines

grptx
Posts: 15
Joined: Sat Jun 17, 2017 10:37 am

### Re: 4 digits 7 segments

I solved by connecting the 4511 IC LE pin to ground