Large button/led board. Multiple SCL-SDA connections

Hi.

I made a 32 Adafruit Neotrellis units large board. Conected i2c with Arduino Mega.

At large speed of data tranfer it freezes or misses steps. It doesnt happen if I use half the boards, for example.

My question is : Would it help if I make multiple conections of the SCL and SDA cables at differente point

around the board?

I like the board but I don’t understand the question.
Please provide a drawing to illustrate what you mean.
Or, better still, why are you ever asking? What is stopping you from just trying it?

Each module has level shifters with 10k pull up resistors, plus the one from the Mega,
that's a combined pull up of ~300 ohm...

Moris526:
My question is : Would it help if I make multiple conections of the SCL and SDA cables at differente point

More wiring is more wire capacitance, so I think a bad idea.

What speed is the TWI at. default 100kHz or high-speed 400kHz.
Does the code allow you to lower the I2C speed.
Leo..

I2C Pullup Resistor Calculation

A strong pullup (small resistor) prevents the I2C pin on an IC from being able to drive low

What happens to the pullup value when you put 32 of them in parallel ?

raschemmel:
I2C Pullup Resistor Calculation

Very useful. Thank you!

The Mega should be able to pull 300 ohm low enough.

Try adding this at the end of setup()

Wire.setClock(50000); // half speed

Leo..

The Mega should be able to pull 300 ohm low enough.

Not sure how that relates.

The standard I2C pullup (I2C is open collector) is 4.7k ohms.

RT=1/[(1/4700ohms) *32)]
RT = 146.875 ohms

(1/4700= 2.127659e-4)
,(2.127659e-4*32=0.0068085)
1/0.0068085= 146.875 ohms

The 32 boards OP is using have 10k pull up resistors, plus a 10k set on the Mega.
That's 10000/33 = 303 ohm = 16.5mA.

Default I2C is 100kHz/400pF/3mA.
A 5volt Arduino can do the newer FM+ (FastMode) I2C standard, which is 400kHz/4000pF/30mA.

Rise times might be compromised by bus capacitance, so OP should try lowering the default I2C speed first.
Leo..

Remove three quarters of the pullups!

Remove three quarters of the pullups!

I2C is open collector. I don't think you want to short the collector directly to the SCL & SDA lines do you ?

That doesn't souind like a good idea .

Open collector outputs require a pull-up resistor (R in the image above) for the output to be able to properly “output high”. The pull-up resistor is connected between the output pin and the output voltage (Vcc in the image above) that is desired for a high state.Nov 9, 2017

LINK

Thanks for the answers.

I tried adding Wire.setClock(50000); to Setup with no luck.

Give you more info. I send data from Max/MSP. Im sure this part of the proyect is not the problem because

I try already sending data directly from the arduino code with the same result.

The problem its either with the Arduino code ( I think the code is pretty clean) or the comunication whit the

boards.

It at high speed when I press a button the data seems to be messed up, changing colours and missing steps.

I leave the Arduino code and attach a video with the behaviour.

#include "Adafruit_NeoTrellis.h"


#define Y_DIM 16 
#define X_DIM 32
#define INT_PIN 10



Adafruit_NeoTrellis t_array[Y_DIM/4][X_DIM/4] = { 

  

 { Adafruit_NeoTrellis(0x35), Adafruit_NeoTrellis(0x3A), Adafruit_NeoTrellis(0x4A), Adafruit_NeoTrellis(0x33),Adafruit_NeoTrellis(0x4B), Adafruit_NeoTrellis(0x45), Adafruit_NeoTrellis(0x4C), Adafruit_NeoTrellis(0x42) },
 
{ Adafruit_NeoTrellis(0x4D), Adafruit_NeoTrellis(0x3E) , Adafruit_NeoTrellis(0x40), Adafruit_NeoTrellis(0x38),Adafruit_NeoTrellis(0x31), Adafruit_NeoTrellis(0x3D), Adafruit_NeoTrellis(0x3B), Adafruit_NeoTrellis(0x49) },

{ Adafruit_NeoTrellis(0x2F), Adafruit_NeoTrellis(0x2E), Adafruit_NeoTrellis(0x3C), Adafruit_NeoTrellis(0x47),Adafruit_NeoTrellis(0x32), Adafruit_NeoTrellis(0x36), Adafruit_NeoTrellis(0x48), Adafruit_NeoTrellis(0x3F)  },

  { Adafruit_NeoTrellis(0x34), Adafruit_NeoTrellis(0x44), Adafruit_NeoTrellis(0x39), Adafruit_NeoTrellis(0x41), Adafruit_NeoTrellis(0x30), Adafruit_NeoTrellis(0x37), Adafruit_NeoTrellis(0x43), Adafruit_NeoTrellis(0x46) }
,
};


