Go Down

Topic: Safe: 8-digit 7-segment tube max7219 lcd in 5 digital pins of Uno (Read 565 times) previous topic - next topic

HermannSW

Today I did solder 5 pin angle headers to another max7219 8-digit 7-segment tube lcd.
I followed the instant idea of plugging the 5 pins into D7-D3 and let D7 play 5V, D6 play GND:


Recently I did fork Ozhan's DigitLedDisplay library:
https://forum.arduino.cc/index.php?topic=651696.0

I changed the initial demo only slighty to make it work in described no-cables setup:
Code: [Select]
$ diff -C 2 libraries/DigitLedDisplay/examples/Digit7SegmentDemo/Digit7SegmentDemo.ino ~/Arduino/sketch_dec08a/sketch_dec08a.ino
*** libraries/DigitLedDisplay/examples/Digit7SegmentDemo/Digit7SegmentDemo.ino 2019-12-03 11:09:48.689729347 +0100
--- /home/stammw/Arduino/sketch_dec08a/sketch_dec08a.ino 2019-12-08 11:50:39.789708093 +0100
***************
*** 7,14 ****
     6 to CS,
     5 to CLK */
! DigitLedDisplay ld = DigitLedDisplay(7, 6, 5);
 
  void setup() {
 
    /* Set the brightness min:1, max:15 */
    ld.setBright(10);
--- 7,17 ----
     6 to CS,
     5 to CLK */
! DigitLedDisplay ld = DigitLedDisplay(5, 4, 3);
 
  void setup() {
 
+   pinMode(7, OUTPUT); digitalWrite(7, HIGH);
+   pinMode(6, OUTPUT); digitalWrite(6, LOW);
+   
    /* Set the brightness min:1, max:15 */
    ld.setBright(10);
$
$


It worked fine, but I wanted to know whether it is safe to use Uno D7 as 5V pin.
Uno allows to draw 40mA on digital pins.
I did change brightness to 15 (maximal) and displayed 8 times "8.".
I powered the max7219 module from my constant voltage power supply with 5V and measured the current as permanent 36mA:


So it is safe to do what I did, and plugging a 2nd tube display into D12-D8 at the same time should be safe as well.
Of course I should have measured first ...
αβ, xy & L₁/L₂ positioning systems w/ 2 28BYJ48 steppers:
https://forum.arduino.cc/index.php?topic=649769.0
Caterpillar robots:
https://forum.arduino.cc/index.php?topic=462107.msg3482895#msg3482895
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Paul__B

It worked fine, but I wanted to know whether it is safe to use Uno D7 as 5V pin.
No it isn't!  :smiley-roll-sweat: D6 as ground neither.

Uno allows to draw 40mA on digital pins.
It may allow it - it has no choice after all - and it certainly may appear to work, but that proves nothing,

You are seriously overloading the microcontroller beyond its specifications, so don't come back complaining when things go wrong!  :smiley-eek:

HermannSW

You are seriously overloading the microcontroller beyond its specifications,
Just claiming statements without refrering a spec is not helpful.

We had similar discussion on powering two 28BYJ-48 stepper motors from single Arduino 5V rail.
People claimed that this is beyond specification, but after careful analysis by people it turned out to be safe for USB powered Uno:
https://forum.arduino.cc/index.php?topic=648859.msg4377804#msg4377804

I did show that maximal current draw is 36mA.

Perhaps I made mistake to take specification of Uno from 1st hit by DuckDuckGo which states 40mA per digital IO:
https://components101.com/microcontrollers/arduino-uno

arduino.cc product specifications says only 20mA per digital IO pin:
https://store.arduino.cc/arduino-uno-rev3

So question is which spec is right -- and in my case I did buy 3$ Uno R3 from aliexpress.com years ago, which might be different as well.
αβ, xy & L₁/L₂ positioning systems w/ 2 28BYJ48 steppers:
https://forum.arduino.cc/index.php?topic=649769.0
Caterpillar robots:
https://forum.arduino.cc/index.php?topic=462107.msg3482895#msg3482895
https://stamm-wilbrandt.de/en/Raspberry_camera.html

CrossRoads

40mA Absolute Max comes from the 328P data sheet.  Exceed that (with some variation of resistor value, no current limti into an LED or NPN transistor base, some surge current from an inductive load, a stalled motor) and you can fry a pin and possibly the device:

"*NOTICE: Stresses beyond those listed under "Absolute Maximum Ratings" may cause permanent damage
to the device. This is a stress rating only and functional operation of the device at these or
other conditions beyond those indicated in the operational sections of this specification is not
implied. Exposure to absolute maximum rating conditions for extended periods may affect
device reliability."


If you want to maintain the minimum High Output voltage limits (with Vcc = 5V) of 4.1V to 4.2V, and maximum Low Output voltage limits of 0.9 to 1.0V, (both temperature dependent also) then you need to keep current outputs to 20mA:


Notes: 1. "Max" means the highest value where the pin is ensured to be read as low
2. "Min." means the lowest value where the pin is ensured to be read as high
3. Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not ensured to source current greater than the listed test condition.
4. Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100mA.
2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100mA.
3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100mA.
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not ensured to sink current greater than the listed test condition.


DIP parts have 1 VCC pin, thus there is a 200mA total source current limit.
SMD parts have 2 VCC pins, this the 300mA total source current limit.



DC Current per I/O Pin . . . . . . . . . . . . . . . . . . 40.0mA

DC Current VCC and GND Pins . . . . . . . . . . 200.0mA
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

HermannSW

Thanks for that detailed information.
Whenever the draw of max7219 (measured as 36mA max) would go above 40mA the IO pin is at risk.

> DC Current VCC and GND Pins . . . . . . . . . . 200.0mA
>
I don't buy that, because that was extensively discussed in the forum thread I pointed to:
https://forum.arduino.cc/index.php?topic=648859.msg4377804#msg4377804

There are 450mA available on USB powered Arduino Uno 5V rail.
I make use of that by powering 2(!) stepper motors that draw constant 200mA each in half-stepping mode from single Uno 5V pins:
αβ, xy & L₁/L₂ positioning systems w/ 2 28BYJ48 steppers:
https://forum.arduino.cc/index.php?topic=649769.0
Caterpillar robots:
https://forum.arduino.cc/index.php?topic=462107.msg3482895#msg3482895
https://stamm-wilbrandt.de/en/Raspberry_camera.html

HermannSW

DC Current per I/O Pin . . . . . . . . . . . . . . . . . . 40.0mA
So doing what I described is at the borderline of safe (drawing up to 36mA).

I had to learn the hard way that powering that little display from Raspberry Pi 5V pin was a really bad idea.
I lost the complete GPIO pins of my best Raspberry (Pi4B with 4GB ram) that way -- good that the Pi as well as HDMI output and camera kept working:
https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=258806&p=1577913#p1577913
αβ, xy & L₁/L₂ positioning systems w/ 2 28BYJ48 steppers:
https://forum.arduino.cc/index.php?topic=649769.0
Caterpillar robots:
https://forum.arduino.cc/index.php?topic=462107.msg3482895#msg3482895
https://stamm-wilbrandt.de/en/Raspberry_camera.html

david_prentice

No,  I have not looked at the component values on your module.

The MAX7219 powers up in "test mode" which runs all segments at maximum brightness.    This is a MASSIVE current.

Your LED power should come from a stable power source e.g. USB or external power.
The signal currents are trivial.   You can drive signals with an ARM.

The AVR can provide 20mA via its GPIO pins.   This can work fine with low-current devices like LCD.
Very unwise for a high-current device like your LED module.

David.

HermannSW

The MAX7219 powers up in "test mode" which runs all segments at maximum brightness.    This is a MASSIVE current.
Yes, 8 times "8." at full brightness draws 36mA.

Quote
Your LED power should come from a stable power source e.g. USB or external power.
Agreed for the Raspberry (I use an Uno as stable 450mA 5V power source for Raspberry).

Quote
The AVR can provide 20mA via its GPIO pins.   This can work fine with low-current devices like LCD.
As CrossRoads stated, the absolute max is 40mA.
So doing this is at the borderline of spec, but not above.

I just wanted to know whether my statement on driving two such modules in parallel is right.
And it is, the demo now runs for 30 minutes without issues.
I scaled down the 640x480@10fps smartphone video to 160x120 in order to get animation size <4MB:

Code: [Select]
/* Include DigitLedDisplay Library */
#include "DigitLedDisplay.h"

DigitLedDisplay ld1 = DigitLedDisplay(5, 4, 3);
DigitLedDisplay ld2 = DigitLedDisplay(11, 10, 9);

void setup() {

  pinMode(7, OUTPUT); digitalWrite(7, HIGH);
  pinMode(6, OUTPUT); digitalWrite(6, LOW);

  pinMode(13, OUTPUT); digitalWrite(13, HIGH);
  pinMode(12, OUTPUT); digitalWrite(12, LOW);
 
  /* Set the brightness min:1, max:15 */
  ld1.setBright(10);
  ld2.setBright(10);

  /* Set the digit count */
  ld1.setDigitLimit(8);
  ld2.setDigitLimit(8);
}

void loop() {
  /* Prints data to the display */
  ld1.printDigit(12345678);
  ld2.printDigit(12345678);
  delay(500);
  /* ld.clear(); */

  /* clear space before (negative) number */
  ld1.printDigit(-2222, 0xFF);
  ld2.printDigit(-2222, 0xFF);
  delay(500);
  ld1.clear();
  ld2.clear();

  ld1.printDigit(44444444);
  ld2.printDigit(44444444);
  delay(500);
  ld1.clear();
  ld2.clear();

  for (int i = 0; i < 100; i++) {
    ld1.printDigit(i);
    ld2.printDigit(i);

    /* Start From Digit 4 */
    ld1.printDigit(-i, 4);
    ld2.printDigit(-i, 4);
    delay(50);
  }

  for (int i = 0; i <= 10; i++) {
    /* Display off */
    ld1.off();
    ld2.off();
    delay(150);

    /* Display on */
    ld1.on();
    ld2.on();
    delay(150);
  }

  /* Clear all display value */
  ld1.clear();
  ld2.clear();
  delay(500);

  for (long i = 0; i < 100; i++) {
    ld1.printDigit(i);
    ld2.printDigit(i);
    delay(25);
  }

  for (int i = 0; i <= 20; i++) {
    /* Select Digit 5 and write B01100011 */
    ld1.write(5, B01100011);
    ld2.write(5, B01100011);
    delay(200);

    /* Select Digit 5 and write B00011101 */
    ld1.write(5, B00011101);
    ld2.write(5, B00011101);
    delay(200);
  }

  /* Clear all display value */
  ld1.clear();
  ld2.clear();
  delay(500);
}
αβ, xy & L₁/L₂ positioning systems w/ 2 28BYJ48 steppers:
https://forum.arduino.cc/index.php?topic=649769.0
Caterpillar robots:
https://forum.arduino.cc/index.php?topic=462107.msg3482895#msg3482895
https://stamm-wilbrandt.de/en/Raspberry_camera.html

david_prentice

From the datasheet:
Quote
Computing Power Dissipation
The upper limit for power dissipation (PD) for the
MAX7219/MAX7221 is determined from the following
equation:
PD = (V + x 8mA) + (V+ - VLED)(DUTY x ISEG x N)
where:
V+ = supply voltage
DUTY = duty cycle set by intensity register
N = number of segments driven (worst case is 8)
VLED = LED forward voltage
ISEG = segment current set by RSET
Dissipation Example:
ISEG = 40mA, N = 8, DUTY = 31/32, VLED = 1.8V at
40mA, V+ = 5.25V
PD = 5.25V(8mA) + (5.25V - 1.8V)(31/32 x
40mA x 8 ) = 1.11W
Thus, for a CERDIP package (qJA = +60°C/W from
Table 12), the maximum allowed ambient temperature
TA is given by:
TJ(MAX) = TA + PD x qJA + 150°C = TA +1.11W x
60°C/W
where TA = +83.4°C.
If your RSET value is 9.53k like the datasheet example this makes 310mA.

What value of RSET is used in your module?
If you have 47k the currents are much lower.
Ebay 8x7-seg modules "look" as if they have RSET=10k

Have you measured the total current for all 64 segments at full brightness ?

Note that even with "low-brightness setting" you still get the same peak current for the PWM.   It just has a lower duty-cycle e.g. lower average current.

David.

Edit.  There is nothing wrong with connecting multiple modules via their signals.
Just connect GND and VCC to proper power pins not signal pins.   Most USB ports will be able to provide enough current.
I note that your brightness=10.  I suggest that you measure the average current with a DMM.   Or with a "Charger Doctor" USB dongle.

Edit again.  I ran your sketch on a single 8x7-seg module (from ETT which has RSEG=10k).   
The Charger Doctor reported 140mA when the sketch was displaying 44444444 and 200mA for 88888888
Obviously the decimal points would add extra current.
And yes,  it is 310mA for 8.8.8.8.8.8.8.8. at brightness=15

No problem for the Uno to control the signals via GPIO pins.   
With the MAX7219 powered by the 5V, GND pins on the Uno.   The Uno powered by USB.

Yes,  it might be handy to plug a 5x1 male from your module into Arduino female sockets.   But it takes far too much current for the power pins.    Safer to use the power header.

HermannSW

I cannot look between the frontside leds and module.
On the backside I did measurs R1 as 9.92KΩ and 9.90KΩ for both modules, not sure whether that is RSET:


> Have you measured the total current for all 64 segments at full brightness ?
>
I have, but at full brightness the DigitLedDisplay library allowed (15, and not 31/32 as shown by you):
Code: [Select]
...
void DigitLedDisplay::setBright(int brightness) {
    if (brightness>=0 && brightness<16)
        write(BRIGHTNESS_ADDR, brightness);
}
...



I displayed all 64 segments on at brightness 15 and measured 36mA:


So it seems that my duty cycle was only 15/32=47%.
With the resistor values I measured, does the measured 36mA fit the formulas?
αβ, xy & L₁/L₂ positioning systems w/ 2 28BYJ48 steppers:
https://forum.arduino.cc/index.php?topic=649769.0
Caterpillar robots:
https://forum.arduino.cc/index.php?topic=462107.msg3482895#msg3482895
https://stamm-wilbrandt.de/en/Raspberry_camera.html

david_prentice

From the datasheet,  MAX7219 has 16 possible intensities i.e. 0-15 representing 1/32, 3/32, ..., 31/32

My module is very old.   But it uses regular Red 7-seg LEDs.   Probably less bright than modern LEDs
And the chip determines the current not the LED forward voltage.

I am surprised that you only draw 36mA.   But if you are taking power from PD6, PD7 pins this will be limiting the current.    You have two GPIO output drivers in series.   You can see the typical characteristics:
Figure 29-353.ATmega328P: I/O Pin Output Voltage vs. Source Current (VCC = 5 V)
Figure 29-351.ATmega328P: I/O Pin Output Voltage vs. Sink Current (VCC = 5 V)

Bear in mind that the curves only show up to 20mA source and sink.

Since you own a smart power supply,  you can measure the Uno current accurately.   Both with GPIO pins and correct power pins.

HermannSW

I lost the complete GPIO pins of my best Raspberry (Pi4B with 4GB ram) that way -- good that the Pi as well as HDMI output and camera kept working:
https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=258806&p=1577913#p1577913
Good news -- I did not loose all GPIO pins of my Pi4B!
They do work fine, only wiringPi gpio library does not work anymore.
I verified with pigpio library "pigs" command and logic analyzer that the first half of pins (1-20) all work:
https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=258806&p=1581680#p1581680
αβ, xy & L₁/L₂ positioning systems w/ 2 28BYJ48 steppers:
https://forum.arduino.cc/index.php?topic=649769.0
Caterpillar robots:
https://forum.arduino.cc/index.php?topic=462107.msg3482895#msg3482895
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Go Up