Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two is31fl3741 boards in serial STEMMA crash on example code #10

Open
dhalbert opened this issue Oct 10, 2021 · 2 comments
Open

Two is31fl3741 boards in serial STEMMA crash on example code #10

dhalbert opened this issue Oct 10, 2021 · 2 comments

Comments

@dhalbert
Copy link
Contributor

I encouraged Discord user RichSad to write this up:

Two is31fl3741 boards in serial STEMMA crash on example code
https://forums.adafruit.com/viewtopic.php?f=60&t=184028

Quoted below:

First of all: The little is31fl3741 RGB LED 13x9 matrix is GORGEOUS! I am so happy I was able to grab two before they sold out for now.

I experienced a reproducible crash attempting to run two is31fl3741 with the two RGB Matrix boards in serial over STEMMA QT connector. I was using unmodified CircuitPython demo code from the learn guide with the slow rainbow color sweep. Devices are listed below. Problem is reproducible 100% of all listed devices. Note: using just one RGB Matrix the code appears to run fine on the same dev boards. Used two short 50mm STEMMA QT male to STEMMA QT male connectors. Tried demo with power over USB C and also with only power from a charged lipo battery.

In all cases with two matrixes in serial, the demo runs for 10 seconds or so (don't quote me on the exact time) and appears to work mirroring the actions on both matrix boards. Then it crashes and cause the mcu to restart (much like a soft reboot when a file is saved). Reproducible every time, with any combo mcu board and power option.

The example code runs fine with a single RGB Matrix board. When a second RGB Matrix is added in serial, the code appears to work at first mirroring the two the RGB Matrix boards. But after some number of seconds it crashes and the board reboots.

I tested this rainbow color sweep sample code from the learn guide on all the STEMMA QT-equipped dev boards I had handy: Adafruit Trinkey RP2040, Feather RP2040, SparkFun Thing Plus Lipo 2040, Pimoroni Pico Lipo 2040. All were running freshly flashed CircuitPython Version '7.0.0 on 2021-09-20'

This is not a critical issue for me. I was trying to wire two RGB Matrix boards in serial over STEMMA QT to see what happened. Code is below. Besides added import os and printing out os.uname() this is the demo from the Learn Guide at https://learn.adafruit.com/adafruit-is31fl3741/python-circuitpython

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import busio
import board
import adafruit_is31fl3741
from random import randint
from rainbowio import colorwheel
from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
import os

print(os.uname())

is31 = Adafruit_RGBMatrixQT(busio.I2C(board.SCL, board.SDA), allocate=adafruit_is31fl3741.PREFER_BUFFER)
is31.set_led_scaling(0xFF)
is31.global_current = 0xFF
is31.enable = True
wheeloffset = 0
while True:
    for y in range(9):
        for x in range(13):
            is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset))
    wheeloffset += 1
    is31.show()
@PaintYourDragon
Copy link
Contributor

Haven’t been able to reproduce this reliably. Did eventually get something happening with 3 chained. Have some theories why this may be happening…most would be resolved with documentation, aren’t code bugs.

Most likely: insufficient current to drive two matrices + microcontroller board. I’m running through a powered USB hub which may be why it’s working more reliably here. This is an easy one to test: instead of animating an every-pixel rainbow cycle, light just a single moving pixel at minimum brightness. If that runs reliably, then yes, it’s a current problem. Also, give the voltage regulator on the microcontroller board the finger test: is it hot? If yes, too much current.

Less likely but should be considered: bus contention when multiple I2C devices share the same address. Everything’s fine as long as their acks/naks are synchronized…but if one acks while the other simultaneously naks, and/or if they’re a bit out of phase, this is Undefined Behavior. Better design is to assign each a unique I2C address via solder pads on the back, and declare two matrix objects, control them separately.

Also possible: I2C write error. They happen sometimes.

For the latter two: a try / except OSError combo may catch this and recover. Most of the 'EyeLights' demos do this — different matrix layout, but same driver chip, so it might still be insightful. An example here:
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/EyeLights_Fire/EyeLights_Fire_CircuitPython/code.py

@DJDevon3
Copy link
Contributor

DJDevon3 commented Apr 10, 2023

RGBMatrixQT unable to set tuple of i2c addresses?

Tried Dan's example and it crashes. Actually, I tried every single example and they all crash with a 2nd device. One works fine, two does not. I can't seem to get it to recognize multiple addressees. I cut the trace between 0x30 and GND and have 0x31 soldered on my 2nd device.

I have is31.global_current = 0x01 so the LED's are barely on and should not be taking up much power. (default is hex 255 0xFF)

I'm using a brand new fresh out of the plastic Feather ESP32-S2 2M PSRAM on latest 8.0.5 stable and mpy from the CP bundle. I'm not using the latest PY library from git. So at least at present, this is a public facing issue not being able to chain them together. Using the 13x9 IS31FL3741 matrix display

Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit Feather ESP32S2 with ESP32S2
Board ID:adafruit_feather_esp32s2

It'll print the OS stats but fails while trying to initialize multiple displays

import board
import adafruit_is31fl3741
from rainbowio import colorwheel
from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
import os

print(os.uname())
i2c = board.STEMMA_I2C()
is31 = Adafruit_RGBMatrixQT(i2c, address=(0x30,0x31), allocate=adafruit_is31fl3741.PREFER_BUFFER)
is31.set_led_scaling(0xFF)
is31.global_current = 0x01
is31.enable = True
wheeloffset = 0
while True:
    for y in range(9):
        for x in range(13):
            is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset))
    wheeloffset += 1
    is31.show()
Traceback (most recent call last):
  File "code.py", line 9, in <module>
  File "adafruit_is31fl3741/adafruit_rgbmatrixqt.py", line 50, in __init__
  File "adafruit_is31fl3741/__init__.py", line 294, in __init__
  File "adafruit_is31fl3741/__init__.py", line 106, in __init__
TypeError: can't convert tuple to int

In the library it just says address=address. I would expect some kind of tuple type there not an int? I can specify 0x30 or 0x31 and either works fine so it is able to pass through 0x30 to use 0x31 no problem.

is31 = Adafruit_RGBMatrixQT(i2c, address=0x30, allocate=adafruit_is31fl3741.PREFER_BUFFER)  # Works
is31 = Adafruit_RGBMatrixQT(i2c, address=0x31, allocate=adafruit_is31fl3741.PREFER_BUFFER)  # Also works

It does not accept a tuple for multiple addresses. It's expecting a single int?

Also worth noting, if you forget to cut the 0x30 trace you'll get a no pull-up on SCL or SDA when connecting the 2nd display regardless of what other address you have soldered. That might help for documenting possible support issues as it was relatively tiny, easy to miss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants