Two 64 width panels shows nothing

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
eeggouveia
 
Posts: 6
Joined: Mon Mar 27, 2023 4:22 pm

Two 64 width panels shows nothing

Post by eeggouveia »

Hi,

I have been working on a personal project with a 64x64 led matrix panel and the project was running great and serving its purpose. The issue starts when I tried to add another 64x64 panel to the side so it becomes a 128x64 screen. I'm using an Arduino Mega, two Waveshare P3 64x64 matrix panels, and the RGBmatrixPanel library to interact with the matrix.

When I initialize the library as 64 as the width value, it will show the text (duplicated text on both panels) correctly. But when I initialize the library as 128 as the width value, it will simply do nothing, all pixels are black.
Is it possible to have more than 64 LEDs in width? Thanks in advance.

Code Example:

Code: Select all

#include "RGBmatrixPanel.h"

#define CLK 11
#define OE   9
#define LAT 10
#define A   A0
#define B   A1
#define C   A2
#define D   A3
#define E   A4

RGBmatrixPanel matrix(A, B, C, D, E, CLK, LAT, OE, false, 164);

void setup() {
  matrix.begin();
  delay(500);
  matrix.setFont(NULL);
  matrix.setTextSize(1);
  matrix.setTextWrap(false);
  matrix.setTextColor(matrix.Color333(7,7,7));
  matrix.setCursor(0,0);
  matrix.print("Hello world! This is my first test.");
}

void loop(){

}

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Two 64 width panels shows nothing

Post by adafruit_support_mike »

No, the RGBmatrixPanel library doesn't support chaining. It expects width values of 32 or 64.

Our Protomatter library does support chaining, but isn't designed for efficiency:

https://learn.adafruit.com/adafruit-pro ... ix-library

It expects a fast 32-bit microcontroller and at least 32k of RAM.

User avatar
eeggouveia
 
Posts: 6
Joined: Mon Mar 27, 2023 4:22 pm

Re: Two 64 width panels shows nothing

Post by eeggouveia »

Is there any Arduino board that you would recommend?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Two 64 width panels shows nothing

Post by adafruit_support_mike »

From the Arduino product family specifically, you'd want to start in the MKR line. Those use a 48MHz SAMD21 microcontroller.

Stepping outside the Arduino line, and keeping the Mega format, our Grand Central M4 would be a good choice:

https://www.adafruit.com/product/4064

It has a 120MHz SAMD51 microcontroller.. about 8x faster than a 16MHz ATmega board.

User avatar
eeggouveia
 
Posts: 6
Joined: Mon Mar 27, 2023 4:22 pm

Re: Two 64 width panels shows nothing

Post by eeggouveia »

I have an Arduino Nano 33 IoT which seems to fulfill the requirements. However, while trying to use the protomatter library and the example given above, I'm not able to initiate the library and I'm receiving the PROTOMATTER_ERR_PINS error.

I'm only using one 64x64 matrix to test. You can find the code that I'm using bellow:

Code: Select all

#include <Adafruit_Protomatter.h>

uint8_t rgbPins[]  = {7, 8, 9, 10, 11, 12};
uint8_t addrPins[] = {17, 18, 19, 20, 21};
uint8_t clockPin   = 14;
uint8_t latchPin   = 15;
uint8_t oePin      = 16;

Adafruit_Protomatter matrix(64, 4, 1, rgbPins, 5, addrPins, clockPin, latchPin, oePin, false);

void setup(void) {
  Serial.begin(9600);

  //Initialize matrix...
  ProtomatterStatus status = matrix.begin();
  Serial.print("Protomatter begin() status: ");
  Serial.println(status != PROTOMATTER_OK);
  if(status != PROTOMATTER_OK) {
    for(;;);
  }

  // Make four color bars (red, green, blue, white) with brightness ramp:
  for(int x=0; x<matrix.width(); x++) {
    uint8_t level = x * 256 / matrix.width(); // 0-255 brightness
    matrix.drawPixel(x, matrix.height() - 4, matrix.color565(level, 0, 0));
    matrix.drawPixel(x, matrix.height() - 3, matrix.color565(0, level, 0));
    matrix.drawPixel(x, matrix.height() - 2, matrix.color565(0, 0, level));
    matrix.drawPixel(x, matrix.height() - 1, matrix.color565(level, level, level));
  }

  // Simple shapes and text, showing GFX library calls:
  matrix.drawCircle(12, 10, 9, matrix.color565(255, 0, 0));               // Red
  matrix.drawRect(14, 6, 17, 17, matrix.color565(0, 255, 0));             // Green
  matrix.drawTriangle(32, 9, 41, 27, 23, 27, matrix.color565(0, 0, 255)); // Blue
  matrix.println("ADAFRUIT"); // Default text color is white

  // AFTER DRAWING, A show() CALL IS REQUIRED TO UPDATE THE MATRIX!

  matrix.show(); // Copy data to matrix buffers
}

void loop(void) {
  Serial.print("Refresh FPS = ~");
  Serial.println(matrix.getFrameCount());
  delay(1000);
}

User avatar
eeggouveia
 
Posts: 6
Joined: Mon Mar 27, 2023 4:22 pm

Re: Two 64 width panels shows nothing

Post by eeggouveia »

I was investigating the repository and found the simple example which refers that the CLOCK and RGB pins should be on the same PORT and that CLOCK should be connected to SDA. Since I'm kind of new in this world, I assume that PORT is either PA or PB, right? SDA in this board is PB08 so I believe that all RGB pins should be on PBs ports.

