Trying to understand calculating circuit current usage

Discussion in 'The Projects Forum' started by AverageJoe, Apr 28, 2016.

  1. AverageJoe

    Thread Starter New Member

    Apr 12, 2016
    8
    1
    Hello AAC,

    I am playing with circuits and the Raspberry Pi, trying to understand voltage and current, and how to safely interface with a device that has limits to such things (i.e. the Raspberry Pi).

    For those who haven't played with a Raspberry Pi, there is a 40-pin header called the GPIO (General Purpose Input Output) that allows outside circuitry to be connected and manipulated via programs running on the Raspberry Pi (typically some variant of Linux). Each data pin is capable of being set to either input or output, and operates at 3.3 volts.

    The Raspberry Pi, from what I can gather from available information, has a current limit of 16mA per GPIO pin, and 50mA for the header as a whole.

    I have built a circuit that I *think* is safe for the Raspberry Pi, but I'd like to post my calculations and get your opinions. I have done a lot of research, but I still have many questions.

    I salvaged a really neat 3-digit 7-segment display from an old MIDI controller, and decided to try to use it with the Raspberry Pi - it is pictured in image_a. The component is labeled E1-3056AUG1, and although I could only find a datasheet for an E1-3056CUY1, it was close enough to allow me to get things going. I learned that the "A" in AUG is for common anode (versus common cathode in the datasheet I found), and the "UG" is ultra green. If the values are similar to the "CUY" datasheet, I should be looking at a forward voltage of about 1.8v (2.3v max).

    So, to light this thing up from the Raspberry Pi, I need to use one of the 3V3 pins with a resistor per digit's common anode. Using the 1.8v spec from the datasheet, I used the following calculation to determine the proper resistance. I was hoping to use around 10mA per each of the three pins.

    (Vsup - Vled) / current = (3.3 - 1.8) / 0.010 = 150 ohm resistor

    I ended up using 120 ohm resistors, so the current per pin should actually be about 12.5mA, still comfortably below the 16mA per pin limit. Since I have three common anodes to power, that's 37.5mA total draw from the header.

    OK, so now I need to put transistors on the other pins and control them with 8 more GPIO pins (segments a - g plus the decimal), but I need to keep the combined current draw below 12.5mA.

    This is where I'm having trouble.

    I'm using NPN transistors for this, since it's a common anode display, and I went with 8 BC574B transistors. I *think* I want to look at the "Base Emitter Saturation Voltage" number on the datasheet? Since it reads 0.7v for Ic @ 10mA / Ib @ 0.5mA, this was closest to my case and I used that in the same calculation.

    Is it correct to use the same formula to determine the resistors I need to keep the current down? For example, if I wanted 1mA draw:

    (Vsup - Vbe) / current = (3.3 - 0.7) / 0.001 = 2,600 ohms

    I ended up using 2,200 ohm resistors, so by the same calculation the current draw should be 1.18mA each pin, or 9.44mA for all eight segment transistors. Added to the 37.5 mA for the 3 common anodes, that's 47.34mA, and safely under my 50mA header max current draw.

    The attached image_b is the breadboard with the salvaged E1-3056AUG1, connected to the Raspberry Pi GPIO pins. Everything seems to work, but I'm super paranoid about this stuff, so I wanted to run it by you all.

    Am I looking at transistors correctly when trying to calculate current? Am I on the right track with this stuff, or am I off base to some degree?

    Thanks for reading!

    image_a.jpg image_b.jpg
     
  2. ronv

    AAC Fanatic!

    Nov 12, 2008
    3,281
    1,232
    Sounds good to me.:)
     
  3. dannyf

    Well-Known Member

    Sep 13, 2015
    1,768
    357
    Those leds are very bright, even at low current levels. So you can actually drive them directly, without any resistor and relying on the mcu's limited current capabilities to do that job.

    Now, that's not a great way to do things but it works.

    A more prudent approach is to use 7/8 resistors on the segments and drive the digit pins directly. Something like 1k for example would give you sufficient current for most applications. It considerably simplifies wiring.
     
  4. dannyf

    Well-Known Member

    Sep 13, 2015
    1,768
    357
    As to how bright those leds can get: it is not hard to find leds that don't materially improve in their brightness above 0.5ma. I typically drive mine at 1-2ma.
     
  5. AverageJoe

    Thread Starter New Member

    Apr 12, 2016
    8
    1
    Thanks, dannyf. Are you driving an entire 7-segment display on 1-2mA? I found that when I went below somewhere around 10mA, displaying numbers that used a lot of segments (like 8, for example), would be noticeably dimmer than numbers that used fewer segments (like a 1).

    Since this is a common-anode type display, I thought that I'd need to feed it enough to account for all segments, then use the segment cathodes to drain/ground the segments that I wanted to display in the current cycle?

    Thanks, ronv! :)
     
    ronv likes this.
  6. AverageJoe

    Thread Starter New Member

    Apr 12, 2016
    8
    1
    I went back and tried a couple of different resistor values for the first digit. Here is the display after using a 1k resistor for the first digit, which should be limiting the current to 1mA.

    7_seg-1000.jpg

    It's actually a lot brighter in the picture than it appeared to my eyes. So I switched to a 680k resistor, which should be 2mA. It was better, but still dim.

    7_seg-680.jpg

    If I play around with the resistors, though, I'll probably be able to find a sweet spot for balancing current with brightness that will lower the overall circuit current even more. Thanks again for the pointers!
     
Loading...