Adafruit_MultiTrellis trellis((Adafruit_NeoTrellis *)t_array, Y_DIM/4, X_DIM/4);


TrellisCallback blink(keyEvent evt){
  
  if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_RISING)
   
     Serial.println (evt.bit.NUM);

      
  else if(evt.bit.EDGE == SEESAW_KEYPAD_EDGE_FALLING)
    
   Serial.println(evt.bit.NUM + 1000);

    
 
  return 0;
}

inline uint32_t rgbColor(uint32_t r, uint32_t g, uint32_t b)
{
  return ((r << 16) | (g << 8) | b);
}
  
   
const byte numChars = 32;
char receivedChars[numChars];
char tempChars[numChars];       
      

int a = 0;
int b = 0;
int c = 0;
int d = 0;

boolean newData = false; 
   
   
////////////////////////////////////////////////////////
   
   
   void setup() {
  Serial.begin(9600);
  

  Wire.setClock(50000); 

  pinMode(INT_PIN,INPUT);
  
  
  !trellis.begin();
  
   
  for(int y=0; y<Y_DIM; y++){
    for(int x=0; x<X_DIM; x++){
      
      trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_RISING, true);
      trellis.activateKey(x, y, SEESAW_KEYPAD_EDGE_FALLING, true);
      trellis.registerCallback(x, y, blink);
   
    }
  }
     
/////////////////////////////////////////////////////////////////////////////////

}

void loop() {
 

  if(!digitalRead(INT_PIN)){
    trellis.read();
  }
  
 

  recvWithStartEndMarkers();
    if (newData == true) {
        strcpy(tempChars, receivedChars);
            
        parseData();
        
        newData = false;
    }

   

}

    
/////////////////////////////////////////////////////////////////////

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;

    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0';
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
}

///////////////////////////////////////////////////////////////////

void parseData() {

     
    
    
    char * strtokIndx; 

    strtokIndx = strtok(tempChars," ");     
     
  
    
   
    a = atoi(strtokIndx);     

    strtokIndx = strtok(NULL, " ");
    b = atoi(strtokIndx);     


    strtokIndx = strtok(NULL, " ");
    c = atoi(strtokIndx);    

    strtokIndx = strtok(NULL, " ");
    d = atoi(strtokIndx);    

      
   
   
   trellis.setPixelColor(a,  rgbColor(b,c,d));
    

  trellis.show();   
  
    
      
    
    
    

  
}

Desktop.zip (1.74 MB)

Did you debounce the button ?
If not you're probably seeing button bounce

raschemmel:
Did you debounce the button ?
If not you're probably seeing button bounce

But with a smaller board the behaviour is normal.

Do you know what debouncing is and how it relates to buttons ?

How long/messy is the wiring between I2C master and LED board.
Leo..

Thank you for you time.

raschemmel:
Do you know what debouncing is and how it relates to buttons ?

I have a vague idea of what debouncing is. I had that problem with econders. Im not discarding your sugestion.

Is it posibble to have that effect with the only difference of loading more individual boards on the arduino code,

But still having no change in the fisical board? If you think so, I will dive into it.

Wawa:
How long/messy is the wiring between I2C master and LED board.
Leo..

From Arduino Mega 2560 to the boards just SDA, SCL, Ground and Interrupt wires. The arduino is conected via

usb. The Board is connected by a 5v 10amp power supply, at 6 different points around the edges.

raschemmel:
Do you know what debouncing is and how it relates to buttons ?

Wawa:
How long/messy is the wiring between I2C master and LED board.
Leo..

Another data is I dont have any capacitor... (dont know if its relevant)

I don't see any schematic so I don't know what a 'button' has to do with this post.
Post a schematic that shows the button and then we can discuss debouncing.
The fact that you are not clear about debouncing and why it is necessary is a red flag
that may indicate it is relevant to your issue. Without seeing the schematic of the
button circuit I can neither confirm or deny that it is.

raschemmel:
I don’t see any schematic so I don’t know what a ‘button’ has to do with this post.
Post a schematic that shows the button and then we can discuss debouncing.
The fact that you are not clear about debouncing and why it is necessary is a red flag
that may indicate it is relevant to your issue. Without seeing the schematic of the
button circuit I can neither confirm or deny that it is.

Sorry. Not following you. I have 16 buttons on each individual board…

I attached a zip with a video showing the behaviour.

The boards are connected with SDA, SCL, Ground and Interrupt wires to Arduino Mega 2560

The only way to isolate th problem is disconnect
the I2C boards from the bus ( ten at a time)
until the issue disappears and then you'll have some data to use to determine if it is a timing issue or a pullup resistor issue. If it turns out to be a pullup resistor issue then you'll have to replace all the pullups with a higher value (15k to 20k).
If it is a timing issue then you have to use a
slower bus speed. (I don't know how to change that)
We are assuming you did your due diligence measuring power supply voltage and current.