Image

I have updated my code to reflect this and the board seems to be stuck when calling matrix.begin function. No status is returned and I can't upload any sketches to the board again.

Code: Select all

#include <Adafruit_Protomatter.h>

uint8_t rgbPins[]  = {15, 19, 21, 3, 2, 1};
uint8_t addrPins[] = {10, 9, 8, 7, 6};
uint8_t clockPin   = 18;
uint8_t latchPin   = 12;
uint8_t oePin      = 11;

Adafruit_Protomatter matrix(64, 4, 1, rgbPins, 5, addrPins, clockPin, latchPin, oePin, false);

void setup(void) {
  Serial.begin(9600);

  // Initialize matrix...
  delay(5000);
  Serial.println("Begin");
  ProtomatterStatus status = matrix.begin();
  Serial.println(status != PROTOMATTER_OK);
  if(status != PROTOMATTER_OK) {
    for(;;);
  }

  // Make four color bars (red, green, blue, white) with brightness ramp:
  for(int x=0; x<matrix.width(); x++) {
    uint8_t level = x * 256 / matrix.width(); // 0-255 brightness
    matrix.drawPixel(x, matrix.height() - 4, matrix.color565(level, 0, 0));
    matrix.drawPixel(x, matrix.height() - 3, matrix.color565(0, level, 0));
    matrix.drawPixel(x, matrix.height() - 2, matrix.color565(0, 0, level));
    matrix.drawPixel(x, matrix.height() - 1, matrix.color565(level, level, level));
  }

  // Simple shapes and text, showing GFX library calls:
  matrix.drawCircle(12, 10, 9, matrix.color565(255, 0, 0));               // Red
  matrix.drawRect(14, 6, 17, 17, matrix.color565(0, 255, 0));             // Green
  matrix.drawTriangle(32, 9, 41, 27, 23, 27, matrix.color565(0, 0, 255)); // Blue
  matrix.println("ADAFRUIT"); // Default text color is white

  // AFTER DRAWING, A show() CALL IS REQUIRED TO UPDATE THE MATRIX!

  matrix.show(); // Copy data to matrix buffers
}

void loop(void) {
  Serial.print("Refresh FPS = ~");
  Serial.println(matrix.getFrameCount());
  delay(1000);
}
Does anyone have any idea of what am I doing wrong? Thanks in advanced!

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Two 64 width panels shows nothing

Post by adafruit_support_mike »

eeggouveia wrote: Fri Apr 14, 2023 3:24 pm SDA in this board is PB08 so I believe that all RGB pins should be on PBs ports.
That's correct.

Atmel designs use PORT registers to hold the state of multiple pins. Each bit represents one pin, so the 32-bit registers in a SAMD21 can hold information about 32 pins. By the same token, you can set the state of all 32 pins at once by assigning an integer value to the PORT register.

That's -much- faster than trying to set the pins one at a time, so PORT assignment is a common technique for moving a lot of data quickly. Setting all the pins necessary for one clock-tick of an LED matrix update is an example of the technique in action.

Obviously the trick doesn't work when you use pins from multiple PORT registers.

In many cases, libraries group pins together so it's easier to build the assigned value. This:

Code: Select all

    PORTA = ( controls << 24 ) + ( red << 16 ) + ( green << 8 ) + ( blue )
requires fewer primitive operations than isolating and shifting 32 bits individually. The loss of flexibility pays for significant gains in speed.

User avatar
eeggouveia
 
Posts: 6
Joined: Mon Mar 27, 2023 4:22 pm

Re: Two 64 width panels shows nothing

Post by eeggouveia »

adafruit_support_mike wrote: Sat Apr 15, 2023 4:16 am Atmel designs use PORT registers to hold the state of multiple pins. Each bit represents one pin, so the 32-bit registers in a SAMD21 can hold information about 32 pins. By the same token, you can set the state of all 32 pins at once by assigning an integer value to the PORT register.

That's -much- faster than trying to set the pins one at a time, so PORT assignment is a common technique for moving a lot of data quickly. Setting all the pins necessary for one clock-tick of an LED matrix update is an example of the technique in action.
Thanks for your reply, as you can see in the code above, I'm connecting the CLK, R1, G1, B1, R2, G2, B2 to PORTB and the remainings in PORTA. But it seems not to work.

I'm I using it correctly? Is this the appropriate board? What am I doing wrong?

Not sure how to apply this solution, or where to apply it:
adafruit_support_mike wrote: Sat Apr 15, 2023 4:16 am In many cases, libraries group pins together so it's easier to build the assigned value. This:

Code: Select all

    PORTA = ( controls << 24 ) + ( red << 16 ) + ( green << 8 ) + ( blue )
requires fewer primitive operations than isolating and shifting 32 bits individually. The loss of flexibility pays for significant gains in speed.

User avatar
eeggouveia
 
Posts: 6
Joined: Mon Mar 27, 2023 4:22 pm

Re: Two 64 width panels shows nothing

Post by eeggouveia »

Any help?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Two 64 width panels shows nothing

Post by adafruit_support_mike »

The advice was not to try doing the thing you asked about in the post above.

The Protomatter library isn't fully enough developed to allow easy modification. The options are to run it on the recommended hardware in the default configuration, or to read the code until you understand it well enough to know how it works and what modifications are possible.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”