Pages: [1]   Go Down
Author Topic: Sourcing and sinking question  (Read 778 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all.

I'm still very much a newbie when it comes to electronics in general let alone Arduino and I'm struggling to understand some measurements I took on my latest tinkering.

I have a 2 digit 7 segment LED. It has 10 pins, two of which are for the common anodes and the rest are for the cathodes. I added the LED to a breadboard and connected each cathode through it's own 330R resistor to a digital pin. I hooked up the common anode pins to two other digital pins.

The sample sketch I had rapidly switches between illuminating segments in each digit with a delay of 2ms to give the illusion that both are powered at the same time.

Only yesterday I started reading about sinking and sourcing current as well as the current limitations of the digital pins and the max combined current. I was concerned that I was drawing too much current through the two pins connected to the anodes especially as I found plenty of examples where people have used transistors to power the LEDs rather than draw current from the digital pins.

Sorry for the long preamble and on to the question. This morning I measured the current on each of the Arduino pins supplying current to each common anode and found that it ranged up to a maximum of around 16-17mA for each pin with this highest value of course being found when displaying an 8 and all segments of that digit were lit. I was somewhat relieved as this is well below the recommended 20mA per pin, let alone the max of 40mA. I then measured current on one of the cathodes as it enters a digital pin (sinking the current) and found it varied up to a max of around 5.5mA. This is what is confusing me. If there are 8 cathodes (only using 7 as no decimal point used), why isn't the current at the cathode a proportion of the input current? E.g if all segments were lit and all segments showed current similar to the one cathode pin I measure, then surely that would be 5.5mA x 8 = 44mA spread across the 8 pins. So how is the input current on one of the anode pins only around 17mA but the potential output of all cathode pins is around 44mA? Is it because a digital mulimeter isn't fast enough to show the differences as it is rapidly turning on the corresponding segments in each display and is therefore showing a higher current, or could it be the way I'm measuring the current (interrupting the circuit and placing the multimeter probes in line, or is it the sinking of the current?

As I say, I'm new to electronics and I'm clearly not understanding one of the basic concepts so I may have asked a really stupid question!  smiley-roll-sweat
Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2144
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is it because a digital mulimeter isn't fast enough to show the differences as it is rapidly turning on the corresponding segments in each display and is therefore showing a higher current
Yes

With a a question like this, it is advantageous to attach a schematic diagram so it can be easily visualized (especially for us older guys).
 
Logged

Montreal
Offline Offline
Edison Member
*
Karma: 23
Posts: 2485
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it varied up to a max of around 5.5mA.
What do you mean "varied"? IMHO, your measurements about right for red LED's , you can get ~5 mA if only one segments lights up. Turning all 7 on, current would drop ,as voltage at the output pin wouldn't be 5 anymore, but 4.2V at 20 mA. Try to measure a voltage at output digital common pin, and see what you get when you lighting up all 7 segments. Also, switch to 1 digit to neglect duty cycle affects. If your readings <4.2 or (2.1V with 2 digits), you're abusing IC
Logged

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

Thanks for the replies.

I don't have a proper schematic yet. I'll try and create one. Here are some pictures of the setup on a breadboard though plus a schematic of the LED module itself.

Magician. I took your advice of only using one digit to take out any duty cycle effects. Measuring the current on one of the cathode pins (pin 10 - A - top segment) with only one digit shows up to 3.3mA. It still does vary though depending on how many segments are lit but never exceeds 3.3 (when displaying a 7 for some reason).

I'm not sure if I'm measuring the voltage at the right point but I tried measuring from pin 10 on the Arduino (common anode for one digit) to pin 2 on the Arduino (cathode for segment A). When 8 is displayed it reads 2V. This is of course across the resistor connected to the cathode and the LED segment.


* IMAG0208.jpg (1381.16 KB, 3264x1840 - viewed 22 times.)

* IMAG0209.jpg (1499.65 KB, 3264x1840 - viewed 18 times.)

* LED_Dual.jpg (18.44 KB, 403x132 - viewed 19 times.)
Logged

Valencia, Spain
Online Online
Faraday Member
**
Karma: 118
Posts: 4541
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Multimeters can't measure a pulsed current, no.

In the case of the common anode, which is nearly always "on", the current reading is probably close. The cathodes, which are only on about 1/8th of the time, not a chance.

To measure the current there you'd have to look at the voltage drop across the current limiting resistors on an oscilloscope and use Ohm's law.
Logged

No, I don't answer questions sent in private messages...

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

Hi Fungus. When you say the cathodes are pulsed, would that be done by the LED unit itself? The only pulsing I'm aware of in the actual sketch is rapidly alternating the two anode pins every 2ms to change between the two digits.

Here is an extract of the code:

Code:
void loop()
{
  tNow = millis();
  if(tNow - tPrev > millisecondspercount)
  {
    tPrev = tNow; 
    counter++;
    if(counter >= maxValue)
      counter = 0;
  }
  int count = counter;
  // Display the digits using multiplexing (only one digit displayed at a time)
  for(int i = 0; i < NumberDigits; i++)
  {
    showdigit(i, count%10);
    delay(2);
    count = count/10;
  }
}
Logged

Valencia, Spain
Online Online
Faraday Member
**
Karma: 118
Posts: 4541
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only pulsing I'm aware of in the actual sketch is rapidly alternating the two anode pins every 2ms to change between the two digits.

NOW you tell us...

In that case the current at the cathodes will be fairly close to constant, and you're killing your Arduino (5.5mA x 8 is too much).
« Last Edit: April 30, 2013, 03:13:09 pm by fungus » Logged

No, I don't answer questions sent in private messages...

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

I did mention that in the original post!  smiley-razz

Could you please explain how it is too much? This is only 5mA per pin being sunk with each cathode on it's own pin. As I understand it, each digital pin can source or sink current up to a max of 40mA and also 5.5mA is nowhere near the overall current limit. Just to reiterate, the anode pins are only showing a current of around 17mA each - again well within the limits.

I just couldn't understand why the current shown at the cathodes was slightly higher than that shown at the anode. I.e. 3.3mA (for one segment of one digit) x 7 = 23.1mA(across 7 Arduino pins) but the anode current is around 17mA.
Logged

Valencia, Spain
Online Online
Faraday Member
**
Karma: 118
Posts: 4541
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to reiterate, the anode pins are only showing a current of around 17mA each - again well within the limits.

Just to reiterate, you cannot measure a pulsed current with a multimeter.

Logged

No, I don't answer questions sent in private messages...

Pages: [1]   Go Up
Jump to: