0

First of all,here's the datasheet of the 4 digit 7 segment display that I'm using: http://www.kingbrightusa.com/images/catalog/SPEC/ca56-11ewa.pdf

How can I make a counter or a clock out of this particular led display,considering the fact that I don't have enough digital pins to manipulate led's pins?

2
2

Only need 4, or 5 pins; SCK (D13), MOSI (D11), slave select (D10). Maybe PWM (D9) for brightness. D12 not used, but is tied up as part of SPI bus.

Connect the Anodes to +5.

Connect the cathodes, with a current limit resistor per cathode, to the outputs of 4 TPIC6C595, or TPIC6B595.

For the resistor, assume worst case voltage drop of 2V and 20mA current draw: (5V - 2V)/.02A = 150 phm.

Use a PWM output pin to drive the OE/ pin of the '595s for brightness control.

Then shift data into the daisychained shift registers as an update is needed.

byte dataMap[] = {
0b00111111, // 0 with bits representing DP,g,f,e,d,c,b,a
0b00000110, // 1
0b01011011, // 2
// etc
};

where segments are layed at as

   a
f     b
   g
e     c
   d      DP or colon

then call the array in loop(), make it a function if you want.

digitalWrite (ssPin, LOW); // D10 on Uno, used as Latch signal
for (x = 0; x <4; x=x+1){
SPI.transfer (mapArray[digit0]); // digit0 value mapped to segments
SPI.transfer (mapArray[digit1]);
SPI.transfer (mapArray[digit2]);
SPI.transfer (mapArray[digit3]);
}
digitalWrite (ssPin, LOW); // outputs update on this rising edge

I wonder where DP5, DP6, which make the colon, are? I don't see them in the pinout.

2
  • 595 shift registers don't use SPI. they can be handled ye the SPI peripheral but I think they predate SPI. I use shiftOut Arduino function. arduino.cc/en/Tutorial/ShiftOut
    – Juraj
    Mar 13 '20 at 13:37
  • 2
    I use SPI to load them all the time, goes way faster then shiftout() does. Can even set the SPI clock to 8 MHz (up from the default speed of 4 MHz) to load them crazy fast. Be sure to have a 0.1uF cap at the VCC pin of each device. I usually have the Clear line connected to +5, and OE/ connected to GND unless I am using PWM on the outputs.
    – CrossRoads
    Mar 13 '20 at 14:59
0

As Juraj mentioned, you can use shift registers, such as 74HC595 which uses the SPI protocol.

To elaborate slightly on this:

  • You can cascade 4 shift registers, totaling 32 pins for output
  • If you need 36, you can use the remaining 4 as normal pins (this is probably the easiest solution)
  • Or you can use the Chip/Slave Select feature of SPI to control two chains of shift registers. So e.g. one chain is doing 4 * 8 = 32 pins, the other (single shift register) using 8 pins (from where 4 pins are used only).

To make a clock, use a RTC (Real time clock) module/IC, a counter (unless very high frequency) does not need an external IC.

6
  • 1
    for 4 digits two 74HC595 are enough
    – Juraj
    Mar 13 '20 at 11:29
  • True … wonder where the 36 pins come from (7 digits + 1 dot maybe, is 8 * 4 = 32 pins, one for VCC/GND, but other two ?) Mar 13 '20 at 11:35
  • @MichelKeijzers by 36 I mean:4X7=28 segments 4X1=4 dots,and the other 4 remaining are the pins for the common anode for each digit.
    – Neri-kun
    Mar 13 '20 at 11:47
  • In that case, 32 pins need to be controlled by the shift registers, so 4 shift registers will suffice, and no need for CS/SS, just cascade them. Mar 13 '20 at 12:07
  • 1
    1 and half shiift registers. one for 7 segments and dot and one for digit select. two registers can handle 8 digits. see the tutorial.
    – Juraj
    Mar 13 '20 at 12:16
0

You actually only need 12 pins for that display.

The display is made up of 4 separate common anode LED displays, and you can use that to your advantage.

Since the 4 anode clusters are separate you have the ability to switch an entire digit on or off. And as a result all the cathodes of the segments can be commoned together (that is, the cathodes of all the segment As can be commoned, and the cathodes of all the segment Bs, etc), which is then 8 clusters of 4 cathodes.

That means you can have 4 outputs controlling the for anodes (ideally through PNP transistors or P-channel MOSFETs to handle higher current), and 8 outputs to control all the cathodes (each through a resistor and ideally an NPN transistor or N-channel MOSFET to handle higher current).

The you rapidly switch between each digit displaying the right segment combination for that digit.

Here's a partial example showing 4 digits but just segments A and B. Youd expand this out for segments C through G. GPIO_A1 to GPIO_A4 are activated to select which digit is being displayed. GPIO_CA through GPIO_CG would be to select the arrangement of segments on that digit.

schematic

simulate this circuit – Schematic created using CircuitLab

5
  • Though it should be mentioned, that multiplexing the displays like this will affect the brightness.
    – chrisl
    Mar 13 '20 at 11:59
  • @chrisl True, but with the reduced duty cycle comes the ability to run the LEDs at a higher current, thus somewhat compensating for that.
    – Majenko
    Mar 13 '20 at 12:00
  • @Majenko Are GPIO_A1,GPIO_A2,GPIO_A3 and GPIO_A4,and GPIO_CA,GPIO_CA the NPN,respectively the transistors that you are referring to?If so,I still don't understand how they actually work such that it can manipulate all 4 digits without even turning even one of them off.Also how do I simulate properly your circuit?And I'm asking this because I have never never worked with such online tool before.
    – Neri-kun
    Mar 13 '20 at 12:27
  • Ignore the "simulate this circuit" thing, it's meaningless. The sequence is: 1 .Turn on GPIO_A1. 2. Turn on combination of GPIO_C*. 3. Turn off all GPIO_C*. 4. Turn off GPIO_A1. 5. Turn on GPIO_A2. 6. Turn on combination of GPIO_C*. 7. Turn off all GPIO_C*. 8. Turn off GPIO_A2. Etc...
    – Majenko
    Mar 13 '20 at 15:40
  • If you just want to try out multiplexing. You can leave out all the transistors, and use resistors of at least 1.2kOhm. That way you'd never exceed the 20mA per IO pin on the Arduino, even if all segments of a digit are lid. The downside will be that it will be less bright. Connect all the four common anodes for the four digits (22,23,31,32) to 4 Arduino pins. Then connect all A segments (20,25,29,34) together, and connect that, via a 1.2k resitor to an Arduino pin. Repeat for all segments and the DP. You'd end up using 8 resistors and 12 Arduino pins.
    – Gerben
    Mar 14 '20 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.